BAEL-797 fixing security settings

This commit is contained in:
tschiman 2017-04-29 21:10:49 -06:00
parent f23b54220f
commit 909e7a9ecd
2 changed files with 5 additions and 7 deletions

View File

@ -29,11 +29,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/*.js","/*.html","/*.ico", "/*").permitAll()
.antMatchers("/book-service/books").permitAll()
.antMatchers("/zipkin/**").permitAll()
.antMatchers("/eureka/**").hasRole("ADMIN")
.anyRequest().authenticated()
.anyRequest().permitAll()
.and()
.logout()
.and()

View File

@ -35,8 +35,9 @@ public class LiveTest {
@Test
public void whenAccessProtectedResourceWithoutLogin_thenRedirectToLogin() {
final Response response = RestAssured.get(ROOT_URI + "/book-service/books/1");
Assert.assertEquals(HttpStatus.UNAUTHORIZED.value(), response.getStatusCode());
final Response response = RestAssured.get(ROOT_URI + "/rating-service/ratings?bookId=1");
Assert.assertEquals(HttpStatus.FORBIDDEN.value(), response.getStatusCode());
Assert.assertNotNull(response.getBody());
}
@Test
@ -46,7 +47,7 @@ public class LiveTest {
.auth().preemptive().basic("user", "password")
.header("X-XSRF-TOKEN", sessionData.getCsrf())
.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.assertNotNull(response.getBody());
}