Skip to content

Commit

Permalink
Merge pull request #25 from virtualidentityag/CARITAS-285-improve-not…
Browse files Browse the repository at this point in the history
…ifications-add-actuator

fix: added actuator endpoint to enable logs in runtime
  • Loading branch information
tkuzynow authored Nov 28, 2024
2 parents 7af4f83 + 875be5b commit 05f28da
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ management.endpoint.health.enabled=true
management.endpoint.health.show-details=never
management.endpoints.web.exposure.include=health,loggers
management.endpoint.health.probes.enabled=true
management.endpoint.loggers.enabled=true

spring.zipkin.baseUrl=
spring.sleuth.sampler.percentage=1.0
spring.zipkin.sender.type=web
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

Expand All @@ -38,12 +39,35 @@ public void setup() {

@Test
void getHealtcheck_Should_returnHealtcheck() throws Exception {

// when // then
mockMvc
.perform(get("/actuator/health").contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("status", is("UP")));
}

@Test
void updateLoggerLevel_Should_ChangeLogLevel() throws Exception {
// given
String loggerName = "de.caritas.cob.userservice.api.adapters.web.controller";
String newLevel = "DEBUG";

// when
mockMvc
.perform(
MockMvcRequestBuilders.post("/actuator/loggers/" + loggerName)
.contentType(APPLICATION_JSON)
.content("{\"configuredLevel\": \"" + newLevel + "\"}"))
.andExpect(status().isNoContent());

// then
mockMvc
.perform(get("/actuator/loggers/" + loggerName).contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.configuredLevel", is(newLevel)));
}

@Test
void getHealtcheck_Should_return403ByCsrfRulesForEndpointsNotExposed() throws Exception {
mockMvc
Expand Down

0 comments on commit 05f28da

Please sign in to comment.