Skip to content

Commit

Permalink
Activiti/Activiti#4366: add actuator INFO exclude Matcher (#1147)
Browse files Browse the repository at this point in the history
* Activiti/Activiti#4366: add actuaror info exclude Matcher

* Activiti/Activiti#4366: remove Unused import
  • Loading branch information
Salvatore Caccia authored Jul 6, 2023
1 parent 7d5b17d commit 94ff914
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@
import org.activiti.cloud.services.test.containers.RabbitMQContainerApplicationInitializer;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;

Expand All @@ -43,16 +39,9 @@ public class TestActuatorSecurityIT {
@Autowired
private MockMvc mockMvc;

@MockBean
private BuildProperties buildProperties;

@Autowired(required = false)
@Autowired
private CommonSecurityAutoConfiguration commonSecurityAutoConfiguration;

@SpringBootConfiguration
@EnableAutoConfiguration
static class Application {}

@Test
public void should_getActuatorLoggersAndReturnUnauthorized() throws Exception {
mockMvc.perform(get("/actuator/loggers")).andExpect(status().isUnauthorized());
Expand All @@ -62,4 +51,9 @@ public void should_getActuatorLoggersAndReturnUnauthorized() throws Exception {
public void should_getActuatorHealthAndReturn200ok() throws Exception {
mockMvc.perform(get("/actuator/health")).andExpect(status().isOk());
}

@Test
public void should_getActuatorInfoAndReturn200ok() throws Exception {
mockMvc.perform(get("/actuator/info")).andExpect(status().isOk());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.github.benmanes.caffeine.cache.Caffeine;
import feign.RequestInterceptor;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.activiti.api.runtime.shared.security.PrincipalGroupsProvider;
Expand Down Expand Up @@ -239,7 +240,12 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
private RequestMatcher actuatorEndpointsMatcher() {
RequestMatcher actuatorMatcher = new AntPathRequestMatcher("/actuator/**");
RequestMatcher healthMatcher = new AntPathRequestMatcher("/actuator/health/**");
return request -> actuatorMatcher.matches(request) && !healthMatcher.matches(request);
RequestMatcher infoMatcher = new AntPathRequestMatcher("/actuator/info/**");

List<RequestMatcher> excludeMatchers = Arrays.asList(healthMatcher, infoMatcher);

return request ->
actuatorMatcher.matches(request) && excludeMatchers.stream().noneMatch(matcher -> matcher.matches(request));
}

@Bean
Expand Down

0 comments on commit 94ff914

Please sign in to comment.