diff --git a/pom.xml b/pom.xml
index 3aeaa40..0e066af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,13 @@
${spring-security.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
org.codehaus.plexus
plexus-utils
@@ -162,6 +169,12 @@
${log4j.version}
+
+ org.yaml
+ snakeyaml
+ 2.0
+
+
org.springframework.boot
@@ -198,6 +211,17 @@
4.3.0
test
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
+ org.springframework.security
+ spring-security-core
+
+
+
diff --git a/src/main/java/de/caritas/cob/liveservice/websocket/registry/SocketUserRegistry.java b/src/main/java/de/caritas/cob/liveservice/websocket/registry/SocketUserRegistry.java
index 37fd836..c9e686d 100644
--- a/src/main/java/de/caritas/cob/liveservice/websocket/registry/SocketUserRegistry.java
+++ b/src/main/java/de/caritas/cob/liveservice/websocket/registry/SocketUserRegistry.java
@@ -31,6 +31,10 @@ public synchronized void addUser(WebSocketUserSession webSocketUserSession) {
this.subscribedUsers.add(webSocketUserSession);
}
+ public synchronized void clearAllSessions() {
+ this.subscribedUsers.clear();
+ }
+
/**
* Removes the user session if a session with given id exists.
*
@@ -66,4 +70,5 @@ public synchronized List retrieveAllUsers() {
return new LinkedList<>(this.subscribedUsers);
}
+
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 2c86c14..973dc64 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -24,3 +24,8 @@ live.event.retry.amount=5
live.event.minimum.seconds.before.retry=1
logging.level.root=WARN
+
+management.endpoint.health.enabled=true
+management.endpoint.health.show-details=never
+management.endpoints.web.exposure.include=health
+management.health.probes.enabled=true
\ No newline at end of file
diff --git a/src/test/java/de/caritas/cob/liveservice/LiveServiceApplicationIT.java b/src/test/java/de/caritas/cob/liveservice/LiveServiceApplicationIT.java
index 24cb2d9..fec4b72 100644
--- a/src/test/java/de/caritas/cob/liveservice/LiveServiceApplicationIT.java
+++ b/src/test/java/de/caritas/cob/liveservice/LiveServiceApplicationIT.java
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.jeasy.random.EasyRandom;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -51,6 +52,11 @@ class LiveServiceApplicationIT extends StompClientIntegrationTest {
@Autowired
private MockMvc mockMvc;
+ @BeforeEach
+ void setup() {
+ socketUserRegistry.clearAllSessions();
+ }
+
@Test
void connectToSocket_Should_connect_When_accessTokenIsValid() throws Exception {
var stompSession = performConnect(FIRST_VALID_USER);
@@ -96,6 +102,7 @@ void connectToSocket_Should_registerExpectedUser_When_accessTokenIsValid() throw
@Test
void subscribe_Should_subscribeUser() throws Exception {
var stompSession = performConnect(FIRST_VALID_USER);
+
final Subscription subscription = performSubscribe(stompSession);
@@ -188,7 +195,7 @@ void sendLiveEvent_Should_sendVideoDenyRequestMessageEventToUser_When_userIsSubs
.andExpect(status().isOk());
await()
- .atMost(15, SECONDS)
+ .atMost(25, SECONDS)
.until(receivedMessages::size, is(1));
var resultMessage = receivedMessages.iterator().next();
assertThat(resultMessage, notNullValue());
diff --git a/src/test/java/de/caritas/cob/liveservice/StompClientIntegrationTest.java b/src/test/java/de/caritas/cob/liveservice/StompClientIntegrationTest.java
index 58acad1..f042c83 100644
--- a/src/test/java/de/caritas/cob/liveservice/StompClientIntegrationTest.java
+++ b/src/test/java/de/caritas/cob/liveservice/StompClientIntegrationTest.java
@@ -48,7 +48,7 @@
public abstract class StompClientIntegrationTest extends AbstractJUnit4SpringContextTests {
protected static final String SUBSCRIPTION_ENDPOINT = "/user/events";
- protected static final int MESSAGE_TIMEOUT = 5;
+ protected static final int MESSAGE_TIMEOUT = 10;
protected static final String FIRST_VALID_USER = "firstValidUser";
static final String SECOND_VALID_USER = "secondValidUser";
static final String THIRD_VALID_USER = "thirdValidUser";
diff --git a/src/test/java/de/caritas/cob/liveservice/api/controller/ActuatorControllerIT.java b/src/test/java/de/caritas/cob/liveservice/api/controller/ActuatorControllerIT.java
new file mode 100644
index 0000000..ff77252
--- /dev/null
+++ b/src/test/java/de/caritas/cob/liveservice/api/controller/ActuatorControllerIT.java
@@ -0,0 +1,53 @@
+package de.caritas.cob.liveservice.api.controller;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.hamcrest.Matchers.is;
+import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import de.caritas.cob.liveservice.LiveServiceApplication;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+@SpringBootTest(classes = LiveServiceApplication.class)
+@TestPropertySource(properties = "spring.profiles.active=testing")
+@AutoConfigureMockMvc(addFilters = false)
+class ActuatorControllerIT {
+
+ @Autowired private WebApplicationContext context;
+
+ private MockMvc mockMvc;
+
+ @BeforeEach
+ public void setup() {
+ mockMvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build();
+ }
+
+ @Test
+ void getHealtcheck_Should_returnHealtcheck() throws Exception {
+ mockMvc
+ .perform(get("/actuator/health").contentType(APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("status", is("UP")));
+ }
+
+ @Test
+ void getActuatorEndpoints_Should_returnNotFound_When_ActuatorEndpointsNotExposed() throws Exception {
+ mockMvc
+ .perform(get("/actuator/env").contentType(APPLICATION_JSON))
+ .andExpect(status().isNotFound());
+
+ mockMvc
+ .perform(get("/actuator/beans").contentType(APPLICATION_JSON))
+ .andExpect(status().isNotFound());
+ }
+}