Skip to content

Commit

Permalink
revoke user keys and check
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Apr 9, 2024
1 parent 571234c commit 4f0238a
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions tests/handlers/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ describe('auth', () => {
expect(token).to.be.a('object');
});

it('key rotation use case', async () => {
it.only('key rotation use case', async () => {
const claimReq: CredentialRequest = {
credentialSchema:
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v4.json',
Expand Down Expand Up @@ -2239,7 +2239,34 @@ describe('auth', () => {
'no auth credentials found'
);

// should this work?
// this should this work because we haven't revoked user keys
await handleAuthorizationRequest(userDID, authReqBody);

// get actual auth credential (k2)
const { authCredential: userAuthCredential } = await idWallet.getActualAuthCredential(userDID);

const treesModel3 = await idWallet.getDIDTreeModel(userDID);
const [ctrHex3, rtrHex3, rorTrHex3] = await Promise.all([
treesModel3.claimsTree.root(),
treesModel3.revocationTree.root(),
treesModel3.rootsTree.root()
]);

const oldTreeState3 = {
state: treesModel3.state,
claimsRoot: ctrHex3,
revocationRoot: rtrHex3,
rootOfRoots: rorTrHex3
};

// revoke user keys
const nonce3 = await idWallet.revokeCredential(userDID, userAuthCredential);
await idWallet.publishStateToRHS(userDID, RHS_URL, [nonce3]);
await proofService.transitState(userDID, oldTreeState3, true, dataStorage.states, ethSigner);

// this should not work because we revoked user keys
await expect(handleAuthorizationRequest(userDID, authReqBody)).to.rejectedWith(
'no auth credentials found'
);
});
});

0 comments on commit 4f0238a

Please sign in to comment.