From 42d9011026b57b143f01fa0c53cd6fd25dfc2691 Mon Sep 17 00:00:00 2001 From: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:57:55 +0100 Subject: [PATCH] Unify error (#332) * refactor: simplify error * test: update error message * chore: fix vulnerability --- package-lock.json | 5 +++-- .../CreateAttributeRequestItemProcessor.ts | 10 +--------- .../CreateAttributeRequestItemProcessor.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58be4b35e..58ffb4165 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3432,9 +3432,10 @@ "license": "MIT" }, "node_modules/cross-spawn": { - "version": "7.0.3", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dev": true, - "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", diff --git a/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts index 043449215..3a4a3fccb 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts @@ -49,17 +49,9 @@ export class CreateAttributeRequestItemProcessor extends GenericRequestItemProce return ValidationResult.success(); } - if (typeof recipient !== "undefined") { - return ValidationResult.error( - ConsumptionCoreErrors.requests.invalidRequestItem( - "The owner of the provided RelationshipAttribute for the `attribute` property can only be the Sender's Address, the Recipient's Address or an empty string. The latter will default to the Recipient's Address." - ) - ); - } - return ValidationResult.error( ConsumptionCoreErrors.requests.invalidRequestItem( - "The owner of the provided RelationshipAttribute for the `attribute` property can only be the Sender's Address or an empty string. The latter will default to the Recipient's Address." + "The owner of the provided RelationshipAttribute for the `attribute` property can only be the address of the sender, recipient or an empty string. The latter will default to the address of the recipient." ) ); } diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts index 5b77126b8..9ca8d7fd1 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts @@ -117,7 +117,7 @@ describe("CreateAttributeRequestItemProcessor", function () { await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfSomeoneElse }); await Then.theResultShouldBeAnErrorWith({ message: - "The owner of the provided RelationshipAttribute for the `attribute` property can only be the Sender's Address, the Recipient's Address or an empty string. The latter will default to the Recipient's Address." + "The owner of the provided RelationshipAttribute for the `attribute` property can only be the address of the sender, recipient or an empty string. The latter will default to the address of the recipient." }); }); @@ -129,7 +129,7 @@ describe("CreateAttributeRequestItemProcessor", function () { await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfSomeoneElse }, TestIdentity.UNDEFINED); await Then.theResultShouldBeAnErrorWith({ message: - "The owner of the provided RelationshipAttribute for the `attribute` property can only be the Sender's Address or an empty string. The latter will default to the Recipient's Address." + "The owner of the provided RelationshipAttribute for the `attribute` property can only be the address of the sender, recipient or an empty string. The latter will default to the address of the recipient." }); }); });