Skip to content

Commit

Permalink
Merge pull request #47 from companieshouse/feature/SAN-229-penalty-pa…
Browse files Browse the repository at this point in the history
…yment-api-healthcheck

SAN-229 Update Healthcheck endpoints to include penalty-payment-api in base path
  • Loading branch information
rbull-ch authored Feb 11, 2025
2 parents 9398f85 + 100552a commit 4f34846
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM 169942020521.dkr.ecr.eu-west-2.amazonaws.com/base/golang:1.19-bullseye-builder AS BUILDER
FROM 169942020521.dkr.ecr.eu-west-2.amazonaws.com/base/golang:1.19-bullseye-builder AS builder

RUN /bin/go_build

FROM 169942020521.dkr.ecr.eu-west-2.amazonaws.com/base/golang:debian11-runtime

COPY --from=BUILDER /build/out/app ./
COPY --from=builder /build/out/app ./

COPY assets ./assets

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ In order to run this API locally you will need to install the following:
## Endpoints
| Method | Path | Description |
|:----------|:-----------------------------------------------------------------------|:----------------------------------------------------------------------|
| **GET** | `/healthcheck` | Standard healthcheck endpoint |
| **GET** | `/healthcheck/finance-system` | Healthcheck endpoint to check whether the finance system is available |
| **GET** | `/penalty-payment-api/healthcheck` | Standard healthcheck endpoint |
| **GET** | `/penalty-payment-api/healthcheck/finance-system` | Healthcheck endpoint to check whether the finance system is available |
| **GET** | `/company/{company_number}/penalties/late-filing` | List the Late Filing Penalties for a company |
| **POST** | `/company/{company_number}/penalties/late-filing/payable` | Create a payable penalty resource |
| **GET** | `/company/{company_number}/penalties/late-filing/payable/{id}` | Get a payable resource |
Expand Down
10 changes: 5 additions & 5 deletions handlers/healthcheck_finance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestUnitHandleHealthCheckFinance(t *testing.T) {
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", now.Hour()-100)
cfg.WeeklyMaintenanceDay = now.Weekday()

req, _ := http.NewRequest("GET", "/healthcheck/finance-system", nil)
req, _ := http.NewRequest("GET", "/penalty-payment-api/healthcheck/finance-system", nil)
w := httptest.NewRecorder()
HandleHealthCheckFinanceSystem(w, req)

Expand All @@ -43,7 +43,7 @@ func TestUnitHandleHealthCheckFinance(t *testing.T) {
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", now.Hour()+100)
cfg.WeeklyMaintenanceDay = now.Weekday()

req, _ := http.NewRequest("GET", "/healthcheck/finance-system", nil)
req, _ := http.NewRequest("GET", "/penalty-payment-api/healthcheck/finance-system", nil)
w := httptest.NewRecorder()
HandleHealthCheckFinanceSystem(w, req)

Expand All @@ -65,7 +65,7 @@ func TestUnitHandleHealthCheckFinance(t *testing.T) {
cfg.PlannedMaintenanceStart = (now.AddDate(0, 0, -1)).Format("02 Jan 06 15:04 MST")
cfg.PlannedMaintenanceEnd = (now.AddDate(0, 0, 1)).Format("02 Jan 06 15:04 MST")

req, _ := http.NewRequest("GET", "/healthcheck/finance-system", nil)
req, _ := http.NewRequest("GET", "/penalty-payment-api/healthcheck/finance-system", nil)
w := httptest.NewRecorder()
HandleHealthCheckFinanceSystem(w, req)

Expand All @@ -86,7 +86,7 @@ func TestUnitHandleHealthCheckFinance(t *testing.T) {
cfg.WeeklyMaintenanceDay = now.Weekday()
cfg.PlannedMaintenanceStart = "invalid"

req, _ := http.NewRequest("GET", "/healthcheck/finance-system", nil)
req, _ := http.NewRequest("GET", "/penalty-payment-api/healthcheck/finance-system", nil)
w := httptest.NewRecorder()
HandleHealthCheckFinanceSystem(w, req)

Expand All @@ -103,7 +103,7 @@ func TestUnitHandleHealthCheckFinance(t *testing.T) {
cfg.PlannedMaintenanceStart = (now).Format("02 Jan 06 15:04 MST")
cfg.PlannedMaintenanceEnd = "invalid"

req, _ := http.NewRequest("GET", "/healthcheck/finance-system", nil)
req, _ := http.NewRequest("GET", "/penalty-payment-api/healthcheck/finance-system", nil)
w := httptest.NewRecorder()
HandleHealthCheckFinanceSystem(w, req)

Expand Down
4 changes: 2 additions & 2 deletions handlers/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func Register(mainRouter *mux.Router, cfg *config.Config, svc dao.Service, penal
RequireElevatedAPIKeyPrivilege: true,
}

mainRouter.HandleFunc("/healthcheck", healthCheck).Methods(http.MethodGet).Name("healthcheck")
mainRouter.HandleFunc("/healthcheck/finance-system", HandleHealthCheckFinanceSystem).Methods(http.MethodGet).Name("healthcheck-finance-system")
mainRouter.HandleFunc("/penalty-payment-api/healthcheck", healthCheck).Methods(http.MethodGet).Name("healthcheck")
mainRouter.HandleFunc("/penalty-payment-api/healthcheck/finance-system", HandleHealthCheckFinanceSystem).Methods(http.MethodGet).Name("healthcheck-finance-system")

appRouter := mainRouter.PathPrefix("/company/{company_number}/penalties/late-filing").Subrouter()
appRouter.HandleFunc("", HandleGetPenalties(penaltyDetailsMap, allowedTransactionsMap)).Methods(http.MethodGet).Name("get-penalties-original")
Expand Down
20 changes: 10 additions & 10 deletions issuer_gateway/api/healthcheck_finance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestUnitCheckScheduledMaintenance(t *testing.T) {
// Given
startHour := currentTime.Hour() - 2
endHour := startHour + 1
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%d00", startHour)
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%d00", endHour)
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%02d00", startHour)
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", endHour)
cfg.WeeklyMaintenanceDay = currentTime.Weekday()

// When
Expand All @@ -45,8 +45,8 @@ func TestUnitCheckScheduledMaintenance(t *testing.T) {
Convey("Current time is during weekly maintenance times", t, func() {
// Given
endHour := currentTime.Hour() + 1
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%d00", currentTime.Hour())
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%d00", endHour)
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%02d00", currentTime.Hour())
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", endHour)
cfg.WeeklyMaintenanceDay = currentTime.Weekday()

// When
Expand All @@ -62,8 +62,8 @@ func TestUnitCheckScheduledMaintenance(t *testing.T) {
// Given
startHour := currentTime.Hour() + 1
endHour := currentTime.Hour() + 2
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%d00", startHour)
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%d00", endHour)
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%02d00", startHour)
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", endHour)
cfg.WeeklyMaintenanceDay = currentTime.Weekday()

// When
Expand Down Expand Up @@ -154,8 +154,8 @@ func TestUnitCheckScheduledMaintenance(t *testing.T) {
Convey("Current time is during scheduled maintenance times, planned ends later", t, func() {
// Given
weeklyEndHour := currentTime.Hour() + 1
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%d00", currentTime.Hour())
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%d00", weeklyEndHour)
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%02d00", currentTime.Hour())
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", weeklyEndHour)
cfg.WeeklyMaintenanceDay = currentTime.Weekday()
plannedStartTime := currentTime.Add(time.Minute * -1).Truncate(time.Minute).Round(0)
cfg.PlannedMaintenanceStart = plannedStartTime.Format(time.RFC822)
Expand All @@ -174,8 +174,8 @@ func TestUnitCheckScheduledMaintenance(t *testing.T) {
Convey("Current time is during scheduled maintenance times, planned ends earlier", t, func() {
// Given
weeklyEndHour := currentTime.Hour() + 2
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%d00", currentTime.Hour())
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%d00", weeklyEndHour)
cfg.WeeklyMaintenanceStartTime = fmt.Sprintf("%02d00", currentTime.Hour())
cfg.WeeklyMaintenanceEndTime = fmt.Sprintf("%02d00", weeklyEndHour)
cfg.WeeklyMaintenanceDay = currentTime.Weekday()
plannedStartTime := currentTime.Add(time.Hour * -1).Truncate(time.Minute).Round(0)
cfg.PlannedMaintenanceStart = plannedStartTime.Format(time.RFC822)
Expand Down
2 changes: 1 addition & 1 deletion routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ weight: 900
routes:
1: ^/company/(.*)/penalties/late-filing
2: ^/company/(.*)/penalties/late-filing.*
3: ^/healthcheck/finance-system
3: ^/penalty-payment-api/healthcheck/finance-system
10 changes: 5 additions & 5 deletions spec/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
}
],
"paths": {
"/healthcheck": {
"/penalty-payment-api/healthcheck": {
"get": {
"tags": [
"Healthcheck"
],
"description": "Check the health of the Penalty Payment Service (PPS) API",
"responses": {
"200": {
"description": "healthy"
"description": "Healthy"
}
}
}
},
"/healthcheck/finance-system": {
"/penalty-payment-api/healthcheck/finance-system": {
"get": {
"tags": [
"Healthcheck"
],
"description": "Check the health of the Finance System",
"responses": {
"200": {
"description": "healthy"
"description": "Healthy"
},
"503": {
"description": "service unavailable",
"description": "Service unavailable",
"schema": {
"$ref": "#/definitions/ServiceUnavailable"
}
Expand Down

0 comments on commit 4f34846

Please sign in to comment.