Skip to content

Commit be0d4a1

Browse files
committed
"Added ActiveProfiles in test classes and removed secret keys from properties file
The ActiveProfiles were added to specify which profiles are active when running the tests in the 'DetectionControllerTest', 'ChartControllerIntegrationTest', 'CameraControllerTest', 'ImageControllerTest', 'LiveViewControllerTest', 'AlarmControllerTest', and 'FirebaseControllerTest' Kotlin test classes. This will allow testing under various application configurations. This change is necessary for creating an environment specific to testing. Additionally, the 'keycloak.credentials.secret' and 'spring.security.oauth2.client.registration.banyuwangi-test.client-secret' keys were removed from the application.properties file to improve security by avoiding the exposure of secret keys. Also, the 'streaming.streamingToken' had been deleted because it is not required anymore in this configuration."
1 parent ef35165 commit be0d4a1

File tree

8 files changed

+14
-3
lines changed

8 files changed

+14
-3
lines changed

src/main/resources/application.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ keycloak.auth-server-url = https://auth.banyuwangikab.go.id
44
keycloak.ssl-required = external
55
keycloak.resource =banyuwangi-webapp
66
keycloak.verify-token-audience=false
7-
keycloak.credentials.secret =fxraDjJMINZSunzgmom1GtrALENPN7sn
87
keycloak.use-resource-role-mappings = false
98

109
spring.security.oauth2.client.provider.banyuwangi.issuer-uri=https://auth.banyuwangikab.go.id/realms/banyuwangi
1110

1211
spring.security.oauth2.client.provider.banyuwangi-test.issuer-uri=https://auth.banyuwangikab.go.id/realms/banyuwangi
1312
spring.security.oauth2.client.registration.banyuwangi-test.client-id=banyuwangi-test
14-
spring.security.oauth2.client.registration.banyuwangi-test.client-secret=MZASrIBdZrMSViBBgLhOCnOeatyiDYPD
1513
spring.security.oauth2.client.registration.banyuwangi-test.authorization-grant-type=client_credentials
1614

1715
spring.rabbitmq.addresses=localhost:5672
@@ -73,7 +71,6 @@ dashboard.app.fcmRateLimit=4
7371

7472
streaming.baseUrl=https://stream-ai.banyuwangikab.go.id
7573
streaming.server=https://stream-ai.banyuwangikab.go.id
76-
streaming.streamingToken=9f8c835e-1896-4f54-b544-29d2a6df802a
7774

7875
gcp.firebase.serviceAccount=classpath:banyuwangi-dashboard-firebase-adminsdk.json
7976

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/AlarmControllerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired
99
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
1010
import org.springframework.boot.test.context.SpringBootTest
1111
import org.springframework.http.MediaType
12+
import org.springframework.test.context.ActiveProfiles
1213
import org.springframework.test.web.servlet.MockMvc
1314
import org.springframework.test.web.servlet.get
1415

