Skip to content

Commit

Permalink
Feature/Allow succession if DeletionRequestRejected (#216)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Milena-Czierlinski and mergify[bot] authored Aug 1, 2024
1 parent e345029 commit fd2f77f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/consumption/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fd2f77f

Please sign in to comment.