BAEL-797 fixing security settings
This commit is contained in:
parent
f23b54220f
commit
909e7a9ecd
|
@ -29,11 +29,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
.httpBasic()
|
.httpBasic()
|
||||||
.and()
|
.and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
.antMatchers("/*.js","/*.html","/*.ico", "/*").permitAll()
|
|
||||||
.antMatchers("/book-service/books").permitAll()
|
|
||||||
.antMatchers("/zipkin/**").permitAll()
|
|
||||||
.antMatchers("/eureka/**").hasRole("ADMIN")
|
.antMatchers("/eureka/**").hasRole("ADMIN")
|
||||||
.anyRequest().authenticated()
|
.anyRequest().permitAll()
|
||||||
.and()
|
.and()
|
||||||
.logout()
|
.logout()
|
||||||
.and()
|
.and()
|
||||||
|
|
|
@ -35,8 +35,9 @@ public class LiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenAccessProtectedResourceWithoutLogin_thenRedirectToLogin() {
|
public void whenAccessProtectedResourceWithoutLogin_thenRedirectToLogin() {
|
||||||
final Response response = RestAssured.get(ROOT_URI + "/book-service/books/1");
|
final Response response = RestAssured.get(ROOT_URI + "/rating-service/ratings?bookId=1");
|
||||||
Assert.assertEquals(HttpStatus.UNAUTHORIZED.value(), response.getStatusCode());
|
Assert.assertEquals(HttpStatus.FORBIDDEN.value(), response.getStatusCode());
|
||||||
|
Assert.assertNotNull(response.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -46,7 +47,7 @@ public class LiveTest {
|
||||||
.auth().preemptive().basic("user", "password")
|
.auth().preemptive().basic("user", "password")
|
||||||
.header("X-XSRF-TOKEN", sessionData.getCsrf())
|
.header("X-XSRF-TOKEN", sessionData.getCsrf())
|
||||||
.filter(sessionFilter)
|
.filter(sessionFilter)
|
||||||
.get(ROOT_URI + "/book-service/books/1");
|
.get(ROOT_URI + "/rating-service/ratings?bookId=1");
|
||||||
Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode());
|
Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode());
|
||||||
Assert.assertNotNull(response.getBody());
|
Assert.assertNotNull(response.getBody());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue