From fd2f77f5f18d835bc2ac991df4195f6e21c8362a Mon Sep 17 00:00:00 2001 From: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:10:18 +0200 Subject: [PATCH] Feature/Allow succession if DeletionRequestRejected (#216) * feat: allow succession of attribute with deletionStatus DeletionRequestRejected * chore: version bump * chore: version bump --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- package-lock.json | 6 ++-- packages/consumption/package.json | 2 +- .../attributes/AttributesController.ts | 3 +- .../attributes/AttributesController.test.ts | 28 +++++++++++++++++++ packages/runtime/package.json | 4 +-- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7c7a6906b..867400064 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12567,7 +12567,7 @@ }, "packages/consumption": { "name": "@nmshd/consumption", - "version": "3.12.3", + "version": "3.12.4", "license": "MIT", "dependencies": { "@js-soft/docdb-querytranslator": "^1.1.4", @@ -12614,14 +12614,14 @@ }, "packages/runtime": { "name": "@nmshd/runtime", - "version": "4.14.3", + "version": "4.14.4", "license": "MIT", "dependencies": { "@js-soft/docdb-querytranslator": "^1.1.4", "@js-soft/logging-abstractions": "^1.0.1", "@js-soft/ts-serval": "2.0.10", "@js-soft/ts-utils": "^2.3.3", - "@nmshd/consumption": "3.12.3", + "@nmshd/consumption": "3.12.4", "@nmshd/content": "2.11.0", "@nmshd/crypto": "2.0.6", "@nmshd/transport": "2.8.2", diff --git a/packages/consumption/package.json b/packages/consumption/package.json index 7a5ed7d8f..1c61630ac 100644 --- a/packages/consumption/package.json +++ b/packages/consumption/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/consumption", - "version": "3.12.3", + "version": "3.12.4", "description": "The consumption library extends the transport library.", "homepage": "https://enmeshed.eu", "repository": { diff --git a/packages/consumption/src/modules/attributes/AttributesController.ts b/packages/consumption/src/modules/attributes/AttributesController.ts index df08f58bc..93974f628 100644 --- a/packages/consumption/src/modules/attributes/AttributesController.ts +++ b/packages/consumption/src/modules/attributes/AttributesController.ts @@ -37,6 +37,7 @@ import { CreateLocalAttributeParams, ICreateLocalAttributeParams } from "./local import { ICreatePeerLocalAttributeParams } from "./local/CreatePeerLocalAttributeParams"; import { CreateSharedLocalAttributeCopyParams, ICreateSharedLocalAttributeCopyParams } from "./local/CreateSharedLocalAttributeCopyParams"; import { ILocalAttribute, LocalAttribute, LocalAttributeJSON } from "./local/LocalAttribute"; +import { DeletionStatus } from "./local/LocalAttributeDeletionInfo"; import { LocalAttributeShareInfo } from "./local/LocalAttributeShareInfo"; import { IdentityAttributeQueryTranslator, RelationshipAttributeQueryTranslator, ThirdPartyRelationshipAttributeQueryTranslator } from "./local/QueryTranslator"; @@ -891,7 +892,7 @@ export class AttributesController extends ConsumptionBaseController { return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeValueType()); } - if (predecessor.hasDeletionInfo()) { + if (predecessor.hasDeletionInfo() && predecessor.deletionInfo.deletionStatus !== DeletionStatus.DeletionRequestRejected) { return ValidationResult.error(CoreErrors.attributes.cannotSucceedAttributesWithDeletionInfo()); } diff --git a/packages/consumption/test/modules/attributes/AttributesController.test.ts b/packages/consumption/test/modules/attributes/AttributesController.test.ts index a5dc5d9ab..299d3f275 100644 --- a/packages/consumption/test/modules/attributes/AttributesController.test.ts +++ b/packages/consumption/test/modules/attributes/AttributesController.test.ts @@ -1112,6 +1112,34 @@ describe("AttributesController", function () { code: "error.consumption.attributes.cannotSucceedAttributesWithDeletionInfo" }); }); + + test("should allow succession if the predecessor has a deletionInfo with status DeletionRequestRejected", async function () { + const predecessor = await consumptionController.attributes.createAttributeUnsafe({ + content: IdentityAttribute.from({ + value: { + "@type": "Nationality", + value: "DE" + }, + owner: CoreAddress.from("address") + }), + deletionInfo: LocalAttributeDeletionInfo.from({ + deletionStatus: DeletionStatus.DeletionRequestRejected, + deletionDate: CoreDate.utc().subtract({ days: 1 }) + }) + }); + const successorData: IAttributeSuccessorParams = { + content: IdentityAttribute.from({ + value: { + "@type": "Nationality", + value: "DE" + }, + owner: CoreAddress.from("address") + }) + }; + + const validationResult = await consumptionController.attributes.validateAttributeSuccessionCommon(predecessor.id, successorData); + expect(validationResult.isSuccess()).toBe(true); + }); }); describe("Validator for own shared identity attribute successions", function () { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index abfae6521..484fd1b8f 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/runtime", - "version": "4.14.3", + "version": "4.14.4", "description": "The enmeshed client runtime.", "homepage": "https://enmeshed.eu", "repository": { @@ -56,7 +56,7 @@ "@js-soft/logging-abstractions": "^1.0.1", "@js-soft/ts-serval": "2.0.10", "@js-soft/ts-utils": "^2.3.3", - "@nmshd/consumption": "3.12.3", + "@nmshd/consumption": "3.12.4", "@nmshd/content": "2.11.0", "@nmshd/crypto": "2.0.6", "@nmshd/transport": "2.8.2",