Skip to content

Commit 51eb28a

Browse files
authored
Merge branch 'main' into add_temporary_instance
2 parents 5748f6e + 43329b2 commit 51eb28a

File tree

6 files changed

+153
-10
lines changed

6 files changed

+153
-10
lines changed

.github/cfg/ods_codes_int.txt

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,104 @@
1-
A83008
2-
FA565
1+
FA090
2+
FAC08
3+
FCD08
4+
FCF21
5+
FCM53
6+
FCP28
7+
FD444
8+
Fd976
9+
FDW46
10+
FE302
11+
FEH17
12+
FEW47
13+
FEW57
14+
FEX32
15+
FEX56
16+
FF403
17+
FF736
18+
FFD93
19+
FFR23
20+
FFR55
21+
FFV85
22+
FFX28
23+
FG043
24+
FG236
25+
FGR00
26+
FGX57
27+
FH657
28+
FHD08
29+
FHF37
30+
FHV89
31+
fj438
32+
FJG01
33+
FJR35
34+
FK857
35+
FKJ13
36+
FKP67
37+
FKR57
38+
FKT41
39+
FL080
40+
FL584
41+
FL669
42+
FLG00
43+
FLH14
44+
FLK02
45+
FM623
46+
FMA26
47+
FMC81
48+
FMG07
49+
FMP08
50+
FMQ08
51+
FMR16
52+
FNG76
53+
FNK11
54+
FNQ36
55+
FNQ40
56+
FP237
57+
FPG70
58+
FQ056
59+
FQD41
60+
FQF92
61+
FQL64
62+
FQR12
63+
FR035
64+
FR116
65+
Fr664
66+
FR791
67+
FRD48
68+
FRH86
69+
FRN27
70+
FRQ45
71+
FRT44
72+
FRV24
73+
FT095
74+
FT608
75+
FT774
76+
FTF34
77+
FTG55
78+
FTL32
79+
FTL60
80+
FTP37
81+
FTQ69
82+
FTT94
83+
FTY56
84+
FV528
85+
FV585
86+
FVC24
87+
FVD61
88+
FVJ67
89+
FVN59
90+
FVP34
91+
FVQ48
92+
FW047
93+
FW122
94+
FW252
95+
FW270
96+
FWC44
97+
FWE04
98+
FWR95
99+
FWW39
100+
FX237
101+
FXE88
102+
FXF99
103+
FXH76
104+
FXR02

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ jobs:
300300
ENABLE_BACKUP: True
301301
ENABLE_NOTIFICATIONS_INTERNAL: true
302302
ENABLE_NOTIFICATIONS_EXTERNAL: true
303-
ENABLED_SYSTEMS: "Internal Test System, Apotec Ltd - Apotec CRM - Production, CrxPatientApp, nhsPrescriptionApp, Titan PSU Prod"
304-
BLOCKED_SITE_ODS_CODES: "B3J1Z"
303+
ENABLED_SYSTEMS: "Internal Test System" # Workaround empty string handling
304+
BLOCKED_SITE_ODS_CODES: "XXXXX" # Workaround empty string handling
305305
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"
306306
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
307307
MTLS_KEY: psu-mtls-1
@@ -383,8 +383,8 @@ jobs:
383383
ENABLE_BACKUP: True
384384
ENABLE_NOTIFICATIONS_INTERNAL: true
385385
ENABLE_NOTIFICATIONS_EXTERNAL: true
386-
ENABLED_SYSTEMS: "Internal Test System"
387-
BLOCKED_SITE_ODS_CODES: "XXXXX" # Workaround empty string handling
386+
ENABLED_SYSTEMS: "Internal Test System" # Workaround empty string handling
387+
BLOCKED_SITE_ODS_CODES: "XXXXX" # Workaround empty string handling
388388
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c" # INT and PROD share a value
389389
NOTIFY_API_BASE_URL: "https://api.service.nhs.uk"
390390
MTLS_KEY: psu-mtls-1

packages/nhsNotifyLambda/src/utils/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function tokenExchange(
1919
])
2020

