generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ gateway add SecurityConfiguration test
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...rc/test/java/de.muenchen.oss.refarch.gateway/configuration/SecurityConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package de.muenchen.oss.refarch.gateway.configuration; | ||
|
||
import static de.muenchen.oss.refarch.gateway.TestConstants.SPRING_TEST_PROFILE; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; | ||
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@AutoConfigureWebTestClient | ||
@AutoConfigureObservability | ||
@ActiveProfiles(profiles = { SPRING_TEST_PROFILE }) | ||
public class SecurityConfigurationTest { | ||
@Autowired | ||
WebTestClient api; | ||
|
||
@Test | ||
void accessSecuredResourceRootThenUnauthorized() { | ||
// api.get().uri("/").exchange().expectStatus().isUnauthorized(); | ||
// 302 is returned instead of 401 because auf cookie session | ||
api.get().uri("/").exchange().expectStatus().isFound(); | ||
} | ||
|
||
@Test | ||
void accessSecuredResourceClientsThenUnauthorized() { | ||
api.get().uri("/clients/test").exchange().expectStatus().isUnauthorized(); | ||
} | ||
|
||
@Test | ||
void accessUnsecuredResourceActuatorHealthThenOk() { | ||
api.get().uri("/actuator/health").exchange().expectStatus().isOk(); | ||
} | ||
|
||
@Test | ||
void accessUnsecuredResourceActuatorHealthLivenessThenOk() { | ||
api.get().uri("/actuator/health/liveness").exchange().expectStatus().isOk(); | ||
} | ||
|
||
@Test | ||
void accessUnsecuredResourceActuatorHealthReadinessThenOk() { | ||
api.get().uri("/actuator/health/readiness").exchange().expectStatus().isOk(); | ||
} | ||
|
||
@Test | ||
void accessUnsecuredResourceActuatorInfoThenOk() { | ||
api.get().uri("/actuator/info").exchange().expectStatus().isOk(); | ||
} | ||
|
||
@Test | ||
void accessUnsecuredResourceActuatorMetricsThenOk() { | ||
api.get().uri("/actuator/metrics").exchange().expectStatus().isOk(); | ||
} | ||
} |