From 0a6e2cdcc2b9f45915c90c5596ac3acc8b7db5cd Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 20 May 2025 11:57:37 +0100 Subject: [PATCH 01/16] CCM-10077: repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 4 +--- .../policies/AssignMessage.MessageBatches.Create.Request.xml | 4 ++++ .../shared/policies/AssignMessage.Messages.Create.Request.xml | 4 ++++ .../policies/AssignMessage.Messages.GetSingle.Request.xml | 4 ++++ .../policies/AssignMessage.NhsAppAccounts.Get.Request.xml | 4 ++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index c9c0bfdd3..6afe7c0e8 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,9 +18,7 @@ true - - - + https://comms-apim.de-iaho3.communications.national.nhs.uk {requestpath} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index 3dfbc673b..1337783ed 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,6 +20,10 @@ requestpath /api/v1/send + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send + %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index 2a8e9cd5c..a4b66b42d 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,6 +20,10 @@ requestpath /api/v1/messages + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages + %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index ce54ec959..dee5d52ef 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,6 +20,10 @@ requestpath + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} +
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 6d71f721a..4452a9b62 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,6 +20,10 @@ requestpath /api/channels/nhsapp/accounts + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts +
{backendCorrelationId}
From 12f65970456e459f680b1dcfac7fedfb2f623145 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 20 May 2025 13:01:07 +0100 Subject: [PATCH 02/16] CCM-10077: repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 10 ++++++++-- ...ssignMessage.MessageBatches.Create.Request.xml | 15 +++++++++++---- .../AssignMessage.Messages.Create.Request.xml | 15 +++++++++++---- .../AssignMessage.Messages.GetSingle.Request.xml | 15 +++++++++++---- .../AssignMessage.NhsAppAccounts.Get.Request.xml | 15 +++++++++++---- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index 6afe7c0e8..3e7779475 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,8 +18,14 @@ true - https://comms-apim.de-iaho3.communications.national.nhs.uk - {requestpath} + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + + + {requestpath} + {% else %} + https://comms-apim.de-iaho3.communications.national.nhs.uk + {% endif %} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index 1337783ed..e0de72fe2 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,10 +20,17 @@ requestpath /api/v1/send - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send - + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/v1/send + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send + + {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index a4b66b42d..e0ca45279 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,10 +20,17 @@ requestpath /api/v1/messages - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages - + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/v1/messages + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages + + {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index dee5d52ef..c0ba2e7a1 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,10 +20,17 @@ requestpath - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} - + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} + + {% endif %}
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 4452a9b62..2ee021b0e 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,10 +20,17 @@ requestpath /api/channels/nhsapp/accounts - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts - + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/channels/nhsapp/accounts + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts + + {% endif %}
{backendCorrelationId}
From 5cfb9a0d3d12b0f9e8b68c9bfe9b7633b4f197c3 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 20 May 2025 13:53:02 +0100 Subject: [PATCH 03/16] CCM-10077: update sandbox and unit tests --- sandbox/__test__/batch_send.spec.js | 230 +++-------------- sandbox/__test__/messages.spec.js | 240 +++--------------- .../override_contact_details.js | 166 ++++-------- 3 files changed, 122 insertions(+), 514 deletions(-) diff --git a/sandbox/__test__/batch_send.spec.js b/sandbox/__test__/batch_send.spec.js index d5a1c2941..4b9ca1c49 100644 --- a/sandbox/__test__/batch_send.spec.js +++ b/sandbox/__test__/batch_send.spec.js @@ -996,7 +996,7 @@ describe("/api/v1/send", () => { recipient: { nhsNumber: "1", contactDetails: { - sms: "11111111111", + sms: 1234, }, }, }, @@ -1006,12 +1006,12 @@ describe("/api/v1/send", () => { }) .expect(400, { message: - "Invalid recipient contact details. Field 'sms': Input failed format check", + "Invalid recipient contact details. Field 'sms': 'sms' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/sms", - message: "Input failed format check", + message: "'sms' is not a string", title: "Invalid value", statusCode: 400, }, @@ -1020,7 +1020,7 @@ describe("/api/v1/send", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when invalid value for sms alternate contact detail is provided", (done) => { + it("returns a 200 when email alternate contact detail is provided", (done) => { request(server) .post("/api/v1/send") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1036,48 +1036,7 @@ describe("/api/v1/send", () => { recipient: { nhsNumber: "1", contactDetails: { - sms: { - hello: 1, - }, - }, - }, - }, - ], - }, - }, - }) - .expect(400, { - message: "Invalid recipient contact details. Field 'sms': Input is not a string", - errors: [ - { - code: 'CM_INVALID_VALUE', - field: "/data/attributes/messages/0/recipient/contactDetails/sms", - message: "Input is not a string", - title: "Invalid value", - statusCode: 400, - }, - ], - }) - .expect("Content-Type", /json/, done); - }); - - it("returns a 200 when sms alternate contact detail is provided", (done) => { - request(server) - .post("/api/v1/send") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "MessageBatch", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageBatchReference: "request-id", - messages: [ - { - messageReference: "1", - recipient: { - nhsNumber: "1", - contactDetails: { - email: "hello", + email: "test@test.com", }, }, }, @@ -1105,7 +1064,7 @@ describe("/api/v1/send", () => { recipient: { nhsNumber: "1", contactDetails: { - email: "invalidEmailAddress", + email: 1234, }, }, }, @@ -1115,53 +1074,12 @@ describe("/api/v1/send", () => { }) .expect(400, { message: - "Invalid recipient contact details. Field 'email': Input failed format check", + "Invalid recipient contact details. Field 'email': 'email' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/email", - message: "Input failed format check", - title: "Invalid value", - statusCode: 400, - }, - ], - }) - .expect("Content-Type", /json/, done); - }); - - it("returns a 400 when invalid value for email alternate contact detail is provided", (done) => { - request(server) - .post("/api/v1/send") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "MessageBatch", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageBatchReference: "request-id", - messages: [ - { - messageReference: "1", - recipient: { - nhsNumber: "1", - contactDetails: { - email: { - hello: 1, - }, - }, - }, - }, - ], - }, - }, - }) - .expect(400, { - message: "Invalid recipient contact details. Field 'email': Input is not a string", - errors: [ - { - code: 'CM_INVALID_VALUE', - field: "/data/attributes/messages/0/recipient/contactDetails/email", - message: "Input is not a string", + message: "'email' is not a string", title: "Invalid value", statusCode: 400, }, @@ -1308,13 +1226,13 @@ describe("/api/v1/send", () => { }) .expect(400, { message: - "Invalid recipient contact details. Field 'address': 'lines' is missing", + "Invalid recipient contact details. Field 'address': 'lines' is not a string array", errors: [ { - code: 'CM_MISSING_VALUE', + code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/address", - message: "`lines` is missing", - title: "Missing value", + message: "'lines' is not a string array", + title: "Invalid value", statusCode: 400, }, ], @@ -1322,7 +1240,7 @@ describe("/api/v1/send", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when too few lines is provided in address alternate contact detail is provided", (done) => { + it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/send") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1339,7 +1257,7 @@ describe("/api/v1/send", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1"], + lines: ["1", "2", "3", "4", "5", "6"], postcode: "hello", }, }, @@ -1350,22 +1268,21 @@ describe("/api/v1/send", () => { }, }) .expect(400, { - message: - "Invalid recipient contact details. Field 'address': Too few address lines were provided", + message: "Invalid recipient contact details. Field 'address': Too many address lines were provided", errors: [ { - code: 'CM_TOO_FEW_ITEMS', + code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/address", - message: "Too few address lines were provided", - title: "Too few items", + message: "Too many address lines were provided", + title: "Invalid value", statusCode: 400, - } - ] + }, + ], }) .expect("Content-Type", /json/, done); }); - it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => { + it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/send") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1382,7 +1299,7 @@ describe("/api/v1/send", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1", "2", "3", "4", "5", "6"], + lines: ["1", "2", 3, "4", "5"], postcode: "hello", }, }, @@ -1393,12 +1310,12 @@ describe("/api/v1/send", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'address': Too many address lines were provided", + message: "Invalid recipient contact details. Field 'address': 'lines' is not a string array", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/address", - message: "Too many address lines were provided", + message: "'lines' is not a string array", title: "Invalid value", statusCode: 400, }, @@ -1407,7 +1324,7 @@ describe("/api/v1/send", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => { + it("returns a 200 when no postcode is provided in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/send") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1424,8 +1341,7 @@ describe("/api/v1/send", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1", "2", 3, "4", "5"], - postcode: "hello", + lines: ["1", "2"], }, }, }, @@ -1434,22 +1350,11 @@ describe("/api/v1/send", () => { }, }, }) - .expect(400, { - message: "Invalid recipient contact details. Field 'address': Lines contain non-string or empty line", - errors: [ - { - code: 'CM_INVALID_VALUE', - field: "/data/attributes/messages/0/recipient/contactDetails/address", - message: "Lines contain non-string or empty line", - title: "Invalid value", - statusCode: 400, - }, - ], - }) + .expect(200) .expect("Content-Type", /json/, done); }); - it("returns a 400 when no postcode is provided in address alternate contact detail is provided", (done) => { + it("returns a 200 when no lines is provided in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/send") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1466,7 +1371,7 @@ describe("/api/v1/send", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1", "2"], + postcode: "hello", }, }, }, @@ -1475,19 +1380,7 @@ describe("/api/v1/send", () => { }, }, }) - .expect(400, { - message: - "Invalid recipient contact details. Field 'address': 'postcode' is missing", - errors: [ - { - code: 'CM_MISSING_VALUE', - field: "/data/attributes/messages/0/recipient/contactDetails/address", - message: "`postcode` is missing", - title: "Missing value", - statusCode: 400, - }, - ], - }) + .expect(200) .expect("Content-Type", /json/, done); }); @@ -1780,51 +1673,6 @@ describe("/api/v1/send", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when no lastName is provided in name alternate contact detail is provided", (done) => { - request(server) - .post("/api/v1/send") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "MessageBatch", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageBatchReference: "request-id", - messages: [ - { - messageReference: "1", - recipient: { - nhsNumber: "1", - contactDetails: { - name: { - prefix: "Mr", - firstName: "John", - middleNames: "Little", - suffix: "Jr" - }, - }, - }, - }, - ], - }, - }, - }) - .expect(400, { - message: - "Invalid recipient contact details. Field 'name': 'lastName' is missing", - errors: [ - { - code: 'CM_MISSING_VALUE', - field: "/data/attributes/messages/0/recipient/contactDetails/name", - message: "`lastName` is missing", - title: "Missing value", - statusCode: 400, - }, - ], - }) - .expect("Content-Type", /json/, done); - }); - it("returns a 400 when lastName contains non-string value in name alternate contact detail is provided", (done) => { request(server) .post("/api/v1/send") @@ -1856,12 +1704,12 @@ describe("/api/v1/send", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'name': 'lastName' must be a non-empty string", + message: "Invalid recipient contact details. Field 'name': 'lastName' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/name", - message: "'lastName' must be a non-empty string", + message: "'lastName' is not a string", title: "Invalid value", statusCode: 400, }, @@ -1932,10 +1780,10 @@ describe("/api/v1/send", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1"], + lines: ["1", "2", "3", "4", "5", "6"], postcode: [], }, - email: "invalidEmailAddress", + email: 1234, }, }, }, @@ -1945,20 +1793,20 @@ describe("/api/v1/send", () => { }) .expect(400, { message: - "Invalid recipient contact details. Field 'email': Input failed format check. Field 'address': Too few address lines were provided", + "Invalid recipient contact details. Field 'email': 'email' is not a string. Field 'address': Too many address lines were provided", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/email", - message: "Input failed format check", + message: "'email' is not a string", title: "Invalid value", statusCode: 400, }, { - code: 'CM_TOO_FEW_ITEMS', + code: 'CM_INVALID_VALUE', field: "/data/attributes/messages/0/recipient/contactDetails/address", - message: "Too few address lines were provided", - title: "Too few items", + message: "Too many address lines were provided", + title: "Invalid value", statusCode: 400, }, ], diff --git a/sandbox/__test__/messages.spec.js b/sandbox/__test__/messages.spec.js index d47d18d0e..ac943f583 100644 --- a/sandbox/__test__/messages.spec.js +++ b/sandbox/__test__/messages.spec.js @@ -681,42 +681,6 @@ describe("/api/v1/messages", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when invalid sms alternate contact detail is provided", (done) => { - request(server) - .post("/api/v1/messages") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "Message", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243", - recipient: { - nhsNumber: "1", - contactDetails: { - sms: "11111111111", - }, - }, - personalisation: {}, - }, - }, - }) - .expect(400, { - message: - "Invalid recipient contact details. Field 'sms': Input failed format check", - errors: [ - { - code: 'CM_INVALID_VALUE', - field: "/data/attributes/recipient/contactDetails/sms", - message: "Input failed format check", - title: "Invalid value", - statusCode: 400, - }, - ], - }) - .expect("Content-Type", /json/, done); - }); - it("returns a 400 when invalid value for sms alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") @@ -740,12 +704,12 @@ describe("/api/v1/messages", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'sms': Input is not a string", + message: "Invalid recipient contact details. Field 'sms': 'sms' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/sms", - message: "Input is not a string", + message: "'sms' is not a string", title: "Invalid value", statusCode: 400, }, @@ -778,42 +742,6 @@ describe("/api/v1/messages", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when invalid email alternate contact detail is provided", (done) => { - request(server) - .post("/api/v1/messages") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "Message", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243", - recipient: { - nhsNumber: "1", - contactDetails: { - email: "invalidEmailAddress", - }, - }, - personalisation: {}, - }, - }, - }) - .expect(400, { - message: - "Invalid recipient contact details. Field 'email': Input failed format check", - errors: [ - { - code: 'CM_INVALID_VALUE', - field: "/data/attributes/recipient/contactDetails/email", - message: "Input failed format check", - title: "Invalid value", - statusCode: 400, - }, - ], - }) - .expect("Content-Type", /json/, done); - }); - it("returns a 400 when invalid value for email alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") @@ -837,12 +765,12 @@ describe("/api/v1/messages", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'email': Input is not a string", + message: "Invalid recipient contact details. Field 'email': 'email' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/email", - message: "Input is not a string", + message: "'email' is not a string", title: "Invalid value", statusCode: 400, }, @@ -973,13 +901,13 @@ describe("/api/v1/messages", () => { }) .expect(400, { message: - "Invalid recipient contact details. Field 'address': 'lines' is missing", + "Invalid recipient contact details. Field 'address': 'lines' is not a string array", errors: [ { - code: 'CM_MISSING_VALUE', + code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/address", - message: "`lines` is missing", - title: "Missing value", + message: "'lines' is not a string array", + title: "Invalid value", statusCode: 400, }, ], @@ -987,7 +915,7 @@ describe("/api/v1/messages", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when too few lines is provided in address alternate contact detail is provided", (done) => { + it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1001,7 +929,7 @@ describe("/api/v1/messages", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1"], + lines: ["1", "2", "3", "4", "5", "6"], postcode: "hello", }, }, @@ -1011,22 +939,21 @@ describe("/api/v1/messages", () => { }, }) .expect(400, { - message: - "Invalid recipient contact details. Field 'address': Too few address lines were provided", + message: "Invalid recipient contact details. Field 'address': Too many address lines were provided", errors: [ { - code: 'CM_TOO_FEW_ITEMS', + code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/address", - message: "Too few address lines were provided", - title: "Too few items", + message: "Too many address lines were provided", + title: "Invalid value", statusCode: 400, - } - ] + }, + ], }) .expect("Content-Type", /json/, done); }); - it("returns a 400 when too many lines is provided in address alternate contact detail is provided", (done) => { + it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1040,7 +967,7 @@ describe("/api/v1/messages", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1", "2", "3", "4", "5", "6"], + lines: ["1", "2", 3, "4", "5"], postcode: "hello", }, }, @@ -1050,12 +977,12 @@ describe("/api/v1/messages", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'address': Too many address lines were provided", + message: "Invalid recipient contact details. Field 'address': 'lines' is not a string array", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/address", - message: "Too many address lines were provided", + message: "'lines' is not a string array", title: "Invalid value", statusCode: 400, }, @@ -1064,7 +991,7 @@ describe("/api/v1/messages", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when lines contains non-string value in address alternate contact detail is provided", (done) => { + it("returns a 201 when no postcode is provided in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1078,8 +1005,7 @@ describe("/api/v1/messages", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1", "2", 3, "4", "5"], - postcode: "hello", + lines: ["1", "2"], }, }, }, @@ -1087,22 +1013,11 @@ describe("/api/v1/messages", () => { }, }, }) - .expect(400, { - message: "Invalid recipient contact details. Field 'address': Lines contain non-string or empty line", - errors: [ - { - code: 'CM_INVALID_VALUE', - field: "/data/attributes/recipient/contactDetails/address", - message: "Lines contain non-string or empty line", - title: "Invalid value", - statusCode: 400, - }, - ], - }) + .expect(201) .expect("Content-Type", /json/, done); }); - it("returns a 400 when no postcode is provided in address alternate contact detail is provided", (done) => { + it("returns a 201 when no lines is provided in address alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") .set({ Authorization: "allowedContactDetailOverride" }) @@ -1116,7 +1031,7 @@ describe("/api/v1/messages", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1", "2"], + postcode: "hello", }, }, }, @@ -1124,19 +1039,7 @@ describe("/api/v1/messages", () => { }, }, }) - .expect(400, { - message: - "Invalid recipient contact details. Field 'address': 'postcode' is missing", - errors: [ - { - code: 'CM_MISSING_VALUE', - field: "/data/attributes/recipient/contactDetails/address", - message: "`postcode` is missing", - title: "Missing value", - statusCode: 400, - }, - ], - }) + .expect(201) .expect("Content-Type", /json/, done); }); @@ -1208,32 +1111,6 @@ describe("/api/v1/messages", () => { .expect("Content-Type", /json/, done); }); - it("returns a 201 when only lastName is provided for name alternate contact details", (done) => { - request(server) - .post("/api/v1/messages") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "Message", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243", - recipient: { - nhsNumber: "1", - contactDetails: { - name: { - lastName: "Smith" - }, - }, - }, - personalisation: {}, - }, - }, - }) - .expect(201) - .expect("Content-Type", /json/, done); - }); - it("returns a 400 when string for name alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") @@ -1427,47 +1304,6 @@ describe("/api/v1/messages", () => { .expect("Content-Type", /json/, done); }); - it("returns a 400 when no lastName is provided in name alternate contact detail is provided", (done) => { - request(server) - .post("/api/v1/messages") - .set({ Authorization: "allowedContactDetailOverride" }) - .send({ - data: { - type: "Message", - attributes: { - routingPlanId: "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - messageReference: "b5bb84b9-a522-41e9-aa8b-ad1b6a454243", - recipient: { - nhsNumber: "1", - contactDetails: { - name: { - prefix: "Mr", - firstName: "John", - middleNames: "Little", - suffix: "Jr" - }, - }, - }, - personalisation: {}, - }, - }, - }) - .expect(400, { - message: - "Invalid recipient contact details. Field 'name': 'lastName' is missing", - errors: [ - { - code: 'CM_MISSING_VALUE', - field: "/data/attributes/recipient/contactDetails/name", - message: "`lastName` is missing", - title: "Missing value", - statusCode: 400, - }, - ], - }) - .expect("Content-Type", /json/, done); - }); - it("returns a 400 when lastName contains non-string value in name alternate contact detail is provided", (done) => { request(server) .post("/api/v1/messages") @@ -1495,12 +1331,12 @@ describe("/api/v1/messages", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'name': 'lastName' must be a non-empty string", + message: "Invalid recipient contact details. Field 'name': 'lastName' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/name", - message: "'lastName' must be a non-empty string", + message: "'lastName' is not a string", title: "Invalid value", statusCode: 400, }, @@ -1526,7 +1362,7 @@ describe("/api/v1/messages", () => { prefix: "Mr", firstName: "John", middleNames: "Little", - lastName: "", + lastName: 1234, suffix: "Jr" }, }, @@ -1536,12 +1372,12 @@ describe("/api/v1/messages", () => { }, }) .expect(400, { - message: "Invalid recipient contact details. Field 'name': 'lastName' must be a non-empty string", + message: "Invalid recipient contact details. Field 'name': 'lastName' is not a string", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/name", - message: "'lastName' must be a non-empty string", + message: "'lastName' is not a string", title: "Invalid value", statusCode: 400, }, @@ -1605,10 +1441,10 @@ describe("/api/v1/messages", () => { nhsNumber: "1", contactDetails: { address: { - lines: ["1"], + lines: ["1", "2", "3", "4", "5", "6"], postcode: [], }, - email: "invalidEmailAddress", + email: 1234, }, }, personalisation: {}, @@ -1617,20 +1453,20 @@ describe("/api/v1/messages", () => { }) .expect(400, { message: - "Invalid recipient contact details. Field 'email': Input failed format check. Field 'address': Too few address lines were provided", + "Invalid recipient contact details. Field 'email': 'email' is not a string. Field 'address': Too many address lines were provided", errors: [ { code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/email", - message: "Input failed format check", + message: "'email' is not a string", title: "Invalid value", statusCode: 400, }, { - code: 'CM_TOO_FEW_ITEMS', + code: 'CM_INVALID_VALUE', field: "/data/attributes/recipient/contactDetails/address", - message: "Too few address lines were provided", - title: "Too few items", + message: "Too many address lines were provided", + title: "Invalid value", statusCode: 400, }, ], diff --git a/sandbox/handlers/error_scenarios/override_contact_details.js b/sandbox/handlers/error_scenarios/override_contact_details.js index b9189dc5c..c9cd9f5f5 100644 --- a/sandbox/handlers/error_scenarios/override_contact_details.js +++ b/sandbox/handlers/error_scenarios/override_contact_details.js @@ -1,8 +1,5 @@ import { notAllowedContactDetailOverride } from "../config.js"; -const invalidPhoneNumber = "11111111111"; -const invalidEmailAddress = "invalidEmailAddress"; - function validationSuccess() { return { valid: true, @@ -20,28 +17,16 @@ function smsValidation(sms, path) { if (!sms) { return validationSuccess(); } - if (sms === invalidPhoneNumber) { - return validationFailure([ - { - title: "Invalid value", - code: 'CM_INVALID_VALUE', - field: `${path}/recipient/contactDetails/sms`, - message: "Input failed format check", - statusCode: 400, - }, - `Field 'sms': Input failed format check`, - ]); - } if (typeof sms !== "string") { return validationFailure([ { title: "Invalid value", code: 'CM_INVALID_VALUE', field: `${path}/recipient/contactDetails/sms`, - message: "Input is not a string", + message: "'sms' is not a string", statusCode: 400, }, - `Field 'sms': Input is not a string`, + `Field 'sms': 'sms' is not a string`, ]); } return validationSuccess(); @@ -51,28 +36,16 @@ function emailValidation(email, path) { if (!email) { return validationSuccess(); } - if (email === invalidEmailAddress) { - return validationFailure([ - { - title: "Invalid value", - code: 'CM_INVALID_VALUE', - field: `${path}/recipient/contactDetails/email`, - message: "Input failed format check", - statusCode: 400, - }, - `Field 'email': Input failed format check`, - ]); - } if (typeof email !== "string") { return validationFailure([ { title: "Invalid value", code: 'CM_INVALID_VALUE', field: `${path}/recipient/contactDetails/email`, - message: "Input is not a string", + message: "'email' is not a string", statusCode: 400, }, - `Field 'email': Input is not a string`, + `Field 'email': 'email' is not a string`, ]); } return validationSuccess(); @@ -96,83 +69,48 @@ function addressValidation(address, path) { ]); } - if (!address.lines) { - return validationFailure([ - { - title: "Missing value", - code: 'CM_MISSING_VALUE', - field: `${path}/recipient/contactDetails/address`, - message: "`lines` is missing", - statusCode: 400, - }, - `Field 'address': 'lines' is missing`, - ]); - } - if (!Array.isArray(address.lines)) { - return validationFailure([ - { - title: "Missing value", - code: 'CM_MISSING_VALUE', - field: `${path}/recipient/contactDetails/address`, - message: "`lines` is missing", - statusCode: 400, - }, - `Field 'address': 'lines' is missing`, - ]); - } - - if (address.lines.some((line) => typeof line !== "string")) { - return validationFailure([ - { - title: "Invalid value", - code: 'CM_INVALID_VALUE', - field: `${path}/recipient/contactDetails/address`, - message: "Lines contain non-string or empty line", - statusCode: 400, - }, - `Field 'address': Lines contain non-string or empty line`, - ]); - } + if ("lines" in address) { + if (!Array.isArray(address.lines)) { + return validationFailure([ + { + title: "Invalid value", + code: 'CM_INVALID_VALUE', + field: `${path}/recipient/contactDetails/address`, + message: "'lines' is not a string array", + statusCode: 400, + }, + `Field 'address': 'lines' is not a string array`, + ]); + } - if (address.lines.length < 2) { - return validationFailure([ - { - code: 'CM_TOO_FEW_ITEMS', - title: "Too few items", - field: `${path}/recipient/contactDetails/address`, - message: "Too few address lines were provided", - statusCode: 400, - }, - `Field 'address': Too few address lines were provided`, - ]); - } - if (address.lines.length > 5) { - return validationFailure([ - { - title: "Invalid value", - code: 'CM_INVALID_VALUE', - field: `${path}/recipient/contactDetails/address`, - message: "Too many address lines were provided", - statusCode: 400, - }, - `Field 'address': Too many address lines were provided`, - ]); - } + if (address.lines.some((line) => typeof line !== "string")) { + return validationFailure([ + { + title: "Invalid value", + code: 'CM_INVALID_VALUE', + field: `${path}/recipient/contactDetails/address`, + message: "'lines' is not a string array", + statusCode: 400, + }, + `Field 'address': 'lines' is not a string array`, + ]); + } - if (!address.postcode) { - return validationFailure([ - { - title: "Missing value", - code: 'CM_MISSING_VALUE', - field: `${path}/recipient/contactDetails/address`, - message: "`postcode` is missing", - statusCode: 400, - }, - `Field 'address': 'postcode' is missing`, - ]); + if (address.lines.length > 5) { + return validationFailure([ + { + title: "Invalid value", + code: 'CM_INVALID_VALUE', + field: `${path}/recipient/contactDetails/address`, + message: "Too many address lines were provided", + statusCode: 400, + }, + `Field 'address': Too many address lines were provided`, + ]); + } } - if (typeof address.postcode !== "string") { + if ("postcode" in address && typeof address.postcode !== "string") { return validationFailure([ { title: "Invalid value", @@ -188,7 +126,6 @@ function addressValidation(address, path) { } function nameValidation(name, path) { - if (!name) { return validationSuccess(); } @@ -245,29 +182,16 @@ function nameValidation(name, path) { ]); } - if (typeof name.lastName === "undefined") { - return validationFailure([ - { - title: "Missing value", - code: 'CM_MISSING_VALUE', - field: `${path}/recipient/contactDetails/name`, - message: "`lastName` is missing", - statusCode: 400, - }, - `Field 'name': 'lastName' is missing`, - ]); - } - - if (typeof name.lastName !== "string" || name.lastName.trim() === "") { + if ("lastName" in name && typeof name.lastName !== "string") { return validationFailure([ { title: "Invalid value", code: 'CM_INVALID_VALUE', field: `${path}/recipient/contactDetails/name`, - message: "'lastName' must be a non-empty string", + message: "'lastName' is not a string", statusCode: 400, }, - `Field 'name': 'lastName' must be a non-empty string`, + `Field 'name': 'lastName' is not a string`, ]); } From fe85ade52d009d72cc6b42df0c1a1a0525c42455 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 20 May 2025 14:44:36 +0100 Subject: [PATCH 04/16] CCM-10077: update e2e tests --- .../post_v1_message-batches/validation.md | 40 --------- .../post_v1_single-message/validation.md | 40 --------- .../post_v1_message-batches/validation.md | 20 ----- .../sandbox/post_v1_messages/validation.md | 20 ----- .../test_400_invalid_contact_details.py | 84 ++----------------- .../test_400_invalid_contact_details.py | 76 +---------------- .../test_field_validation.py | 54 +----------- .../create_messages/test_field_validation.py | 49 +---------- 8 files changed, 20 insertions(+), 363 deletions(-) diff --git a/docs/tests/post_v1_message-batches/validation.md b/docs/tests/post_v1_message-batches/validation.md index a639aaa5d..5fb269de8 100644 --- a/docs/tests/post_v1_message-batches/validation.md +++ b/docs/tests/post_v1_message-batches/validation.md @@ -33,46 +33,6 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/messages/0/recipient/nhsNumber | -## Scenario: An API consumer submitting a request with an invalid address postcode receives a 400 ‘Invalid Value’ response - -A valid contact detail must be structured in this format: { sms: value, email: value, address: { lines: [], postcode: value } } - -**Given** the API consumer provides an message body with an invalid postcode -
-**When** the request is submitted -
-**Then** the response returns a 400 invalid value error -
- -**Asserts** -- Response returns a 400 ‘Invalid Value’ error -- Response returns the expected error message body with references to the invalid attribute - -| Value | Description | -|-----------|------------------------------------------------| -| LS1 6AECD | Used to ensure only valid postcode is accepted | - - -## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response - -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } - -**Given** the API consumer provides an message body with with too few address lines -
-**When** the request is submitted -
-**Then** the response returns a 400 too few items error -
- -**Asserts** -- Response returns a 400 ‘Too few items’ error -- Response returns the expected error message body with references to the invalid attribute - -| Value | Description | -|---------|-----------------------------------------------------------| -| [ “1” ] | Used to ensure list of less than 2 values is not accepted | - - ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } diff --git a/docs/tests/post_v1_single-message/validation.md b/docs/tests/post_v1_single-message/validation.md index f60681457..0bab10d87 100644 --- a/docs/tests/post_v1_single-message/validation.md +++ b/docs/tests/post_v1_single-message/validation.md @@ -1,46 +1,6 @@ # Validation Tests -## Scenario: An API consumer submitting a request with an invalid address postcode receives a 400 ‘Invalid Value’ response - -A valid contact detail must be structured in this format: { sms: value, email: value, address: { lines: [], postcode: value } } - -**Given** the API consumer provides an message body with an invalid postcode -
-**When** the request is submitted -
-**Then** the response returns a 400 invalid value error -
- -**Asserts** -- Response returns a 400 ‘Invalid Value’ error -- Response returns the expected error message body with references to the invalid attribute - -| Value | Description | -|-----------|------------------------------------------------| -| LS1 6AECD | Used to ensure only valid postcode is accepted | - - -## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response - -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } - -**Given** the API consumer provides an message body with with too few address lines -
-**When** the request is submitted -
-**Then** the response returns a 400 too few items error -
- -**Asserts** -- Response returns a 400 ‘Too few items’ error -- Response returns the expected error message body with references to the invalid attribute - -| Value | Description | -|---------|-----------------------------------------------------------| -| [ “1” ] | Used to ensure list of less than 2 values is not accepted | - - ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } diff --git a/docs/tests/sandbox/post_v1_message-batches/validation.md b/docs/tests/sandbox/post_v1_message-batches/validation.md index 8dc7d17b9..f70a1a684 100644 --- a/docs/tests/sandbox/post_v1_message-batches/validation.md +++ b/docs/tests/sandbox/post_v1_message-batches/validation.md @@ -129,26 +129,6 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/messages/0/recipient/nhsNumber | -## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response - -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } - -**Given** the API consumer provides an message body with with too few address lines -
-**When** the request is submitted -
-**Then** the response returns a 400 too few items error -
- -**Asserts** -- Response returns a 400 ‘Too few items’ error -- Response returns the expected error message body with references to the invalid attribute - -| Value | Description | -|---------|-----------------------------------------------------------| -| [ “1” ] | Used to ensure list of less than 2 values is not accepted | - - ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } diff --git a/docs/tests/sandbox/post_v1_messages/validation.md b/docs/tests/sandbox/post_v1_messages/validation.md index 475d93a1f..39202906e 100644 --- a/docs/tests/sandbox/post_v1_messages/validation.md +++ b/docs/tests/sandbox/post_v1_messages/validation.md @@ -62,26 +62,6 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/recipient/nhsNumber | -## Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 ‘Too few items’ response - -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } - -**Given** the API consumer provides an message body with with too few address lines -
-**When** the request is submitted -
-**Then** the response returns a 400 too few items error -
- -**Asserts** -- Response returns a 400 ‘Too few items’ error -- Response returns the expected error message body with references to the invalid attribute - -| Value | Description | -|---------|-----------------------------------------------------------| -| [ “1” ] | Used to ensure list of less than 2 values is not accepted | - - ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } diff --git a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py index d7d1e2811..9f3fc9884 100644 --- a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py @@ -18,7 +18,7 @@ def test_invalid_sms_contact_details(url, bearer_token): data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][0]["recipient"] = { "contactDetails": { - "sms": "077009000021" + "sms": 1234 } } @@ -33,7 +33,7 @@ def test_invalid_sms_contact_details(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/0/recipient/contactDetails/sms", - "Input failed format check" + "'sms' is not a string" ), None ) @@ -51,7 +51,7 @@ def test_invalid_sms_contact_details_second_message(url, bearer_token): data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][1]["recipient"] = { "contactDetails": { - "sms": "077009000021" + "sms": 1234 } } @@ -66,7 +66,7 @@ def test_invalid_sms_contact_details_second_message(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/1/recipient/contactDetails/sms", - "Input failed format check" + "'sms' is not a string" ), None ) @@ -84,7 +84,7 @@ def test_invalid_email_contact_details(url, bearer_token): data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][0]["recipient"] = { "contactDetails": { - "email": "invalidEmailAddress" + "email": 1234 } } @@ -99,7 +99,7 @@ def test_invalid_email_contact_details(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/0/recipient/contactDetails/email", - "Input failed format check" + "'email' is not a string" ), None ) @@ -117,7 +117,7 @@ def test_invalid_email_contact_details_third_message(url, bearer_token): data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][2]["recipient"] = { "contactDetails": { - "email": "invalidEmailAddress" + "email": 1234 } } @@ -131,41 +131,7 @@ def test_invalid_email_contact_details_third_message(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/2/recipient/contactDetails/email", - "Input failed format check" - ), - None - ) - - -@pytest.mark.test -@pytest.mark.devtest -@pytest.mark.inttest -@pytest.mark.prodtest -def test_invalid_address_contact_details_too_few_lines(url, bearer_token): - """ - .. include:: ../partials/validation/test_invalid_contact_details_address_lines_too_few.rst - """ - headers = Generators.generate_valid_headers(bearer_token.value) - data = Generators.generate_valid_create_message_batch_body("dev") - data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = { - "address": { - "lines": ["1"], - "postcode": "LS1 6AE" - } - } - - resp = requests.post( - f"{url}{MESSAGE_BATCHES_ENDPOINT}", - headers=headers, - json=data - ) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 400, - Generators.generate_too_few_items_error_custom_detail( - "/data/attributes/messages/0/recipient/contactDetails/address", - "Too few address lines were provided" + "'email' is not a string" ), None ) @@ -205,40 +171,6 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token): ) -@pytest.mark.test -@pytest.mark.devtest -@pytest.mark.inttest -@pytest.mark.prodtest -def test_invalid_address_contact_details_postcode(url, bearer_token): - """ - .. include:: ../partials/validation/test_invalid_contact_details_address_postcode.rst - """ - headers = Generators.generate_valid_headers(bearer_token.value) - data = Generators.generate_valid_create_message_batch_body("dev") - data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = { - "address": { - "lines": ["1", "2", "3", "4", "5"], - "postcode": "LS1 6AECD" - } - } - - resp = requests.post( - f"{url}{MESSAGE_BATCHES_ENDPOINT}", - headers=headers, - json=data - ) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 400, - Generators.generate_invalid_value_error_custom_detail( - "/data/attributes/messages/0/recipient/contactDetails/address", - "Postcode input failed format check" - ), - None - ) - - @pytest.mark.devtest def test_not_permitted_to_use_contact_details(url, bearer_token_internal_dev_test_1): """ diff --git a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py index a9214d0e9..5f7b82fd2 100644 --- a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py @@ -16,7 +16,7 @@ def test_invalid_sms_contact_details(url, bearer_token): """ headers = Generators.generate_valid_headers(bearer_token.value) data = Generators.generate_valid_create_message_body("dev") - data["data"]["attributes"]["recipient"]["contactDetails"] = {"sms": "11111111111"} + data["data"]["attributes"]["recipient"]["contactDetails"] = {"sms": 1234} resp = requests.post( f"{url}{MESSAGES_ENDPOINT}", @@ -29,7 +29,7 @@ def test_invalid_sms_contact_details(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/recipient/contactDetails/sms", - "Input failed format check" + "'sms' is not a string" ), None ) @@ -45,7 +45,7 @@ def test_invalid_email_contact_details(url, bearer_token): """ headers = Generators.generate_valid_headers(bearer_token.value) data = Generators.generate_valid_create_message_body("dev") - data["data"]["attributes"]["recipient"]["contactDetails"] = {"email": "invalidEmailAddress"} + data["data"]["attributes"]["recipient"]["contactDetails"] = {"email": 1234} resp = requests.post( f"{url}{MESSAGES_ENDPOINT}", @@ -58,41 +58,7 @@ def test_invalid_email_contact_details(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/recipient/contactDetails/email", - "Input failed format check" - ), - None - ) - - -@pytest.mark.test -@pytest.mark.devtest -@pytest.mark.inttest -@pytest.mark.prodtest -def test_invalid_address_contact_details_too_few_lines(url, bearer_token): - """ - .. include :: /partials/validation/test_invalid_contact_details_address_lines_too_few.rst - """ - headers = Generators.generate_valid_headers(bearer_token.value) - data = Generators.generate_valid_create_message_body("dev") - data["data"]["attributes"]["recipient"]["contactDetails"] = { - "address": { - "lines": ["1"], - "postcode": "test" - } - } - - resp = requests.post( - f"{url}{MESSAGES_ENDPOINT}", - headers=headers, - json=data - ) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 400, - Generators.generate_too_few_items_error_custom_detail( - "/data/attributes/recipient/contactDetails/address", - "Too few address lines were provided" + "'email' is not a string" ), None ) @@ -132,40 +98,6 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token): ) -@pytest.mark.test -@pytest.mark.devtest -@pytest.mark.inttest -@pytest.mark.prodtest -def test_invalid_address_contact_details_postcode(url, bearer_token): - """ - .. include :: /partials/validation/test_invalid_contact_details_address_postcode.rst - """ - headers = Generators.generate_valid_headers(bearer_token.value) - data = Generators.generate_valid_create_message_body("dev") - data["data"]["attributes"]["recipient"]["contactDetails"] = { - "address": { - "lines": ["1", "2", "3", "4", "5"], - "postcode": "LS1 6AECD" - } - } - - resp = requests.post( - f"{url}{MESSAGES_ENDPOINT}", - headers=headers, - json=data - ) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 400, - Generators.generate_invalid_value_error_custom_detail( - "/data/attributes/recipient/contactDetails/address", - "Postcode input failed format check" - ), - None - ) - - @pytest.mark.devtest def test_not_permitted_to_use_contact_details(url, bearer_token_internal_dev_test_1): """ diff --git a/tests/sandbox/message_batches/create_message_batches/test_field_validation.py b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py index a51e1235e..e4f5cee28 100644 --- a/tests/sandbox/message_batches/create_message_batches/test_field_validation.py +++ b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py @@ -554,7 +554,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id): "recipient": { "nhsNumber": "9990548609", "contactDetails": { - "sms": "11111111111" + "sms": 1234 } }, } @@ -568,7 +568,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/0/recipient/contactDetails/sms", - "Input failed format check" + "'sms' is not a string" ), correlation_id ) @@ -595,7 +595,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id): "recipient": { "nhsNumber": "9990548609", "contactDetails": { - "email": "invalidEmailAddress" + "email": 1234 } }, } @@ -609,53 +609,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/0/recipient/contactDetails/email", - "Input failed format check" - ), - correlation_id - ) - - -@pytest.mark.sandboxtest -@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID) -def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, correlation_id): - """ - .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_few.rst - """ - resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - **headers, - "X-Correlation-Id": correlation_id - }, json={ - "data": { - "type": "MessageBatch", - "attributes": { - "routingPlanId": "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - "messageBatchReference": str(uuid.uuid1()), - "messages": [ - { - "messageReference": "72f2fa29-1570-47b7-9a67-63dc4b28fc1b", - "recipient": { - "nhsNumber": "9990548609", - "contactDetails": { - "address": { - "lines": [ - "1" - ], - "postcode": "test" - } - } - }, - } - ] - } - } - }) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 400, - Generators.generate_too_few_items_error_custom_detail( - "/data/attributes/messages/0/recipient/contactDetails/address", - "Too few address lines were provided" + "'email' is not a string" ), correlation_id ) diff --git a/tests/sandbox/messages/create_messages/test_field_validation.py b/tests/sandbox/messages/create_messages/test_field_validation.py index 811fd20e3..b894660d5 100644 --- a/tests/sandbox/messages/create_messages/test_field_validation.py +++ b/tests/sandbox/messages/create_messages/test_field_validation.py @@ -334,7 +334,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id): "recipient": { "nhsNumber": "9990548609", "contactDetails": { - "sms": "11111111111" + "sms": 1234 } }, } @@ -346,7 +346,7 @@ def test_invalid_sms_contact_details(nhsd_apim_proxy_url, correlation_id): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/recipient/contactDetails/sms", - "Input failed format check" + "'sms' is not a string" ), correlation_id ) @@ -370,7 +370,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id): "recipient": { "nhsNumber": "9990548609", "contactDetails": { - "email": "invalidEmailAddress" + "email": 1234 } }, } @@ -382,48 +382,7 @@ def test_invalid_email_contact_details(nhsd_apim_proxy_url, correlation_id): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/recipient/contactDetails/email", - "Input failed format check" - ), - correlation_id - ) - - -@pytest.mark.sandboxtest -@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID) -def test_invalid_address_contact_details_too_few_lines(nhsd_apim_proxy_url, correlation_id): - """ - .. include:: ../../partials/validation/test_invalid_contact_details_address_lines_too_few.rst - """ - resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - **headers, - "X-Correlation-Id": correlation_id - }, json={ - "data": { - "type": "Message", - "attributes": { - "routingPlanId": "b838b13c-f98c-4def-93f0-515d4e4f4ee1", - "messageReference": str(uuid.uuid1()), - "recipient": { - "nhsNumber": "9990548609", - "contactDetails": { - "address": { - "lines": [ - "1" - ], - "postcode": "test" - } - } - }, - } - } - }) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 400, - Generators.generate_too_few_items_error_custom_detail( - "/data/attributes/recipient/contactDetails/address", - "Too few address lines were provided" + "'email' is not a string" ), correlation_id ) From 8608d1074e9871ffbf79d8df1af206aba806992c Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Wed, 21 May 2025 10:15:31 +0100 Subject: [PATCH 05/16] CCM-10077: remove too few address lines test --- ..._contact_details_address_lines_too_few.rst | 22 ------------------- tests/lib/constants/constants.py | 16 -------------- 2 files changed, 38 deletions(-) delete mode 100644 tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst deleted file mode 100644 index 61132ebd1..000000000 --- a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_few.rst +++ /dev/null @@ -1,22 +0,0 @@ -Scenario: An API consumer submitting a request with invalid address lines (too few) receives a 400 'Too few items' response -============================================================================================================================ - -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } - -| **Given** the API consumer provides an message body with with too few address lines -| **When** the request is submitted -| **Then** the response returns a 400 too few items error - -**Asserts** -- Response returns a 400 'Too few items' error -- Response returns the expected error message body with references to the invalid attribute - -.. list-table:: - :widths: 50 50 - :header-rows: 1 - - * - Value - - Description - * - [ "1" ] - - Used to ensure list of less than 2 values is not accepted - diff --git a/tests/lib/constants/constants.py b/tests/lib/constants/constants.py index 021189639..79ffa4f82 100644 --- a/tests/lib/constants/constants.py +++ b/tests/lib/constants/constants.py @@ -109,14 +109,6 @@ def __init__(self, code, status, title, detail, links={}): "The property at the specified location is required, but was not present in the request." ) -# too few address lines -ERROR_TOO_FEW_ADDRESS_LINES = Error( - "CM_MISSING_VALUE", - "400", - "Missing value", - "Too few address lines were provided" -) - # null value constants ERROR_NULL_VALUE = Error( "CM_NULL_VALUE", @@ -135,14 +127,6 @@ def __init__(self, code, status, title, detail, links={}): "are not allowed." ) -# too few items constants -ERROR_TOO_FEW_ITEMS = Error( - "CM_TOO_FEW_ITEMS", - "400", - "Too few items", - "The property at the specified location contains too few items." -) - # access denied ERROR_ACCESS_DENIED = Error( "CM_DENIED", From 1d26214ef4b70bda587b04b5c6cfec3080da2ba6 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Wed, 21 May 2025 12:40:21 +0100 Subject: [PATCH 06/16] CCM-10077: put ERROR_TOO_FEW_ITEMS constant back --- tests/lib/constants/constants.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/lib/constants/constants.py b/tests/lib/constants/constants.py index 79ffa4f82..1ad914d0b 100644 --- a/tests/lib/constants/constants.py +++ b/tests/lib/constants/constants.py @@ -127,6 +127,14 @@ def __init__(self, code, status, title, detail, links={}): "are not allowed." ) +# too few items constants +ERROR_TOO_FEW_ITEMS = Error( + "CM_TOO_FEW_ITEMS", + "400", + "Too few items", + "The property at the specified location contains too few items." +) + # access denied ERROR_ACCESS_DENIED = Error( "CM_DENIED", From a98a5944aba3245ddd5962a1226c2b77538deae0 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Wed, 21 May 2025 13:28:05 +0100 Subject: [PATCH 07/16] CCM-10077: revert repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 12 ++++-------- .../AssignMessage.MessageBatches.Create.Request.xml | 11 ----------- .../AssignMessage.Messages.Create.Request.xml | 11 ----------- .../AssignMessage.Messages.GetSingle.Request.xml | 11 ----------- .../AssignMessage.NhsAppAccounts.Get.Request.xml | 11 ----------- 5 files changed, 4 insertions(+), 52 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index 3e7779475..c9c0bfdd3 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,14 +18,10 @@ true - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - - - {requestpath} - {% else %} - https://comms-apim.de-iaho3.communications.national.nhs.uk - {% endif %} + + + + {requestpath} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index e0de72fe2..3dfbc673b 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,17 +20,6 @@ requestpath /api/v1/send - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/v1/send - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send - - {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index e0ca45279..2a8e9cd5c 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,17 +20,6 @@ requestpath /api/v1/messages - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/v1/messages - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages - - {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index c0ba2e7a1..ce54ec959 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,17 +20,6 @@ requestpath - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} - - {% endif %}
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 2ee021b0e..6d71f721a 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,17 +20,6 @@ requestpath /api/channels/nhsapp/accounts - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/channels/nhsapp/accounts - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts - - {% endif %}
{backendCorrelationId}
From 775b8bccf872fcdd2b6c9dd287a379883e06912d Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 12:56:27 +0100 Subject: [PATCH 08/16] CCM-10077: update and add tests --- .../post_v1_message-batches/validation.md | 88 ++++++++++++++----- .../post_v1_single-message/validation.md | 24 ++--- .../post_v1_message-batches/validation.md | 24 ++--- .../sandbox/post_v1_messages/validation.md | 24 ++--- sandbox/handlers/config.js | 5 +- .../test_400_invalid_contact_details.py | 68 ++++++++++++++ ..._invalid_contact_details_address_lines.rst | 22 +++++ ...valid_contact_details_address_postcode.rst | 12 +-- .../test_invalid_contact_details_email.rst | 10 +-- .../test_invalid_contact_details_sms.rst | 12 +-- 10 files changed, 208 insertions(+), 81 deletions(-) create mode 100644 tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst diff --git a/docs/tests/post_v1_message-batches/validation.md b/docs/tests/post_v1_message-batches/validation.md index 5fb269de8..0f5903368 100644 --- a/docs/tests/post_v1_message-batches/validation.md +++ b/docs/tests/post_v1_message-batches/validation.md @@ -33,6 +33,46 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/messages/0/recipient/nhsNumber | +## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response + +A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array + +**Given** the API consumer provides a message body with a non-string array address lines +
+**When** the request is submitted +
+**Then** the response returns a 400 invalid value error +
+ +**Asserts** +- Response returns a 400 ‘Invalid Value’ error +- Response returns the expected error message body with references to the invalid attribute + +| Value | Description | +|---------|--------------------------------------------------------------| +| [1,2] | Used to ensure only a string array address lines is accepted | + + +## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response + +A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array + +**Given** the API consumer provides a message body with a non-string array address lines +
+**When** the request is submitted +
+**Then** the response returns a 400 invalid value error +
+ +**Asserts** +- Response returns a 400 ‘Invalid Value’ error +- Response returns the expected error message body with references to the invalid attribute + +| Value | Description | +|---------|--------------------------------------------------------------| +| [1,2] | Used to ensure only a string array address lines is accepted | + + ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } @@ -53,11 +93,11 @@ A valid contact detail must be structured in this format: { address: { lines: [ | [ “1”, “2”, “3”, “4”, “5”, “6” ] | Used to ensure list of more than 5 values is not accepted | -## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { email: Value } +A valid email contact detail must be structured in this format: { email: Value } where Value is a string -**Given** the API consumer provides an message body with an invalid email address +**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -68,16 +108,16 @@ A valid contact detail must be structured in this format: { email: Value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|---------------------|------------------------------------------------------| -| invalidEmailAddress | Used to ensure invalid email address is not accepted | +| Value | Description | +|---------|--------------------------------------------------------| +| [] | Used to ensure only a string email address is accepted | -## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { email: Value } +A valid email contact detail must be structured in this format: { email: Value } where Value is a string -**Given** the API consumer provides an message body with an invalid email address +**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -88,16 +128,16 @@ A valid contact detail must be structured in this format: { email: Value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|---------------------|------------------------------------------------------| -| invalidEmailAddress | Used to ensure invalid email address is not accepted | +| Value | Description | +|---------|--------------------------------------------------------| +| [] | Used to ensure only a string email address is accepted | -## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } +A valid sms contact detail must be structured in this format: { sms: value } where Value is a string -**Given** the API consumer provides an message body with an invalid sms +**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -108,16 +148,16 @@ A valid sms contact detail must be structured in this format: { sms: value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|--------------|-----------------------------------------------------| -| 077009000021 | Used to ensure invalid phone number is not accepted | +| Value | Description | +|---------|-------------------------------------------------------| +| [] | Used to ensure only a string phone number is accepted | -## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } +A valid sms contact detail must be structured in this format: { sms: value } where Value is a string -**Given** the API consumer provides an message body with an invalid sms +**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -128,9 +168,9 @@ A valid sms contact detail must be structured in this format: { sms: value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|--------------|-----------------------------------------------------| -| 077009000021 | Used to ensure invalid phone number is not accepted | +| Value | Description | +|---------|-------------------------------------------------------| +| [] | Used to ensure only a string phone number is accepted | ## Scenario: An API consumer submitting a request with an contact details when not allowed receives a 400 ‘Cannot set contact details’ response diff --git a/docs/tests/post_v1_single-message/validation.md b/docs/tests/post_v1_single-message/validation.md index 0bab10d87..669ca77e3 100644 --- a/docs/tests/post_v1_single-message/validation.md +++ b/docs/tests/post_v1_single-message/validation.md @@ -21,11 +21,11 @@ A valid contact detail must be structured in this format: { address: { lines: [ | [ “1”, “2”, “3”, “4”, “5”, “6” ] | Used to ensure list of more than 5 values is not accepted | -## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { email: Value } +A valid email contact detail must be structured in this format: { email: Value } where Value is a string -**Given** the API consumer provides an message body with an invalid email address +**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -36,16 +36,16 @@ A valid contact detail must be structured in this format: { email: Value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|---------------------|------------------------------------------------------| -| invalidEmailAddress | Used to ensure invalid email address is not accepted | +| Value | Description | +|---------|--------------------------------------------------------| +| [] | Used to ensure only a string email address is accepted | -## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } +A valid sms contact detail must be structured in this format: { sms: value } where Value is a string -**Given** the API consumer provides an message body with an invalid sms +**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -56,9 +56,9 @@ A valid sms contact detail must be structured in this format: { sms: value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|--------------|-----------------------------------------------------| -| 077009000021 | Used to ensure invalid phone number is not accepted | +| Value | Description | +|---------|-------------------------------------------------------| +| [] | Used to ensure only a string phone number is accepted | ## Scenario: An API consumer submitting a request with an contact details when not allowed receives a 400 ‘Cannot set contact details’ response diff --git a/docs/tests/sandbox/post_v1_message-batches/validation.md b/docs/tests/sandbox/post_v1_message-batches/validation.md index f70a1a684..a7d085e7b 100644 --- a/docs/tests/sandbox/post_v1_message-batches/validation.md +++ b/docs/tests/sandbox/post_v1_message-batches/validation.md @@ -163,11 +163,11 @@ A valid contact detail must be structured in this format: { address: { lines: [ - Response returns the expected error message body -## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { email: Value } +A valid email contact detail must be structured in this format: { email: Value } where Value is a string -**Given** the API consumer provides an message body with an invalid email address +**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -178,9 +178,9 @@ A valid contact detail must be structured in this format: { email: Value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|---------------------|------------------------------------------------------| -| invalidEmailAddress | Used to ensure invalid email address is not accepted | +| Value | Description | +|---------|--------------------------------------------------------| +| [] | Used to ensure only a string email address is accepted | ## Scenario: An API consumer submitting a request with an invalid message batch reference receives a 400 ‘Invalid Value’ response @@ -268,11 +268,11 @@ The routing plan must be in a UUID format, for more information on UUID, look [h - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } +A valid sms contact detail must be structured in this format: { sms: value } where Value is a string -**Given** the API consumer provides an message body with an invalid sms +**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -283,9 +283,9 @@ A valid sms contact detail must be structured in this format: { sms: value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|--------------|-----------------------------------------------------| -| 077009000021 | Used to ensure invalid phone number is not accepted | +| Value | Description | +|---------|-------------------------------------------------------| +| [] | Used to ensure only a string phone number is accepted | ## Scenario: An API consumer submitting a request with an invalid message value receives a 400 ‘Invalid Value’ response diff --git a/docs/tests/sandbox/post_v1_messages/validation.md b/docs/tests/sandbox/post_v1_messages/validation.md index 39202906e..e98d7d00d 100644 --- a/docs/tests/sandbox/post_v1_messages/validation.md +++ b/docs/tests/sandbox/post_v1_messages/validation.md @@ -96,11 +96,11 @@ A valid contact detail must be structured in this format: { address: { lines: [ - Response returns the expected error message body -## Scenario: An API consumer submitting a request with an invalid email receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string email address receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { email: Value } +A valid email contact detail must be structured in this format: { email: Value } where Value is a string -**Given** the API consumer provides an message body with an invalid email address +**Given** the API consumer provides a message body with a non-string email address
**When** the request is submitted
@@ -111,9 +111,9 @@ A valid contact detail must be structured in this format: { email: Value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|---------------------|------------------------------------------------------| -| invalidEmailAddress | Used to ensure invalid email address is not accepted | +| Value | Description | +|---------|--------------------------------------------------------| +| [] | Used to ensure only a string email address is accepted | ## Scenario: An API consumer submitting a request with an invalid message reference receives a 400 ‘Invalid Value’ response @@ -185,11 +185,11 @@ The routing plan must be in a UUID format, for more information on UUID, look [h - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid sms receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } +A valid sms contact detail must be structured in this format: { sms: value } where Value is a string -**Given** the API consumer provides an message body with an invalid sms +**Given** the API consumer provides a message body with a non-string sms
**When** the request is submitted
@@ -200,9 +200,9 @@ A valid sms contact detail must be structured in this format: { sms: value } - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|--------------|-----------------------------------------------------| -| 077009000021 | Used to ensure invalid phone number is not accepted | +| Value | Description | +|---------|-------------------------------------------------------| +| [] | Used to ensure only a string phone number is accepted | ## Scenario: An API consumer submitting a request with an contact details when not allowed receives a 400 ‘Cannot set contact details’ response diff --git a/sandbox/handlers/config.js b/sandbox/handlers/config.js index cb3e2f3e5..c30d12cc5 100644 --- a/sandbox/handlers/config.js +++ b/sandbox/handlers/config.js @@ -25,8 +25,6 @@ const validSendingGroupIds = { [globalFreeTextSmsSendingGroupId]: "xoERWoahq12cq8WMXya4yed9hZtZbMxJ" }; -const invalidEmailAddress = "invalidEmailAddress"; - const duplicateTemplates = [ { name: "EMAIL_TEMPLATE", @@ -68,6 +66,5 @@ export { globalFreeTextSmsSendingGroupId, noDefaultOdsClientAuth, noOdsChangeClientAuth, - notAllowedContactDetailOverride, - invalidEmailAddress + notAllowedContactDetailOverride } diff --git a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py index 9f3fc9884..c45b88a60 100644 --- a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py @@ -171,6 +171,74 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token): ) +@pytest.mark.test +@pytest.mark.devtest +@pytest.mark.inttest +@pytest.mark.prodtest +def test_invalid_address_contact_details_lines_not_string_array(url, bearer_token): + """ + .. include:: ../partials/validation/test_invalid_contact_details_address_lines.rst + """ + headers = Generators.generate_valid_headers(bearer_token.value) + data = Generators.generate_valid_create_message_batch_body("dev") + data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = { + "address": { + "lines": [1, 2, 3], + "postcode": "LS1 6AE" + } + } + + resp = requests.post( + f"{url}{MESSAGE_BATCHES_ENDPOINT}", + headers=headers, + json=data + ) + + Assertions.assert_error_with_optional_correlation_id( + resp, + 400, + Generators.generate_invalid_value_error_custom_detail( + "/data/attributes/messages/0/recipient/contactDetails/address", + "Field 'address': 'lines' is not a string array" + ), + None + ) + + +@pytest.mark.test +@pytest.mark.devtest +@pytest.mark.inttest +@pytest.mark.prodtest +def test_invalid_address_contact_details_postcode_not_string(url, bearer_token): + """ + .. include:: ../partials/validation/test_invalid_contact_details_address_lines.rst + """ + headers = Generators.generate_valid_headers(bearer_token.value) + data = Generators.generate_valid_create_message_batch_body("dev") + data["data"]["attributes"]["messages"][0]["recipient"]["contactDetails"] = { + "address": { + "lines": ["1", "2"], + "postcode": [] + } + } + + resp = requests.post( + f"{url}{MESSAGE_BATCHES_ENDPOINT}", + headers=headers, + json=data + ) + + Assertions.assert_error_with_optional_correlation_id( + resp, + 400, + Generators.generate_invalid_value_error_custom_detail( + "/data/attributes/messages/0/recipient/contactDetails/address", + "Field 'address': 'postcode' is not a string" + ), + None + ) + + @pytest.mark.devtest def test_not_permitted_to_use_contact_details(url, bearer_token_internal_dev_test_1): """ diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst new file mode 100644 index 000000000..e7a166652 --- /dev/null +++ b/tests/docs/partials/validation/test_invalid_contact_details_address_lines.rst @@ -0,0 +1,22 @@ +Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 'Invalid Value' response +============================================================================================================================ + +A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array + +| **Given** the API consumer provides a message body with a non-string array address lines +| **When** the request is submitted +| **Then** the response returns a 400 invalid value error + +**Asserts** +- Response returns a 400 'Invalid Value' error +- Response returns the expected error message body with references to the invalid attribute + +.. list-table:: + :widths: 50 50 + :header-rows: 1 + + * - Value + - Description + * - [1,2] + - Used to ensure only a string array address lines is accepted + diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst index 051f1b19e..1c05951f0 100644 --- a/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst +++ b/tests/docs/partials/validation/test_invalid_contact_details_address_postcode.rst @@ -1,9 +1,9 @@ -Scenario: An API consumer submitting a request with an invalid address postcode receives a 400 'Invalid Value' response -=========================================================================================================================== +Scenario: An API consumer submitting a request with a non-string address postcode receives a 400 'Invalid Value' response +========================================================================================================================= -A valid contact detail must be structured in this format: { sms: value, email: value, address: { lines: [], postcode: value } } +A valid address postcode contact detail must be structured in this format: { address: { postcode: Value } } where Value is a string -| **Given** the API consumer provides an message body with an invalid postcode +| **Given** the API consumer provides a message body with a non-string address postcode | **When** the request is submitted | **Then** the response returns a 400 invalid value error @@ -17,6 +17,6 @@ A valid contact detail must be structured in this format: { sms: value, email: v * - Value - Description - * - LS1 6AECD - - Used to ensure only valid postcode is accepted + * - [] + - Used to ensure only a string address postcode is accepted diff --git a/tests/docs/partials/validation/test_invalid_contact_details_email.rst b/tests/docs/partials/validation/test_invalid_contact_details_email.rst index a2cf7e596..6eff865a0 100644 --- a/tests/docs/partials/validation/test_invalid_contact_details_email.rst +++ b/tests/docs/partials/validation/test_invalid_contact_details_email.rst @@ -1,9 +1,9 @@ -Scenario: An API consumer submitting a request with an invalid email receives a 400 'Invalid Value' response +Scenario: An API consumer submitting a request with a non-string email address receives a 400 'Invalid Value' response ====================================================================================================================== -A valid contact detail must be structured in this format: { email: Value } +A valid email contact detail must be structured in this format: { email: Value } where Value is a string -| **Given** the API consumer provides an message body with an invalid email address +| **Given** the API consumer provides a message body with a non-string email address | **When** the request is submitted | **Then** the response returns a 400 invalid value error @@ -17,6 +17,6 @@ A valid contact detail must be structured in this format: { email: Value } * - Value - Description - * - invalidEmailAddress - - Used to ensure invalid email address is not accepted + * - [] + - Used to ensure only a string email address is accepted diff --git a/tests/docs/partials/validation/test_invalid_contact_details_sms.rst b/tests/docs/partials/validation/test_invalid_contact_details_sms.rst index 0c52652f8..a663c5faa 100644 --- a/tests/docs/partials/validation/test_invalid_contact_details_sms.rst +++ b/tests/docs/partials/validation/test_invalid_contact_details_sms.rst @@ -1,9 +1,9 @@ -Scenario: An API consumer submitting a request with an invalid sms receives a 400 'Invalid Value' response -====================================================================================================================== +Scenario: An API consumer submitting a request with a non-string sms receives a 400 'Invalid Value' response +============================================================================================================ -A valid sms contact detail must be structured in this format: { sms: value } +A valid sms contact detail must be structured in this format: { sms: value } where Value is a string -| **Given** the API consumer provides an message body with an invalid sms +| **Given** the API consumer provides a message body with a non-string sms | **When** the request is submitted | **Then** the response returns a 400 invalid value error @@ -17,6 +17,6 @@ A valid sms contact detail must be structured in this format: { sms: value } * - Value - Description - * - 077009000021 - - Used to ensure invalid phone number is not accepted + * - [] + - Used to ensure only a string phone number is accepted From 48bdecadbec2bcfbef7898957fb21d762112330f Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 12:57:06 +0100 Subject: [PATCH 09/16] CCM-10077: update specification document --- .../message_batches/400_UnableToProcessMessageBatch.yaml | 7 ------- .../responses/4xx/messages/400_UnableToProcessMessage.yaml | 7 ------- 2 files changed, 14 deletions(-) diff --git a/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml b/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml index 45553bb2b..6b3f02829 100644 --- a/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml +++ b/specification/responses/4xx/message_batches/400_UnableToProcessMessageBatch.yaml @@ -44,13 +44,6 @@ description: |+ -d '{"data":{"type":"MessageBatch","attributes":{"routingPlanId":"b838b13c-f98c-4def-93f0-515d4e4f4ee1","messageBatchReference":"346e3fc3-0b55-4c0d-bec9-0cc5aa431836","messages":[{"messageReference":"da0b1495-c7cb-468c-9d81-07dee089d728","recipient":{"nhsNumber":"9990548609","contactDetails":{"sms":"07777000000"}},"personalisation":{}}]}}}' \ https://sandbox.api.service.nhs.uk/comms/v1/message-batches ``` - - Contact detail validation errors can be triggered with the following values. - - | Field | Value | Description | - | ---------- | ----- | ----------- | - | sms | 11111111111 | Returns 'Input failed format check' error with a pointer to sms. | - | email | invalidEmailAddress | Returns 'Input failed format check' error with a pointer to email. | content: application/vnd.api+json: schema: diff --git a/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml b/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml index 65d2dd229..a2562cc3f 100644 --- a/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml +++ b/specification/responses/4xx/messages/400_UnableToProcessMessage.yaml @@ -42,13 +42,6 @@ description: |+ -d '{"data": {"type": "Message","attributes": {"routingPlanId": "b838b13c-f98c-4def-93f0-515d4e4f4ee1","messageReference": "da0b1495-c7cb-468c-9d81-07dee089d728","recipient": {"nhsNumber": "9990548609","contactDetails": {"sms": "07777000000"}},"personalisation": {}}}}' \ https://sandbox.api.service.nhs.uk/comms/v1/messages ``` - - Contact detail validation errors can be triggered with the following values. - - | Field | Value | Description | - | ---------- | ----- | ----------- | - | sms | 11111111111 | Returns 'Input failed format check' error with a pointer to sms. | - | email | invalidEmailAddress | Returns 'Input failed format check' error with a pointer to email. | content: application/vnd.api+json: schema: From 26a8287c2b282416eb1b244bffb002cc742e30d3 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 16:32:03 +0100 Subject: [PATCH 10/16] CCM-10077: repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 12 ++++++++---- .../AssignMessage.MessageBatches.Create.Request.xml | 11 +++++++++++ .../AssignMessage.Messages.Create.Request.xml | 11 +++++++++++ .../AssignMessage.Messages.GetSingle.Request.xml | 11 +++++++++++ .../AssignMessage.NhsAppAccounts.Get.Request.xml | 11 +++++++++++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index c9c0bfdd3..3e7779475 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,10 +18,14 @@ true - - - - {requestpath} + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + + + {requestpath} + {% else %} + https://comms-apim.de-iaho3.communications.national.nhs.uk + {% endif %} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index 3dfbc673b..e0de72fe2 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,6 +20,17 @@ requestpath /api/v1/send + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/v1/send + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send + + {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index 2a8e9cd5c..e0ca45279 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,6 +20,17 @@ requestpath /api/v1/messages + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/v1/messages + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages + + {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index ce54ec959..c0ba2e7a1 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,6 +20,17 @@ requestpath + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} + + {% endif %}
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 6d71f721a..2ee021b0e 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,6 +20,17 @@ requestpath /api/channels/nhsapp/accounts + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/channels/nhsapp/accounts + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts + + {% endif %}
{backendCorrelationId}
From 1e3f40af8bdfb932bef06a0bc6071387121e7121 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 17:26:10 +0100 Subject: [PATCH 11/16] CCM-10077: fix tests --- .../field_validation/test_400_invalid_contact_details.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py index c45b88a60..416f7d3a5 100644 --- a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py @@ -199,7 +199,7 @@ def test_invalid_address_contact_details_lines_not_string_array(url, bearer_toke 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/0/recipient/contactDetails/address", - "Field 'address': 'lines' is not a string array" + "'lines' is not a string array" ), None ) @@ -233,7 +233,7 @@ def test_invalid_address_contact_details_postcode_not_string(url, bearer_token): 400, Generators.generate_invalid_value_error_custom_detail( "/data/attributes/messages/0/recipient/contactDetails/address", - "Field 'address': 'postcode' is not a string" + "'postcode' is not a string" ), None ) From b672521f1a5486b0da1b94449232f8530ce4cd4a Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 17:43:54 +0100 Subject: [PATCH 12/16] CCM-10077: revert repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 12 ++++-------- .../AssignMessage.MessageBatches.Create.Request.xml | 11 ----------- .../AssignMessage.Messages.Create.Request.xml | 11 ----------- .../AssignMessage.Messages.GetSingle.Request.xml | 11 ----------- .../AssignMessage.NhsAppAccounts.Get.Request.xml | 11 ----------- 5 files changed, 4 insertions(+), 52 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index 3e7779475..c9c0bfdd3 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,14 +18,10 @@ true - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - - - {requestpath} - {% else %} - https://comms-apim.de-iaho3.communications.national.nhs.uk - {% endif %} + + + + {requestpath} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index e0de72fe2..3dfbc673b 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,17 +20,6 @@ requestpath /api/v1/send - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/v1/send - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send - - {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index e0ca45279..2a8e9cd5c 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,17 +20,6 @@ requestpath /api/v1/messages - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/v1/messages - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages - - {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index c0ba2e7a1..ce54ec959 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,17 +20,6 @@ requestpath - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} - - {% endif %}
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 2ee021b0e..6d71f721a 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,17 +20,6 @@ requestpath /api/channels/nhsapp/accounts - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/channels/nhsapp/accounts - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts - - {% endif %}
{backendCorrelationId}
From fd22cd365d7dab8e322e9bbd8f13448cfe6a36b7 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Wed, 28 May 2025 08:34:44 +0100 Subject: [PATCH 13/16] CCM-10077: clean up tests --- .../post_v1_message-batches/validation.md | 30 ++++++------- .../post_v1_single-message/validation.md | 36 +++++++++++---- .../post_v1_message-batches/validation.md | 36 +++++++++++---- .../sandbox/post_v1_messages/validation.md | 36 +++++++++++---- .../test_400_invalid_contact_details.py | 2 +- .../test_400_invalid_contact_details.py | 34 ++++++++++++++ ...contact_details_address_lines_too_many.rst | 2 +- .../test_invalid_contact_details_sms.rst | 2 +- .../test_invalid_personalisation.rst | 6 +-- .../test_field_validation.py | 44 +++++++++++++++++++ .../create_messages/test_field_validation.py | 39 ++++++++++++++++ 11 files changed, 222 insertions(+), 45 deletions(-) diff --git a/docs/tests/post_v1_message-batches/validation.md b/docs/tests/post_v1_message-batches/validation.md index 0f5903368..b55daa774 100644 --- a/docs/tests/post_v1_message-batches/validation.md +++ b/docs/tests/post_v1_message-batches/validation.md @@ -53,11 +53,11 @@ A valid address lines contact detail must be structured in this format: { addres | [1,2] | Used to ensure only a string array address lines is accepted | -## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response +## Scenario: An API consumer submitting a request with a non-string address postcode receives a 400 ‘Invalid Value’ response -A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array +A valid address postcode contact detail must be structured in this format: { address: { postcode: Value } } where Value is a string -**Given** the API consumer provides a message body with a non-string array address lines +**Given** the API consumer provides a message body with a non-string address postcode
**When** the request is submitted
@@ -68,14 +68,14 @@ A valid address lines contact detail must be structured in this format: { addres - Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute -| Value | Description | -|---------|--------------------------------------------------------------| -| [1,2] | Used to ensure only a string array address lines is accepted | +| Value | Description | +|---------|-----------------------------------------------------------| +| [] | Used to ensure only a string address postcode is accepted | ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } +A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } } **Given** the API consumer provides an message body with with too many address lines
@@ -135,7 +135,7 @@ A valid email contact detail must be structured in this format: { email: Value } ## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } where Value is a string +A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string **Given** the API consumer provides a message body with a non-string sms
@@ -155,7 +155,7 @@ A valid sms contact detail must be structured in this format: { sms: value } whe ## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } where Value is a string +A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string **Given** the API consumer provides a message body with a non-string sms
@@ -281,9 +281,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -293,7 +293,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | @@ -364,9 +364,9 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/messages/0/recipient/nhsNumber | -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -376,7 +376,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | diff --git a/docs/tests/post_v1_single-message/validation.md b/docs/tests/post_v1_single-message/validation.md index 669ca77e3..9103f6de9 100644 --- a/docs/tests/post_v1_single-message/validation.md +++ b/docs/tests/post_v1_single-message/validation.md @@ -1,9 +1,29 @@ # Validation Tests +## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response + +A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array + +**Given** the API consumer provides a message body with a non-string array address lines +
+**When** the request is submitted +
+**Then** the response returns a 400 invalid value error +
+ +**Asserts** +- Response returns a 400 ‘Invalid Value’ error +- Response returns the expected error message body with references to the invalid attribute + +| Value | Description | +|---------|--------------------------------------------------------------| +| [1,2] | Used to ensure only a string array address lines is accepted | + + ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } +A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } } **Given** the API consumer provides an message body with with too many address lines
@@ -43,7 +63,7 @@ A valid email contact detail must be structured in this format: { email: Value } ## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } where Value is a string +A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string **Given** the API consumer provides a message body with a non-string sms
@@ -152,9 +172,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -164,7 +184,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | @@ -219,9 +239,9 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/recipient/nhsNumber | -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -231,7 +251,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | diff --git a/docs/tests/sandbox/post_v1_message-batches/validation.md b/docs/tests/sandbox/post_v1_message-batches/validation.md index a7d085e7b..cf95dd96f 100644 --- a/docs/tests/sandbox/post_v1_message-batches/validation.md +++ b/docs/tests/sandbox/post_v1_message-batches/validation.md @@ -129,9 +129,29 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/messages/0/recipient/nhsNumber | +## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response + +A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array + +**Given** the API consumer provides a message body with a non-string array address lines +
+**When** the request is submitted +
+**Then** the response returns a 400 invalid value error +
+ +**Asserts** +- Response returns a 400 ‘Invalid Value’ error +- Response returns the expected error message body with references to the invalid attribute + +| Value | Description | +|---------|--------------------------------------------------------------| +| [1,2] | Used to ensure only a string array address lines is accepted | + + ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } +A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } } **Given** the API consumer provides an message body with with too many address lines
@@ -231,9 +251,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -243,7 +263,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | @@ -270,7 +290,7 @@ The routing plan must be in a UUID format, for more information on UUID, look [h ## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } where Value is a string +A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string **Given** the API consumer provides a message body with a non-string sms
@@ -316,9 +336,9 @@ A valid sms contact detail must be structured in this format: { sms: value } whe - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -328,7 +348,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | diff --git a/docs/tests/sandbox/post_v1_messages/validation.md b/docs/tests/sandbox/post_v1_messages/validation.md index e98d7d00d..ded2fb523 100644 --- a/docs/tests/sandbox/post_v1_messages/validation.md +++ b/docs/tests/sandbox/post_v1_messages/validation.md @@ -62,9 +62,29 @@ Below is a table showing the required attributes and their locations as seen in | nhsNumber | /data/attributes/recipient/nhsNumber | +## Scenario: An API consumer submitting a request with a non-string array address lines receives a 400 ‘Invalid Value’ response + +A valid address lines contact detail must be structured in this format: { address: { lines: Value } } where Value is a string array + +**Given** the API consumer provides a message body with a non-string array address lines +
+**When** the request is submitted +
+**Then** the response returns a 400 invalid value error +
+ +**Asserts** +- Response returns a 400 ‘Invalid Value’ error +- Response returns the expected error message body with references to the invalid attribute + +| Value | Description | +|---------|--------------------------------------------------------------| +| [1,2] | Used to ensure only a string array address lines is accepted | + + ## Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 ‘Invalid Value’ response -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } +A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } } **Given** the API consumer provides an message body with with too many address lines
@@ -148,9 +168,9 @@ An NHS Number is a 10 digit number used to identify patients, for more informati - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -160,7 +180,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | @@ -187,7 +207,7 @@ The routing plan must be in a UUID format, for more information on UUID, look [h ## Scenario: An API consumer submitting a request with a non-string sms receives a 400 ‘Invalid Value’ response -A valid sms contact detail must be structured in this format: { sms: value } where Value is a string +A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string **Given** the API consumer provides a message body with a non-string sms
@@ -219,9 +239,9 @@ A valid sms contact detail must be structured in this format: { sms: value } whe - Response returns the expected error message body with references to the invalid attribute -## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid value’ response +## Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 ‘Invalid Value’ response -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } **Given** the API consumer provides a message body with an invalid personalisation
@@ -231,7 +251,7 @@ A valid personalisation must be structured in this format: { parameter: value }
**Asserts** -- Response returns a 400 ‘Invalid value’ error +- Response returns a 400 ‘Invalid Value’ error - Response returns the expected error message body with references to the invalid attribute | Value | Description | diff --git a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py index 416f7d3a5..2b8b8d0f3 100644 --- a/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/message_batches/field_validation/test_400_invalid_contact_details.py @@ -211,7 +211,7 @@ def test_invalid_address_contact_details_lines_not_string_array(url, bearer_toke @pytest.mark.prodtest def test_invalid_address_contact_details_postcode_not_string(url, bearer_token): """ - .. include:: ../partials/validation/test_invalid_contact_details_address_lines.rst + .. include:: ../partials/validation/test_invalid_contact_details_address_postcode.rst """ headers = Generators.generate_valid_headers(bearer_token.value) data = Generators.generate_valid_create_message_batch_body("dev") diff --git a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py index 5f7b82fd2..313180fb1 100644 --- a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py @@ -98,6 +98,40 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token): ) +@pytest.mark.test +@pytest.mark.devtest +@pytest.mark.inttest +@pytest.mark.prodtest +def test_invalid_address_contact_details_lines_not_string_array(url, bearer_token): + """ + .. include:: ../partials/validation/test_invalid_contact_details_address_lines.rst + """ + headers = Generators.generate_valid_headers(bearer_token.value) + data = Generators.generate_valid_create_message_batch_body("dev") + data["data"]["attributes"]["recipient"]["contactDetails"] = { + "address": { + "lines": [1, 2, 3], + "postcode": "test" + } + } + + resp = requests.post( + f"{url}{MESSAGES_ENDPOINT}", + headers=headers, + json=data + ) + + Assertions.assert_error_with_optional_correlation_id( + resp, + 400, + Generators.generate_invalid_value_error_custom_detail( + "/data/attributes/recipient/contactDetails/address", + "'lines' is not a string array" + ), + None + ) + + @pytest.mark.devtest def test_not_permitted_to_use_contact_details(url, bearer_token_internal_dev_test_1): """ diff --git a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst b/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst index 3727100ce..126ec7407 100644 --- a/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst +++ b/tests/docs/partials/validation/test_invalid_contact_details_address_lines_too_many.rst @@ -1,7 +1,7 @@ Scenario: An API consumer submitting a request with invalid address lines (too many) receives a 400 'Invalid Value' response =============================================================================================================================== -A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: value } } +A valid contact detail must be structured in this format: { address: { lines: [ Value1, Value2 ], postcode: Value } } | **Given** the API consumer provides an message body with with too many address lines | **When** the request is submitted diff --git a/tests/docs/partials/validation/test_invalid_contact_details_sms.rst b/tests/docs/partials/validation/test_invalid_contact_details_sms.rst index a663c5faa..2c62f53d3 100644 --- a/tests/docs/partials/validation/test_invalid_contact_details_sms.rst +++ b/tests/docs/partials/validation/test_invalid_contact_details_sms.rst @@ -1,7 +1,7 @@ Scenario: An API consumer submitting a request with a non-string sms receives a 400 'Invalid Value' response ============================================================================================================ -A valid sms contact detail must be structured in this format: { sms: value } where Value is a string +A valid sms contact detail must be structured in this format: { sms: Value } where Value is a string | **Given** the API consumer provides a message body with a non-string sms | **When** the request is submitted diff --git a/tests/docs/partials/validation/test_invalid_personalisation.rst b/tests/docs/partials/validation/test_invalid_personalisation.rst index c40050bac..ecff04908 100644 --- a/tests/docs/partials/validation/test_invalid_personalisation.rst +++ b/tests/docs/partials/validation/test_invalid_personalisation.rst @@ -1,14 +1,14 @@ -Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 'Invalid value' response +Scenario: An API consumer submitting a request with an invalid personalisation receives a 400 'Invalid Value' response ====================================================================================================================== -A valid personalisation must be structured in this format: { parameter: value } +A valid personalisation must be structured in this format: { parameter: Value } | **Given** the API consumer provides a message body with an invalid personalisation | **When** the request is submitted | **Then** the response returns a 400 invalid value error **Asserts** -- Response returns a 400 'Invalid value' error +- Response returns a 400 'Invalid Value' error - Response returns the expected error message body with references to the invalid attribute .. list-table:: diff --git a/tests/sandbox/message_batches/create_message_batches/test_field_validation.py b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py index e4f5cee28..51e83b006 100644 --- a/tests/sandbox/message_batches/create_message_batches/test_field_validation.py +++ b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py @@ -664,3 +664,47 @@ def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, cor ), correlation_id ) + + +@pytest.mark.sandboxtest +@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID) +def test_invalid_address_contact_details_lines_not_string_array(nhsd_apim_proxy_url, correlation_id): + """ + .. include:: ../../partials/validation/test_invalid_contact_details_address_lines.rst + """ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ + **headers, + "X-Correlation-Id": correlation_id + }, json={ + "data": { + "type": "MessageBatch", + "attributes": { + "routingPlanId": "b838b13c-f98c-4def-93f0-515d4e4f4ee1", + "messageBatchReference": str(uuid.uuid1()), + "messages": [ + { + "messageReference": "72f2fa29-1570-47b7-9a67-63dc4b28fc1b", + "recipient": { + "nhsNumber": "9990548609", + "contactDetails": { + "address": { + "lines": [1, 2, 3], + "postcode": "test" + } + } + }, + } + ] + } + } + }) + + Assertions.assert_error_with_optional_correlation_id( + resp, + 400, + Generators.generate_invalid_value_error_custom_detail( + "/data/attributes/messages/0/recipient/contactDetails/address", + "'lines' is not a string array" + ), + correlation_id + ) diff --git a/tests/sandbox/messages/create_messages/test_field_validation.py b/tests/sandbox/messages/create_messages/test_field_validation.py index b894660d5..707d83f6f 100644 --- a/tests/sandbox/messages/create_messages/test_field_validation.py +++ b/tests/sandbox/messages/create_messages/test_field_validation.py @@ -432,3 +432,42 @@ def test_invalid_address_contact_details_too_many_lines(nhsd_apim_proxy_url, cor ), correlation_id ) + + +@pytest.mark.sandboxtest +@pytest.mark.parametrize("correlation_id", constants.CORRELATION_ID) +def test_invalid_address_contact_details_lines_not_string_array(nhsd_apim_proxy_url, correlation_id): + """ + .. include:: ../../partials/validation/test_invalid_contact_details_address_lines.rst + """ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ + **headers, + "X-Correlation-Id": correlation_id + }, json={ + "data": { + "type": "Message", + "attributes": { + "routingPlanId": "b838b13c-f98c-4def-93f0-515d4e4f4ee1", + "messageReference": str(uuid.uuid1()), + "recipient": { + "nhsNumber": "9990548609", + "contactDetails": { + "address": { + "lines": [1, 2, 3], + "postcode": "test" + } + } + }, + } + } + }) + + Assertions.assert_error_with_optional_correlation_id( + resp, + 400, + Generators.generate_invalid_value_error_custom_detail( + "/data/attributes/recipient/contactDetails/address", + "'lines' is not a string array" + ), + correlation_id + ) From eefb358b773815e813d93988bd2d711f26070e96 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 16:32:03 +0100 Subject: [PATCH 14/16] CCM-10077: repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 12 ++++++++---- .../AssignMessage.MessageBatches.Create.Request.xml | 11 +++++++++++ .../AssignMessage.Messages.Create.Request.xml | 11 +++++++++++ .../AssignMessage.Messages.GetSingle.Request.xml | 11 +++++++++++ .../AssignMessage.NhsAppAccounts.Get.Request.xml | 11 +++++++++++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index c9c0bfdd3..3e7779475 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,10 +18,14 @@ true - - - - {requestpath} + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + + + {requestpath} + {% else %} + https://comms-apim.de-iaho3.communications.national.nhs.uk + {% endif %} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index 3dfbc673b..e0de72fe2 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,6 +20,17 @@ requestpath /api/v1/send + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/v1/send + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send + + {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index 2a8e9cd5c..e0ca45279 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,6 +20,17 @@ requestpath /api/v1/messages + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/v1/messages + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages + + {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index ce54ec959..c0ba2e7a1 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,6 +20,17 @@ requestpath + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} + + {% endif %}
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 6d71f721a..2ee021b0e 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,6 +20,17 @@ requestpath /api/channels/nhsapp/accounts + {% if ENVIRONMENT_TYPE == 'sandbox' %} + + requestpath + /api/channels/nhsapp/accounts + + {% else %} + + target.url + https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts + + {% endif %}
{backendCorrelationId}
From 20cba479f066cf865827a6be173a662f9f8c0b51 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Wed, 28 May 2025 09:04:36 +0100 Subject: [PATCH 15/16] CCM-10077: fix tests --- .../field_validation/test_400_invalid_contact_details.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py index 313180fb1..08b92fbe1 100644 --- a/tests/api/single_message/field_validation/test_400_invalid_contact_details.py +++ b/tests/api/single_message/field_validation/test_400_invalid_contact_details.py @@ -104,10 +104,10 @@ def test_invalid_address_contact_details_too_many_lines(url, bearer_token): @pytest.mark.prodtest def test_invalid_address_contact_details_lines_not_string_array(url, bearer_token): """ - .. include:: ../partials/validation/test_invalid_contact_details_address_lines.rst + .. include:: /partials/validation/test_invalid_contact_details_address_lines.rst """ headers = Generators.generate_valid_headers(bearer_token.value) - data = Generators.generate_valid_create_message_batch_body("dev") + data = Generators.generate_valid_create_message_body("dev") data["data"]["attributes"]["recipient"]["contactDetails"] = { "address": { "lines": [1, 2, 3], From b1a803ff206dc291b01cf64e20b3f298a129458c Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Tue, 27 May 2025 17:43:54 +0100 Subject: [PATCH 16/16] CCM-10077: revert repoint to de-iaho3 backend --- proxies/live/apiproxy/targets/target.xml | 12 ++++-------- .../AssignMessage.MessageBatches.Create.Request.xml | 11 ----------- .../AssignMessage.Messages.Create.Request.xml | 11 ----------- .../AssignMessage.Messages.GetSingle.Request.xml | 11 ----------- .../AssignMessage.NhsAppAccounts.Get.Request.xml | 11 ----------- 5 files changed, 4 insertions(+), 52 deletions(-) diff --git a/proxies/live/apiproxy/targets/target.xml b/proxies/live/apiproxy/targets/target.xml index 3e7779475..c9c0bfdd3 100644 --- a/proxies/live/apiproxy/targets/target.xml +++ b/proxies/live/apiproxy/targets/target.xml @@ -18,14 +18,10 @@ true - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - - - {requestpath} - {% else %} - https://comms-apim.de-iaho3.communications.national.nhs.uk - {% endif %} + + + + {requestpath} 29000 diff --git a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml index e0de72fe2..3dfbc673b 100644 --- a/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.MessageBatches.Create.Request.xml @@ -20,17 +20,6 @@ requestpath /api/v1/send - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/v1/send - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/send - - {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml index e0ca45279..2a8e9cd5c 100644 --- a/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.Create.Request.xml @@ -20,17 +20,6 @@ requestpath /api/v1/messages - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/v1/messages - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages - - {% endif %} %data.payload# diff --git a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml index c0ba2e7a1..ce54ec959 100644 --- a/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml +++ b/proxies/shared/policies/AssignMessage.Messages.GetSingle.Request.xml @@ -20,17 +20,6 @@ requestpath - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/v1/messages/{data.messageId} - - {% endif %}
{backendCorrelationId}
diff --git a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml index 2ee021b0e..6d71f721a 100644 --- a/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml +++ b/proxies/shared/policies/AssignMessage.NhsAppAccounts.Get.Request.xml @@ -20,17 +20,6 @@ requestpath /api/channels/nhsapp/accounts - {% if ENVIRONMENT_TYPE == 'sandbox' %} - - requestpath - /api/channels/nhsapp/accounts - - {% else %} - - target.url - https://comms-apim.de-iaho3.communications.national.nhs.uk/api/channels/nhsapp/accounts - - {% endif %}
{backendCorrelationId}