working hasGlobalAdminRole and prepare for Micrometer metrics with Spring Security #127
@ -16,6 +16,7 @@ public class WebSecurityConfig {
|
|||||||
public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exception {
|
||||||
return http
|
return http
|
||||||
.authorizeHttpRequests(authorize -> authorize
|
.authorizeHttpRequests(authorize -> authorize
|
||||||
|
.requestMatchers("/api/**").permitAll() // TODO.impl: implement authentication
|
||||||
.requestMatchers("/actuator/**").permitAll()
|
.requestMatchers("/actuator/**").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng;
|
package net.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -14,8 +14,12 @@ import org.springframework.test.context.TestPropertySource;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestPropertySource(properties = {"management.port=0"})
|
@TestPropertySource(properties = {"management.port=0", "server.port=0"})
|
||||||
class HsadminNgApplicationIntegrationTest {
|
// IMPORTANT: To test prod config, do not use test profile!
|
||||||
|
class WebSecurityConfigIntegrationTest {
|
||||||
|
|
||||||
|
@Value("${local.server.port}")
|
||||||
|
private int serverPort;
|
||||||
|
|
||||||
@Value("${local.management.port}")
|
@Value("${local.management.port}")
|
||||||
private int managementPort;
|
private int managementPort;
|
||||||
@ -23,6 +27,14 @@ class HsadminNgApplicationIntegrationTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TestRestTemplate restTemplate;
|
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
|
@Test
|
||||||
public void shouldSupportActuatorEndpoint() {
|
public void shouldSupportActuatorEndpoint() {
|
||||||
final var result = this.restTemplate.getForEntity(
|
final var result = this.restTemplate.getForEntity(
|
Loading…
Reference in New Issue
Block a user