[BAEL-7608] - Fixed SecurityIntegrationTest with redirecting to login

This commit is contained in:
amit2103 2018-07-31 00:41:20 +05:30
parent 7c83e6d22e
commit 680e0c24a7
3 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import reactor.ipc.netty.NettyContext; import reactor.ipc.netty.NettyContext;
import reactor.ipc.netty.http.server.HttpServer; import reactor.ipc.netty.http.server.HttpServer;
@ComponentScan(basePackages = {"com.baeldung.security"}) @ComponentScan(basePackages = {"com.baeldung.reactive.security"})
@EnableWebFlux @EnableWebFlux
public class SpringSecurity5Application { public class SpringSecurity5Application {

View File

@ -19,7 +19,7 @@ public class SecurityConfig {
@Bean @Bean
public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) { public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) {
return http.authorizeExchange() return http.authorizeExchange()
.pathMatchers("/admin") .pathMatchers("/", "/admin")
.hasAuthority("ROLE_ADMIN") .hasAuthority("ROLE_ADMIN")
.matchers(EndpointRequest.to(FeaturesEndpoint.class)) .matchers(EndpointRequest.to(FeaturesEndpoint.class))
.permitAll() .permitAll()

View File

@ -28,7 +28,7 @@ public class SecurityIntegrationTest {
@Test @Test
public void whenNoCredentials_thenRedirectToLogin() { public void whenNoCredentials_thenRedirectToLogin() {
this.rest.get().uri("/").exchange().expectStatus().is4xxClientError(); this.rest.get().uri("/").exchange().expectStatus().is3xxRedirection();
} }
@Test @Test