Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions bruno/APIM/Get_Auth_Token.bru
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion bruno/APIM/Post_Document_Bundle_via_APIM_INT.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Post Document Bundle via APIM - INT
type: http
seq: 4
seq: 3
}

post {
Expand Down
84 changes: 84 additions & 0 deletions bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authenticate.bru
Original file line number Diff line number Diff line change
@@ -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
}
84 changes: 84 additions & 0 deletions bruno/APIM/Test_MNS_Pathology_Api_Unable_To_Authorize_Event.bru
Original file line number Diff line number Diff line change
@@ -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
}
84 changes: 84 additions & 0 deletions bruno/APIM/Test_MNS_Service_Experience_Bad_Gateway_Error.bru
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
Loading
Loading