diff --git a/bruno/APIM/Get_Auth_Token.bru b/bruno/APIM/Get_Auth_Token.bru index 74257faf..bc80a744 100644 --- a/bruno/APIM/Get_Auth_Token.bru +++ b/bruno/APIM/Get_Auth_Token.bru @@ -20,19 +20,17 @@ script:pre-request { const jwt = require("jsonwebtoken"); const fs = require("node:fs"); const crypto = require("node:crypto"); - const secret = bru.getEnvVar("JWT_SECRET"); const privateKeyPath = bru.getEnvVar("PRIVATE_KEY_PATH"); - if (!secret) { throw new Error("JWT_SECRET environment variable is missing."); } + if (!privateKeyPath) { throw new Error("PRIVATE_KEY_PATH environment variable is missing."); } const privateKey = fs.readFileSync(privateKeyPath); - const payload = { sub: secret, iss: secret, @@ -45,19 +43,14 @@ script:pre-request { algorithm: 'RS512', header: { kid: kid } }; - const token = jwt.sign(payload, privateKey, options); - let new_body = req.getBody(); new_body.push({ name: "client_assertion", value: token }); - req.setBody(new_body); } - const environment = bru.getGlobalEnvVar("APIM_ENV") generateAuthToken(bru, req, `https://${environment}.api.service.nhs.uk/oauth2/token`, bru.getEnvVar("KID")); } - script:post-response { bru.setGlobalEnvVar("auth_token", res.getBody().access_token) } diff --git a/bruno/APIM/Post_Document_Bundle_via_APIM_INT.bru b/bruno/APIM/Post_Document_Bundle_via_APIM_INT.bru index 2d24c9be..61a5c528 100644 --- a/bruno/APIM/Post_Document_Bundle_via_APIM_INT.bru +++ b/bruno/APIM/Post_Document_Bundle_via_APIM_INT.bru @@ -1,7 +1,7 @@ meta { name: Post Document Bundle via APIM - INT type: http - seq: 4 + seq: 3 } post { diff --git a/bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authenticate.bru b/bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authenticate.bru new file mode 100644 index 00000000..7d68562b --- /dev/null +++ b/bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authenticate.bru @@ -0,0 +1,84 @@ +meta { + name: Test_MNS_Pathology_Api_Unable_To_Authenticate + type: http + seq: 5 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "MNS_AUTHENTICATION_ERROR" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: eq "Failed to publish an event" +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authorize_Event.bru b/bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authorize_Event.bru new file mode 100644 index 00000000..35730ee9 --- /dev/null +++ b/bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authorize_Event.bru @@ -0,0 +1,84 @@ +meta { + name: Test_MNS_Pathology_Api_Unable_To_Authorize_Event + type: http + seq: 5 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "MNS_AUTHORIZATION_ERROR" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: eq "Failed to publish an event" +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_MNS_Service_Experience_Bad_Gateway_Error.bru b/bruno/APIM/Test_MNS_Service_Experience_Bad_Gateway_Error.bru new file mode 100644 index 00000000..99ed5495 --- /dev/null +++ b/bruno/APIM/Test_MNS_Service_Experience_Bad_Gateway_Error.bru @@ -0,0 +1,84 @@ +meta { + name: Test_MNS_Service_Experience_Bad_Gateway_Error + type: http + seq: 7 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "MNS_BAD_GATEWAY_ERROR" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: eq "Failed to publish an event" +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_MNS_Service_Experience_Gateway_Timeout_Error.bru b/bruno/APIM/Test_MNS_Service_Experience_Gateway_Timeout_Error.bru new file mode 100644 index 00000000..b278d6c3 --- /dev/null +++ b/bruno/APIM/Test_MNS_Service_Experience_Gateway_Timeout_Error.bru @@ -0,0 +1,84 @@ +meta { + name: Test_MNS_Service_Experience_Gateway_Timeout_Error + type: http + seq: 8 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "MNS_GATEWAY_TIMEOUT_ERROR" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: eq "Failed to publish an event" +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_MNS_Service_Experience_Validation_Error.bru b/bruno/APIM/Test_MNS_Service_Experience_Validation_Error.bru new file mode 100644 index 00000000..9df7519a --- /dev/null +++ b/bruno/APIM/Test_MNS_Service_Experience_Validation_Error.bru @@ -0,0 +1,84 @@ +meta { + name: Test_MNS_Service_Experience_Validation_Error + type: http + seq: 9 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "MNS_VALIDATION_ERROR" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: eq "Failed to publish an event" +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_MNS_Service_Returns_Client_Side_Error.bru b/bruno/APIM/Test_MNS_Service_Returns_Client_Side_Error.bru new file mode 100644 index 00000000..4f8e9a74 --- /dev/null +++ b/bruno/APIM/Test_MNS_Service_Returns_Client_Side_Error.bru @@ -0,0 +1,84 @@ +meta { + name: Test_MNS_Service_Returns_Client_Side_Error + type: http + seq: 6 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "MNS_SERVER_ERROR" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: eq "Failed to publish an event" +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_PDM_Api_Server_Error.bru b/bruno/APIM/Test_PDM_Api_Server_Error.bru new file mode 100644 index 00000000..731a50fd --- /dev/null +++ b/bruno/APIM/Test_PDM_Api_Server_Error.bru @@ -0,0 +1,96 @@ +meta { + name: Test_PDM_Api_Server_Error + type: http + seq: 12 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "test-nhs-number" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "patient", + "resource": { + "resourceType": "Patient", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "PDM_SERVER_ERROR" + } + ] + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: contains Failed to send document: +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_PDM_Api_Validation_Error.bru b/bruno/APIM/Test_PDM_Api_Validation_Error.bru new file mode 100644 index 00000000..f6901469 --- /dev/null +++ b/bruno/APIM/Test_PDM_Api_Validation_Error.bru @@ -0,0 +1,96 @@ +meta { + name: Test_PDM_Api_Validation_Error + type: http + seq: 10 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "test-nhs-number" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "patient", + "resource": { + "resourceType": "Patient", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "PDM_VALIDATION_ERROR" + } + ] + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 500 + res.body.issue[0].diagnostics: contains Failed to send document: +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/APIM/Test_PDM_Bundle_Succesful_Response.bru b/bruno/APIM/Test_PDM_Bundle_Succesful_Response.bru new file mode 100644 index 00000000..502810ac --- /dev/null +++ b/bruno/APIM/Test_PDM_Bundle_Succesful_Response.bru @@ -0,0 +1,95 @@ +meta { + name: Test_PDM_Bundle_Succesful_Response + type: http + seq: 12 +} + +post { + url: https://{{APIM_ENV}}.api.service.nhs.uk/pathology-laboratory-reporting-pr-{{PR_NUMBER}}/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "document", + "entry": [ + { + "fullUrl": "composition", + "resource": { + "resourceType": "Composition", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "servicerequest" + } + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "test-nhs-number" + } + } + } + }, + { + "fullUrl": "servicerequest", + "resource": { + "resourceType": "ServiceRequest", + "requester": { + "reference": "practitionerrole" + } + } + }, + { + "fullUrl": "practitionerrole", + "resource": { + "resourceType": "PractitionerRole", + "organization": { + "reference": "organization" + } + } + }, + { + "fullUrl": "patient", + "resource": { + "resourceType": "Patient", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + ] + } + }, + { + "fullUrl": "organization", + "resource": { + "resourceType": "Organization", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "testOrg" + } + ] + } + } + ] + } +} + +assert { + res.status: eq 200 +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru b/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru index 1f289b16..899b5eeb 100644 --- a/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru +++ b/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru @@ -1,7 +1,7 @@ meta { name: Post a Transaction Bundle type: http - seq: 5 + seq: 2 } post { diff --git a/bruno/PDM/environments/PDM.bru b/bruno/PDM/environments/PDM.bru new file mode 100644 index 00000000..7e5d0a67 --- /dev/null +++ b/bruno/PDM/environments/PDM.bru @@ -0,0 +1,6 @@ +vars:secret [ + PRIVATE_KEY_PATH, + JWT_SECRET, + PR_NUMBER, + KID +]