Skip to content

Commit

Permalink
review comment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Sep 10, 2024
1 parent 7b33941 commit 1ee314d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/protocols-grant-authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class ProtocolsGrantAuthorization {
ProtocolsGrantAuthorization.verifyScope(protocolsConfigureMessage, permissionGrant.scope as ProtocolPermissionScope);
}

/**
* Authorizes the scope of a permission grant for a ProtocolsQuery message.
* @param messageStore Used to check if the grant has been revoked.
*/
public static async authorizeQuery(input: {
expectedGrantor: string,
expectedGrantee: string,
Expand Down
2 changes: 1 addition & 1 deletion tests/features/author-delegated-grant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function testAuthorDelegatedGrant(): void {
const alice = await TestDataGenerator.generateDidKeyPersona();
const bob = await TestDataGenerator.generateDidKeyPersona();

// Alice grants Bob to configure the email protocol
// Alice grants Bob ability to configure any protocol, bob will use it to configure the email protocol
const scope: PermissionScope = {
interface : DwnInterfaceName.Protocols,
method : DwnMethodName.Configure,
Expand Down
11 changes: 11 additions & 0 deletions tests/handlers/protocols-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,17 @@ export function testProtocolsQueryHandler(): void {
expect(protocolQueryPublishedReply.status.code).to.equal(200);
expect(protocolQueryPublishedReply.entries?.length).to.equal(1);
expect(protocolQueryPublishedReply.entries![0].descriptor.definition.protocol).to.deep.equal(publishedProtocol);

// Bob tries to ProtocolsQuery to Alice's DWN with no filters, using the same grant
const protocolQueryNoFilters = await ProtocolsQuery.create({
signer : Jws.createSigner(bob),
permissionGrantId : permissionGrant.recordsWrite.message.recordId,
});

const protocolQueryNoFiltersReply = await dwn.processMessage(alice.did, protocolQueryNoFilters.message);
expect(protocolQueryNoFiltersReply.status.code).to.equal(200);
expect(protocolQueryNoFiltersReply.entries?.length).to.equal(1);
expect(protocolQueryNoFiltersReply.entries![0].descriptor.definition.protocol).to.deep.equal(publishedProtocol);
});

it('rejects with 401 when an external party attempts to ProtocolsQuery if they present an expired grant', async () => {
Expand Down

0 comments on commit 1ee314d

Please sign in to comment.