1516
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1617
@AutoConfigureMockMvc
18+
@ActiveProfiles("secret", "default")
1719
class AlarmControllerTest(
1820
@Autowired private val mockMvc: MockMvc,
1921
@Autowired private val alarmRepo: AlarmRepo,

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/CameraControllerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import org.springframework.beans.factory.annotation.Autowired
1111
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
1212
import org.springframework.boot.test.context.SpringBootTest
1313
import org.springframework.http.MediaType
14+
import org.springframework.test.context.ActiveProfiles
1415
import org.springframework.test.web.servlet.MockMvc
1516
import org.springframework.test.web.servlet.get
1617
import org.springframework.test.web.servlet.post
1718
import java.util.UUID
1819

1920
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
2021
@AutoConfigureMockMvc
22+
@ActiveProfiles("secret", "default")
2123
class CameraControllerTest(
2224
@Autowired private val mockMvc: MockMvc,
2325
@Autowired private val tokenManager: TokenManager,

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/ChartControllerIntegrationTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith
77
import org.springframework.beans.factory.annotation.Autowired
88
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
99
import org.springframework.boot.test.context.SpringBootTest
10+
import org.springframework.test.context.ActiveProfiles
1011
import org.springframework.test.context.junit.jupiter.SpringExtension
1112
import org.springframework.test.web.servlet.MockMvc
1213
import org.springframework.test.web.servlet.get
@@ -20,6 +21,7 @@ import java.net.InetSocketAddress
2021
@ExtendWith(SpringExtension::class)
2122
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
2223
@AutoConfigureMockMvc
24+
@ActiveProfiles("secret", "default")
2325
class ChartControllerIntegrationTest(
2426
@Autowired private val mockMvc: MockMvc,
2527
@Autowired private val tokenManager: TokenManager,

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/DetectionControllerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired
2222
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
2323
import org.springframework.boot.test.context.SpringBootTest
2424
import org.springframework.data.domain.Sort.Direction
25+
import org.springframework.test.context.ActiveProfiles
2526
import org.springframework.test.context.junit.jupiter.SpringExtension
2627
import org.springframework.test.web.servlet.MockMvc
2728
import org.springframework.test.web.servlet.get
@@ -35,6 +36,7 @@ import java.util.UUID
3536
@ExtendWith(SpringExtension::class)
3637
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
3738
@AutoConfigureMockMvc
39+
@ActiveProfiles("secret", "default")
3840
class DetectionControllerTest(
3941
@Autowired private val mockMvc: MockMvc,
4042
@Autowired private val tokenManager: TokenManager,

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/FirebaseControllerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired
1010
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
1111
import org.springframework.boot.test.context.SpringBootTest
1212
import org.springframework.http.MediaType
13+
import org.springframework.test.context.ActiveProfiles
1314
import org.springframework.test.context.junit.jupiter.SpringExtension
1415
import org.springframework.test.web.servlet.MockMvc
1516
import org.springframework.test.web.servlet.delete
@@ -18,6 +19,7 @@ import org.springframework.test.web.servlet.put
1819
@ExtendWith(SpringExtension::class)
1920
@SpringBootTest
2021
@AutoConfigureMockMvc
22+
@ActiveProfiles("secret", "default")
2123
class FirebaseControllerTest(
2224
@Autowired private val mockMvc: MockMvc,
2325
@Autowired private val tokenManager: TokenManager,

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/LiveViewControllerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired
1717
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
1818
import org.springframework.boot.test.context.SpringBootTest
1919
import org.springframework.http.MediaType
20+
import org.springframework.test.context.ActiveProfiles
2021
import org.springframework.test.context.junit.jupiter.SpringExtension
2122
import org.springframework.test.web.servlet.MockMvc
2223
import org.springframework.test.web.servlet.get
@@ -26,6 +27,7 @@ import java.util.UUID
2627
@ExtendWith(SpringExtension::class)
2728
@SpringBootTest
2829
@AutoConfigureMockMvc
30+
@ActiveProfiles("secret", "default")
2931
class LiveViewControllerTest(
3032
@Autowired private val mockMvc: MockMvc,
3133
@Autowired private val tokenManager: TokenManager,

src/test/kotlin/com/katalisindonesia/imageserver/controller/ImageControllerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
1111
import org.springframework.boot.test.context.SpringBootTest
1212
import org.springframework.core.io.ClassPathResource
1313
import org.springframework.http.MediaType
14+
import org.springframework.test.context.ActiveProfiles
1415
import org.springframework.test.context.junit.jupiter.SpringExtension
1516
import org.springframework.test.web.servlet.MockMvc
1617
import org.springframework.test.web.servlet.get
@@ -30,6 +31,7 @@ import java.util.UUID
3031
classes = [BanyuwangiCoreApplication::class]
3132
)
3233
@AutoConfigureMockMvc
34+
@ActiveProfiles("secret", "default")
3335
class ImageControllerTest(
3436
@Autowired private val mockMvc: MockMvc,
3537
@Autowired private val imageProperties: ImageProperties,

0 commit comments

Comments
 (0)