Skip to content

Commit

Permalink
add explicit test for querying protocol configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Sep 10, 2024
1 parent 1ee314d commit fe856be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/handlers/protocols-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ export function testProtocolsQueryHandler(): void {
const bob = await TestDataGenerator.generateDidKeyPersona();
const mallory = await TestDataGenerator.generateDidKeyPersona();

// Alice creates a public and private protocol to test query results
const { message: publicProtocolMessage } = await TestDataGenerator.generateProtocolsConfigure({
author : alice,
published : true,
});

const { status: publicProtocolStatus } = await dwn.processMessage(alice.did, publicProtocolMessage);
expect(publicProtocolStatus.code).to.equal(202);

const { message: privateProtocolMessage } = await TestDataGenerator.generateProtocolsConfigure({
author : alice,
published : false,
});

const { status: privateProtocolStatus } = await dwn.processMessage(alice.did, privateProtocolMessage);
expect(privateProtocolStatus.code).to.equal(202);

// 1. Alice grants Bob the access to ProtocolsQuery on her DWN
const permissionGrant = await PermissionsProtocol.createGrant({
signer : Jws.createSigner(alice),
Expand All @@ -259,6 +276,7 @@ export function testProtocolsQueryHandler(): void {
});
const protocolsQueryReply = await dwn.processMessage(alice.did, protocolsQuery.message);
expect(protocolsQueryReply.status.code).to.equal(200);
expect(protocolsQueryReply.entries?.length).to.equal(2);

// 3. Verify that Mallory cannot to use Bob's permission grant to gain access to Alice's DWN
const malloryProtocolsQuery = await TestDataGenerator.generateProtocolsQuery({
Expand Down

0 comments on commit fe856be

Please sign in to comment.