fix ArchitectureTest by moving HsadminNgApplicationIntegrationTest to WebSecurityConfigIntegrationTest
This commit is contained in:
parent
15f97466f8
commit
593a3545d0
@ -16,6 +16,7 @@ public class WebSecurityConfig {
|
||||
public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exception {
|
||||
return http
|
||||
.authorizeHttpRequests(authorize -> authorize
|
||||
.requestMatchers("/api/**").permitAll() // TODO.impl: implement authentication
|
||||
.requestMatchers("/actuator/**").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng;
|
||||
package net.hostsharing.hsadminng.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -14,8 +14,12 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestPropertySource(properties = {"management.port=0"})
|
||||
class HsadminNgApplicationIntegrationTest {
|
||||
@TestPropertySource(properties = {"management.port=0", "server.port=0"})
|
||||
// IMPORTANT: To test prod config, do not use test profile!
|
||||
class WebSecurityConfigIntegrationTest {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
private int serverPort;
|
||||
|
||||
@Value("${local.management.port}")
|
||||
private int managementPort;
|
||||
@ -23,6 +27,14 @@ class HsadminNgApplicationIntegrationTest {
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void shouldSupportPingEndpoint() {
|
||||
final var result = this.restTemplate.getForEntity(
|
||||
"http://localhost:" + this.serverPort + "/api/ping", String.class);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(result.getBody()).startsWith("pong");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSupportActuatorEndpoint() {
|
||||
final var result = this.restTemplate.getForEntity(
|
Loading…
Reference in New Issue
Block a user