* BAEL-4825

* BAEL-4825 added integration tests

* BAEL-4825 Fix line continuation indents

* BAEL-4825 Fix line continuation indents
This commit is contained in:
Amy DeGregorio 2021-04-01 11:14:25 -04:00 committed by GitHub
parent 9706d7b6fd
commit 86575c861b
2 changed files with 14 additions and 14 deletions

View File

@ -17,20 +17,20 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
auth.inMemoryAuthentication()
.withUser("user")
.password(encoder.encode("password"))
.roles("USER")
.and()
.withUser("admin")
.password(encoder.encode("admin"))
.roles("USER", "ADMIN");
.withUser("user")
.password(encoder.encode("password"))
.roles("USER")
.and()
.withUser("admin")
.password(encoder.encode("admin"))
.roles("USER", "ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(EndpointRequest.toAnyEndpoint())
.authorizeRequests((requests) -> requests.anyRequest()
.hasRole("ADMIN"));
.authorizeRequests((requests) -> requests.anyRequest()
.hasRole("ADMIN"));
http.httpBasic();
}
}

View File

@ -21,16 +21,16 @@ public class EndpointEnablingIntegrationTest {
@WithMockUser(username = "user", password = "password", roles = "USER")
public void givenWrongAuthentication_whenCallingActuator_thenReturns401() throws Exception {
mockMvc.perform(get("/actuator"))
.andExpect(status().isForbidden());
.andExpect(status().isForbidden());
}
@Test
@WithMockUser(username = "admin", password = "admin", roles = "ADMIN")
public void givenProperAuthentication_whenCallingActuator_thenReturnsExpectedEndpoints() throws Exception {
mockMvc.perform(get("/actuator"))
.andExpect(jsonPath("$._links").exists())
.andExpect(jsonPath("$._links.beans").exists())
.andExpect(jsonPath("$._links.env").exists())
.andExpect(jsonPath("$._links.shutdown").exists());
.andExpect(jsonPath("$._links").exists())
.andExpect(jsonPath("$._links.beans").exists())
.andExpect(jsonPath("$._links.env").exists())
.andExpect(jsonPath("$._links.shutdown").exists());
}
}