2121
const API_KEY = apiKeyRaw?.toString().trim()
22-
const PRIVATE_KEY = privateKeyRaw?.toString()
22+
const PRIVATE_KEY = privateKeyRaw?.toString().trim()
2323
const KID = kidRaw?.toString().trim()
2424

2525
if (!API_KEY || !PRIVATE_KEY || !KID) {

packages/nhsNotifyUpdateCallback/src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export async function fetchSecrets(logger: Logger): Promise<void> {
6161
throw new Error("Failed to get secret values from the AWS secret manager")
6262
}
6363

64-
APP_ID = appIdValue.toString()
65-
API_KEY = apiKeyValue.toString()
64+
APP_ID = appIdValue.toString().trim()
65+
API_KEY = apiKeyValue.toString().trim()
6666

6767
// Check again to catch empty strings
6868
if (!appIdValue || !apiKeyValue) {

packages/updatePrescriptionStatus/src/updatePrescriptionStatus.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ const lambdaHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayPro
111111

112112
const dataItems = buildDataItems(requestEntries, xRequestID, applicationName)
113113

114+
// If the dataItems contain any invalid ODS codes, then return an error
115+
const invalidODSCodes = dataItems
116+
.filter(item => {
117+
const odsCode = item.PharmacyODSCode
118+
if (!odsCode || !/^[A-Z0-9]+$/.test(odsCode)) return true
119+
return false
120+
})
121+
.map(it => it.PharmacyODSCode)
122+
if (invalidODSCodes.length) {
123+
logger.error("Received invalid ODS codes", {invalidODSCodes})
124+
responseEntries = [badRequest(`Received invalid ODS codes: ${JSON.stringify(invalidODSCodes)}`)]
125+
return response(400, responseEntries)
126+
}
127+
114128
// AEA-4317 (AEA-4365) - Intercept INT test prescriptions
115129
let testPrescription1Forced201 = false
116130
let testPrescriptionForcedError = false
@@ -318,7 +332,7 @@ export function buildDataItems(
318332
LastModified: task.lastModified!,
319333
LineItemID: task.focus!.identifier!.value!.toUpperCase(),
320334
PatientNHSNumber: task.for!.identifier!.value!,
321-
PharmacyODSCode: task.owner!.identifier!.value!.toUpperCase(),
335+
PharmacyODSCode: task.owner!.identifier!.value!.toUpperCase().trim(),
322336
PrescriptionID: task.basedOn![0].identifier!.value!.toUpperCase(),
323337
...(repeatNo !== undefined && {RepeatNo: repeatNo}),
324338
RequestID: xRequestID,

packages/updatePrescriptionStatus/tests/testHandler.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,33 @@ describe("Integration tests for updatePrescriptionStatus handler", () => {
217217
)
218218
})
219219

220+
const testInvalidODSCode = async (invalidODSCode: string, expectedErrorCode: string) => {
221+
const body = generateBody()
222+
const entryResource: any = body.entry?.[0]?.resource
223+
if (entryResource?.owner?.identifier) {
224+
entryResource.owner.identifier.value = invalidODSCode
225+
}
226+
227+
const event: APIGatewayProxyEvent = generateMockEvent(body)
228+
229+
const response: APIGatewayProxyResult = await handler(event, {})
230+
231+
expect(response.statusCode).toBe(400)
232+
expect(JSON.parse(response.body)).toEqual(
233+
bundleWrap([
234+
badRequest(`Received invalid ODS codes: ["${expectedErrorCode}"]`)
235+
])
236+
)
237+
}
238+
239+
it("When the ODS code contains a special character, the handler returns a 400 error", async () => {
240+
await testInvalidODSCode("AB1$%2", "AB1$%2")
241+
})
242+
243+
it("When the ODS code is a space character, the handler returns a 400 error", async () => {
244+
await testInvalidODSCode(" ", "")
245+
})
246+
220247
it("when dynamo call fails, expect 500 status code and internal server error message", async () => {
221248
const event = generateMockEvent(requestDispatched)
222249
dynamoDBMockSend.mockRejectedValue(new Error() as never)

0 commit comments

Comments
 (0)