Skip to content

Commit

Permalink
Decrypting Messages fails when Relationship is not active anymore (#279)
Browse files Browse the repository at this point in the history
* fix: validate messages, challenges for once active relationship

* test: remove test

* Revert "test: remove test"

This reverts commit 469c9bd.

* feat: revert create challenge validation

* test: add tests

* feat: message controller wording

Co-authored-by: Julian König <[email protected]>

* refactor: newline

* chore: remove challenge changes

* refactor: remove unused code

---------

Co-authored-by: Julian König <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 23, 2024
1 parent 3ad1fa5 commit 85db57a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/transport/src/modules/messages/MessageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ export class MessageController extends TransportController {
);
}
} else {
relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy);
relationship = await this.relationships.getRelationshipToIdentity(envelope.createdBy);

if (!relationship) {
throw TransportCoreErrors.messages.missingOrInactiveRelationship(envelope.createdBy.toString());
throw TransportCoreErrors.general.recordNotFound(Relationship, envelope.createdBy.toString());
}

const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,20 @@ describe("MessageController", function () {
});

describe("Relationship Termination", function () {
let messageId: CoreId;

beforeAll(async function () {
messageId = (await TestUtil.sendMessage(sender, recipient)).id;
await TestUtil.terminateRelationship(sender, recipient);
});

test("should not send a message on a terminated relationship", async function () {
await expect(TestUtil.sendMessage(sender, recipient)).rejects.toThrow("error.transport.messages.missingOrInactiveRelationship");
});

test("should still decrypt the message", async function () {
await expect(sender.messages.fetchCaches([messageId])).resolves.not.toThrow();
await expect(recipient.messages.fetchCaches([messageId])).resolves.not.toThrow();
});
});
});

0 comments on commit 85db57a

Please sign in to comment.