Skip to content

Commit

Permalink
ARC-1238: Added health endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrichner-oviva committed Feb 8, 2024
1 parent 8d99d23 commit 9eee8a6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public Set<Object> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 9eee8a6

Please sign in to comment.