Skip to content

Commit

Permalink
DSND-3203: Make healthcheck private (#158)
Browse files Browse the repository at this point in the history
* DSND-3203: Make healthcheck not public

* DSND-3203: Address vulnerable deps

* DSND-3203: Remove fixing vulnerable transitive dep

* Upgrading this transitive dep breaks the service and is out of scope for this ticket.
* Service needs a major refactor.
  • Loading branch information
sthompsonCH authored Dec 18, 2024
1 parent 8b250dd commit 2a695ef
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 33 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -126,6 +127,10 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down

This file was deleted.

8 changes: 6 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
management.endpoints.web.base-path=/psc-data-api
management.endpoints.web.path-mapping.health=/healthcheck
management.endpoints.enabled-by-default=false
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck
management.endpoint.health.show-details=never
management.endpoint.health.enabled=true
management.health.mongo.enabled=false

chs.api.kafka.url=${CHS_KAFKA_API_URL:localhost}
chs.api.kafka.resource-changed.uri=${PSC_API_RESOURCE_CHANGED_URI:/private/resource-changed}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uk.gov.companieshouse.pscdataapi;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
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.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.web.servlet.MockMvc;

@AutoConfigureMockMvc
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class PscDataApiApplicationIT {

@Autowired
private MockMvc mockMvc;

@Test
void shouldStartApplication() {
Executable executable = () -> PscDataApiApplication.main(new String[0]);
assertDoesNotThrow(executable);
}

@Test
void shouldReturn200FromGetHealthEndpoint() throws Exception {
this.mockMvc.perform(get("/healthcheck"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string("{\"status\":\"UP\"}"));
}
}

This file was deleted.

8 changes: 6 additions & 2 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ feature.psc_individual_full_record_get=true

items-per-page-max-internal=500

management.endpoints.web.base-path=/psc-data-api
management.endpoints.web.path-mapping.health=/healthcheck
management.endpoints.enabled-by-default=false
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck
management.endpoint.health.show-details=never
management.endpoint.health.enabled=true
management.health.mongo.enabled=false

spring.data.mongodb.uri=${MONGODB_URL:mongodb://mongo:27017}
spring.data.mongodb.name=company_pscs
Expand Down
3 changes: 1 addition & 2 deletions terraform/groups/ecs-service/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ locals {
kms_alias = "alias/${var.aws_profile}/environment-services-kms"
lb_listener_rule_priority = 88
lb_listener_paths = [
"/psc-data-api/healthcheck",
"/company/*/persons-with-significant-control",
"/company/*/persons-with-significant-control/*"
]
healthcheck_path = "/psc-data-api/healthcheck" #healthcheck path for psc-data-api
healthcheck_path = "/healthcheck" #healthcheck path for psc-data-api
healthcheck_matcher = "200"
vpc_name = local.stack_secrets["vpc_name"]
s3_config_bucket = data.vault_generic_secret.shared_s3.data["config_bucket_name"]
Expand Down

0 comments on commit 2a695ef

Please sign in to comment.