diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts index 98af18996..8945fcecf 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts @@ -66,9 +66,9 @@ export class Context { public translateTestIdentity(testIdentity: CoreAddress): CoreAddress | undefined { switch (testIdentity.toString()) { - case TestIdentity.SENDER.toString(): + case TestIdentity.CURRENT_IDENTITY.toString(): return this.accountController.identity.address; - case TestIdentity.RECIPIENT.toString(): + case TestIdentity.PEER.toString(): return this.peerAddress; case TestIdentity.EMPTY.toString(): return CoreAddress.from(""); @@ -230,7 +230,7 @@ export class WhenSteps { await this.context.consumptionController.attributes.updateAttributeUnsafe(attribute); } - public async iCallCanCreateOutgoingRequestItemWith(partialRequestItem: Partial, recipient: CoreAddress = TestIdentity.RECIPIENT): Promise { + public async iCallCanCreateOutgoingRequestItemWith(partialRequestItem: Partial, recipient: CoreAddress = TestIdentity.PEER): Promise { partialRequestItem.mustBeAccepted ??= true; partialRequestItem.attribute ??= TestObjectFactory.createIdentityAttribute({ owner: this.context.accountController.identity.address 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 7d7f4118f..ee2f7900a 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts @@ -31,18 +31,18 @@ describe("CreateAttributeRequestItemProcessor", function () { }); describe("canCreateOutgoingRequestItem", function () { - test("returns Success when passing an IdentityAttribute with owner={{Recipient}}", async function () { + test("returns Success when passing an IdentityAttribute with owner={{Peer}}", async function () { const identityAttributeOfRecipient = TestObjectFactory.createIdentityAttribute({ - owner: TestIdentity.RECIPIENT + owner: TestIdentity.PEER }); await When.iCallCanCreateOutgoingRequestItemWith({ attribute: identityAttributeOfRecipient }); await Then.theCanCreateResultShouldBeASuccess(); }); - test("returns an Error when passing an IdentityAttribute with owner={{Sender}}", async function () { + test("returns an Error when passing an IdentityAttribute with owner={{CurrentIdentity}}", async function () { const identityAttributeOfSender = TestObjectFactory.createIdentityAttribute({ - owner: TestIdentity.SENDER + owner: TestIdentity.CURRENT_IDENTITY }); await When.iCallCanCreateOutgoingRequestItemWith({ attribute: identityAttributeOfSender }); @@ -72,7 +72,7 @@ describe("CreateAttributeRequestItemProcessor", function () { }); }); - test("returns Success when passing an IdentityAttribute with owner={{SomeoneElse}}, but no Recipient", async function () { + test("returns Success when passing an IdentityAttribute with owner={{SomeoneElse}}, but no recipient", async function () { const identityAttributeOfSomeoneElse = TestObjectFactory.createIdentityAttribute({ owner: TestIdentity.SOMEONE_ELSE }); @@ -84,18 +84,18 @@ describe("CreateAttributeRequestItemProcessor", function () { }); }); - test("returns Success when passing a RelationshipAttribute with owner={{Recipient}}", async function () { + test("returns Success when passing a RelationshipAttribute with owner={{Peer}}", async function () { const relationshipAttributeOfRecipient = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.RECIPIENT + owner: TestIdentity.PEER }); await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfRecipient }); await Then.theCanCreateResultShouldBeASuccess(); }); - test("returns Success when passing a RelationshipAttribute with owner={{Sender}}", async function () { + test("returns Success when passing a RelationshipAttribute with owner={{CurrentIdentity}}", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER + owner: TestIdentity.CURRENT_IDENTITY }); await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfSender }); @@ -123,7 +123,7 @@ describe("CreateAttributeRequestItemProcessor", function () { }); }); - test("returns Success when passing a RelationshipAttribute with owner={{SomeoneElse}}, but no Recipient", async function () { + test("returns Success when passing a RelationshipAttribute with owner={{SomeoneElse}}, but no recipient", async function () { const relationshipAttributeOfSomeoneElse = TestObjectFactory.createRelationshipAttribute({ owner: TestIdentity.SOMEONE_ELSE }); @@ -138,18 +138,18 @@ describe("CreateAttributeRequestItemProcessor", function () { test("returns Error when passing a RelationshipAttribute with same key as an already existing RelationshipAttribute of this Relationship", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "uniqueKey" }); await When.iCreateARelationshipAttribute(relationshipAttributeOfSender); const relationshipAttributeWithSameKey = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "uniqueKey" }); - await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeWithSameKey }, TestIdentity.RECIPIENT); + await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeWithSameKey }, TestIdentity.PEER); await Then.theCanCreateResultShouldBeAnErrorWith({ code: "error.consumption.requests.invalidRequestItem", message: @@ -157,9 +157,9 @@ describe("CreateAttributeRequestItemProcessor", function () { }); }); - test("returns Error on violation of key uniqueness even if the owner of the provided RelationshipAttribute is an empty string as long as the Recipient is known", async function () { + test("returns Error on violation of key uniqueness even if the owner of the provided RelationshipAttribute is an empty string as long as the recipient is known", async function () { const relationshipAttributeOfRecipient = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.RECIPIENT, + owner: TestIdentity.PEER, key: "uniqueKey" }); @@ -170,7 +170,7 @@ describe("CreateAttributeRequestItemProcessor", function () { key: "uniqueKey" }); - await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeWithSameKeyAndEmptyOwner }, TestIdentity.RECIPIENT); + await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeWithSameKeyAndEmptyOwner }, TestIdentity.PEER); await Then.theCanCreateResultShouldBeAnErrorWith({ code: "error.consumption.requests.invalidRequestItem", message: @@ -180,24 +180,24 @@ describe("CreateAttributeRequestItemProcessor", function () { test("returns Success when passing a RelationshipAttribute with same key but different owner", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "ownerSpecificUniqueKey" }); await When.iCreateARelationshipAttribute(relationshipAttributeOfSender); const relationshipAttributeOfRecipient = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.RECIPIENT, + owner: TestIdentity.PEER, key: "ownerSpecificUniqueKey" }); - await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfRecipient }, TestIdentity.RECIPIENT); + await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfRecipient }, TestIdentity.PEER); await Then.theCanCreateResultShouldBeASuccess(); }); test("returns Success when passing a RelationshipAttribute with same key but different value type", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "valueTypeSpecificUniqueKey", value: ProprietaryString.from({ title: "aTitle", value: "aProprietaryStringValue" }) }); @@ -205,18 +205,18 @@ describe("CreateAttributeRequestItemProcessor", function () { await When.iCreateARelationshipAttribute(relationshipAttributeOfSender); const relationshipAttributeOfRecipient = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "valueTypeSpecificUniqueKey", value: ProprietaryInteger.from({ title: "aTitle", value: 1 }) }); - await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfRecipient }, TestIdentity.RECIPIENT); + await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfRecipient }, TestIdentity.PEER); await Then.theCanCreateResultShouldBeASuccess(); }); test("returns Success when passing a RelationshipAttribute with same key as a RelationshipAttribute in deletion", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "persistenceSpecificUniqueKey" }); @@ -224,28 +224,28 @@ describe("CreateAttributeRequestItemProcessor", function () { await When.iMarkMyAttributeAsToBeDeleted(createdAttribute); const relationshipAttributeWithSameKey = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "persistenceSpecificUniqueKey" }); - await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeWithSameKey }, TestIdentity.RECIPIENT); + await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeWithSameKey }, TestIdentity.PEER); await Then.theCanCreateResultShouldBeASuccess(); }); test("returns Success when passing a RelationshipAttribute with same key as an already existing ThirdPartyRelationshipAttribute", async function () { const thirdPartyRelationshipAttribute = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "relationshipSpecificUniqueKey" }); await When.iCreateAThirdPartyRelationshipAttribute(thirdPartyRelationshipAttribute); const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER, + owner: TestIdentity.CURRENT_IDENTITY, key: "relationshipSpecificUniqueKey" }); - await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfSender }, TestIdentity.RECIPIENT); + await When.iCallCanCreateOutgoingRequestItemWith({ attribute: relationshipAttributeOfSender }, TestIdentity.PEER); await Then.theCanCreateResultShouldBeASuccess(); }); }); @@ -253,7 +253,7 @@ describe("CreateAttributeRequestItemProcessor", function () { describe("canAccept", function () { test("can create a RelationshipAttribute", async function () { await Given.aRequestItemWithARelationshipAttribute({ - attributeOwner: TestIdentity.RECIPIENT + attributeOwner: TestIdentity.PEER }); await When.iCallCanAccept(); @@ -262,13 +262,13 @@ describe("CreateAttributeRequestItemProcessor", function () { test("cannot create another RelationshipAttribute with same key", async function () { const relationshipAttributeOfRecipient = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.RECIPIENT + owner: TestIdentity.PEER }); await When.iCreateARelationshipAttribute(relationshipAttributeOfRecipient); await Given.aRequestItemWithARelationshipAttribute({ - attributeOwner: TestIdentity.RECIPIENT + attributeOwner: TestIdentity.PEER }); await expect(When.iCallCanAccept()).rejects.toThrow( @@ -278,7 +278,7 @@ describe("CreateAttributeRequestItemProcessor", function () { test("cannot create another RelationshipAttribute with same key even if the owner of the provided RelationshipAttribute is an empty string", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER + owner: TestIdentity.CURRENT_IDENTITY }); await When.iCreateARelationshipAttribute(relationshipAttributeOfSender); @@ -294,7 +294,7 @@ describe("CreateAttributeRequestItemProcessor", function () { test("cannot accept because it would lead to the creation of another RelationshipAttribute with same key but rejecting of the CreateAttributeRequestItem would be permitted", async function () { const relationshipAttributeOfSender = TestObjectFactory.createRelationshipAttribute({ - owner: TestIdentity.SENDER + owner: TestIdentity.CURRENT_IDENTITY }); await When.iCreateARelationshipAttribute(relationshipAttributeOfSender); @@ -317,7 +317,7 @@ describe("CreateAttributeRequestItemProcessor", function () { describe("accept", function () { test("in case of a RelationshipAttribute: creates an own shared RelationshipAttribute", async function () { await Given.aRequestItemWithARelationshipAttribute({ - attributeOwner: TestIdentity.SENDER + attributeOwner: TestIdentity.CURRENT_IDENTITY }); await When.iCallAccept(); await Then.anOwnSharedRelationshipAttributeIsCreated(); @@ -325,7 +325,7 @@ describe("CreateAttributeRequestItemProcessor", function () { test("in case of an IdentityAttribute: creates a RepositoryAttribute and an own shared IdentityAttribute", async function () { await Given.aRequestItemWithAnIdentityAttribute({ - attributeOwner: TestIdentity.SENDER + attributeOwner: TestIdentity.CURRENT_IDENTITY }); await When.iCallAccept(); await Then.aRepositoryAttributeIsCreated(); @@ -334,7 +334,7 @@ describe("CreateAttributeRequestItemProcessor", function () { }); describe("applyIncomingResponseItem", function () { - test.each([TestIdentity.RECIPIENT, TestIdentity.EMPTY])( + test.each([TestIdentity.PEER, TestIdentity.EMPTY])( "in case of an IdentityAttribute with owner=${value.toString()}: creates a LocalAttribute with the Attribute from the RequestItem and the attributeId from the ResponseItem for the peer of the request ", async function (attributeOwner: CoreAddress) { await Given.aRequestItemWithAnIdentityAttribute({ attributeOwner }); @@ -345,7 +345,7 @@ describe("CreateAttributeRequestItemProcessor", function () { } ); - test.each([TestIdentity.RECIPIENT, TestIdentity.EMPTY, TestIdentity.SENDER])( + test.each([TestIdentity.PEER, TestIdentity.EMPTY, TestIdentity.CURRENT_IDENTITY])( "in case of a RelationshipAttribute with owner=${value.toString()}: creates a LocalAttribute with the Attribute from the RequestItem and the attributeId from the ResponseItem for the peer of the request ", async function (attributeOwner: CoreAddress) { await Given.aRequestItemWithARelationshipAttribute({ attributeOwner }); diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts index 5c73f9fc4..330ac7b8a 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts @@ -1,8 +1,8 @@ import { CoreAddress } from "@nmshd/core-types"; export class TestIdentity { - public static readonly SENDER = CoreAddress.from("{{Sender}}"); - public static readonly RECIPIENT = CoreAddress.from("{{Recipient}}"); + public static readonly CURRENT_IDENTITY = CoreAddress.from("{{CurrentAddress}}"); + public static readonly PEER = CoreAddress.from("{{Peer}}"); public static readonly EMPTY = CoreAddress.from("{{Empty}}"); public static readonly UNDEFINED = CoreAddress.from("{{Undefined}}"); public static readonly SOMEONE_ELSE = CoreAddress.from("{{SomeoneElse}}");