From 86575c861b3920dd917534992686b7d69dd3f3cd Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Thu, 1 Apr 2021 11:14:25 -0400 Subject: [PATCH] BAEL-4825 (#10616) * BAEL-4825 * BAEL-4825 added integration tests * BAEL-4825 Fix line continuation indents * BAEL-4825 Fix line continuation indents --- .../enabling/SecurityConfiguration.java | 18 +++++++++--------- .../EndpointEnablingIntegrationTest.java | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/enabling/SecurityConfiguration.java b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/enabling/SecurityConfiguration.java index 24b78642f2..894c24693e 100644 --- a/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/enabling/SecurityConfiguration.java +++ b/spring-boot-modules/spring-boot-actuator/src/main/java/com/baeldung/endpoints/enabling/SecurityConfiguration.java @@ -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(); } } diff --git a/spring-boot-modules/spring-boot-actuator/src/test/java/com/baeldung/endpoints/enabling/EndpointEnablingIntegrationTest.java b/spring-boot-modules/spring-boot-actuator/src/test/java/com/baeldung/endpoints/enabling/EndpointEnablingIntegrationTest.java index 8a9dd4ca72..8274619517 100644 --- a/spring-boot-modules/spring-boot-actuator/src/test/java/com/baeldung/endpoints/enabling/EndpointEnablingIntegrationTest.java +++ b/spring-boot-modules/spring-boot-actuator/src/test/java/com/baeldung/endpoints/enabling/EndpointEnablingIntegrationTest.java @@ -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()); } }