Skip to content

Commit

Permalink
Consumer Api: Deleting an identity with an already decomposed relatio…
Browse files Browse the repository at this point in the history
…nship throws an error (#977)

* fix: Don't throw an error if the relationship is already decomposed

* chore: Remove unnecessary test
  • Loading branch information
MH321Productions authored Dec 13, 2024
1 parent 35687c4 commit aa84f59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ public void Decomposition_can_be_performed_from_multiple_statuses(RelationshipSt
relationship.ToHasDecomposed.Should().BeFalse();
}

[Fact]
public void Decomposition_can_not_be_called_by_the_same_identity_twice()
{
// Arrange
var relationship = CreateRelationshipDecomposedByFrom(IDENTITY_1, IDENTITY_2);

// Act
var acting = () => relationship.DecomposeDueToIdentityDeletion(IDENTITY_1, DID_DOMAIN_NAME);

// Assert
acting.Should().Throw<DomainException>().WithError("error.platform.validation.relationship.relationshipAlreadyDecomposed");
}

[Fact]
public void Decomposition_can_not_be_performed_by_other_identities()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ public void Decompose(IdentityAddress activeIdentity, DeviceId activeDevice)
public void DecomposeDueToIdentityDeletion(IdentityAddress identityToBeDeleted, string didDomainName)
{
EnsureHasParticipant(identityToBeDeleted);
EnsureRelationshipNotDecomposedBy(identityToBeDeleted);

if (From == identityToBeDeleted && FromHasDecomposed || To == identityToBeDeleted && ToHasDecomposed) return;

if (Status is RelationshipStatus.DeletionProposed)
DecomposeAsSecondParticipant(identityToBeDeleted, null, RelationshipAuditLogEntryReason.DecompositionDueToIdentityDeletion);
Expand Down

0 comments on commit aa84f59

Please sign in to comment.