diff --git a/Dockerfile b/Dockerfile index 88bdf31..e670b59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,4 +26,7 @@ COPY --chown=1001 ehealthid-rp/target/ehealthid-rp-jar-with-dependencies.jar /de USER 1001 +# The default port, configurable though. +EXPOSE 1234 + ENTRYPOINT [ "/deployments/run-java.sh" ] \ No newline at end of file diff --git a/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/App.java b/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/App.java index 26bd0bc..b44df79 100644 --- a/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/App.java +++ b/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/App.java @@ -44,7 +44,8 @@ public Set getSingletons() { new AuthEndpoint( config.baseUri(), config.relyingParty(), sessionRepo, tokenIssuer, authenticationFlow), new OpenIdEndpoint(config.baseUri(), config.relyingParty(), keyStore), - new JacksonJsonProvider(configureObjectMapper())); + new JacksonJsonProvider(configureObjectMapper()), + new HealthEndpoint()); } @Override diff --git a/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpoint.java b/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpoint.java new file mode 100644 index 0000000..f5ec37e --- /dev/null +++ b/ehealthid-rp/src/main/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpoint.java @@ -0,0 +1,19 @@ +package com.oviva.ehealthid.relyingparty.ws; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; + +@Path("/health") +public class HealthEndpoint { + + private static final String STATUS_UP = "{\"status\":\"UP\"}"; + + @GET + public Response get() { + // For now if this endpoint is reachable then the service is up. There is no hard dependency + // that could be down. + return Response.ok(STATUS_UP).type(MediaType.APPLICATION_JSON_TYPE).build(); + } +} diff --git a/ehealthid-rp/src/test/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpointTest.java b/ehealthid-rp/src/test/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpointTest.java new file mode 100644 index 0000000..f7e0601 --- /dev/null +++ b/ehealthid-rp/src/test/java/com/oviva/ehealthid/relyingparty/ws/HealthEndpointTest.java @@ -0,0 +1,20 @@ +package com.oviva.ehealthid.relyingparty.ws; + +import static org.junit.jupiter.api.Assertions.*; + +import jakarta.ws.rs.core.Response.Status; +import org.junit.jupiter.api.Test; + +class HealthEndpointTest { + + @Test + void get() { + var sut = new HealthEndpoint(); + + // when + var res = sut.get(); + + // then + assertEquals(Status.OK.getStatusCode(), res.getStatus()); + } +}