Skip to content

Commit d1437b6

Browse files
committedMay 15, 2024
[HIA-721]
WIP Adding smoke test; checking it runs in CI
1 parent 7b4b716 commit d1437b6

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:current-alpine3.17
2+
3+
RUN apk update && apk add bash curl --no-cache
4+
5+
RUN curl https://assess-risks-and-needs-dev.hmpps.service.justice.gov.uk/v3/api-docs > risk-management-plan-search.json && \
6+
sed -i "s+\*/\*+application/json+g" risk-management-plan-search.json && \
7+
npm install -g @stoplight/prism-cli
8+
9+
RUN adduser -D user
10+
11+
USER user
12+
13+
CMD prism mock -p 4091 -h 0.0.0.0 /risk-management-plan-search.json

‎docker-compose.yml

+10
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ services:
136136
ports:
137137
- '4090:4010'
138138

139+
risk-management-plan-api:
140+
build:
141+
context: .
142+
dockerfile: Dockerfile.setup-risk-management-plan-search
143+
container_name: risk-management-plan-api
144+
healthcheck:
145+
test: 'wget --header="Authorization: Bearer abc" http://127.0.0.1:4091/risks/crn/D1974X/risk-management-plan -O /dev/null'
146+
ports:
147+
- '4091:4010'
148+
139149
local-stack-aws:
140150
image: localstack/localstack:3.0
141151
container_name: local-stack-aws
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.smoke.person
2+
3+
import io.kotest.core.spec.style.DescribeSpec
4+
import io.kotest.matchers.shouldBe
5+
import io.kotest.matchers.string.shouldContain
6+
import org.springframework.http.HttpStatus
7+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.removeWhitespaceAndNewlines
8+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.helpers.IntegrationAPIHttpClient
9+
import java.net.URLEncoder
10+
import java.nio.charset.StandardCharsets
11+
12+
class RiskManagementSmokeTest : DescribeSpec(
13+
{
14+
val basePath = "v1/persons"
15+
val httpClient = IntegrationAPIHttpClient()
16+
val hmppsId = "2004/13116M"
17+
val tailPath = "risk-management-plan"
18+
val encodedHmppsId = URLEncoder.encode(hmppsId, StandardCharsets.UTF_8)
19+
20+
it("returns a list of risk management plans using crn / hmppsId as search parameters") {
21+
22+
val response = httpClient.performAuthorised("$basePath/$encodedHmppsId/$tailPath")
23+
24+
response.statusCode().shouldBe(HttpStatus.OK.value())
25+
response.body().shouldContain("\"data\":[")
26+
response.body().shouldContain(
27+
"""
28+
"assessmentStatus": "string",
29+
"assessmentType": "string",
30+
"initiationDate": "2024-05-04T01:04:20",
31+
"assessmentStatus": "string",
32+
"assessmentType": "string",
33+
""".removeWhitespaceAndNewlines(),
34+
)
35+
}
36+
}
37+
)

0 commit comments

Comments
 (0)