Skip to content

Commit

Permalink
Execute sequential tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Sep 30, 2024
1 parent 022639b commit cb2be30
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/controllers/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class AccreditationController {
),
AccreditationService.instance.verify_accreditation(
issuerDid,
parentAccreditation,
rootAuthorisation,
true,
false,
response.locals.customer
Expand Down
35 changes: 16 additions & 19 deletions src/services/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,30 @@ export class AccreditationService {
};
}
const accreditorDid = didUrl.split('?')[0];
const parentDid = termsOfUse.parentAccreditation.split('?')[0];
const parentAccreditation = (
await this.verify_accreditation(
const [parentAccreditation, rootAuthorisation] = await Promise.all([
this.verify_accreditation(
accreditorDid,
termsOfUse.parentAccreditation,
verifyStatus,
allowDeactivatedDid,
customer
)
).success;
const rootDid = termsOfUse.rootAuthorisation.split('?')[0];
let rootAuthorisation = false;
if (parentDid == rootDid) {
rootAuthorisation = (
await this.verify_accreditation(
accreditorDid,
termsOfUse.rootAuthorisation,
verifyStatus,
allowDeactivatedDid,
customer
)
).success;
}
),
this.verify_accreditation(
accreditorDid,
termsOfUse.rootAuthorisation,
verifyStatus,
allowDeactivatedDid,
customer
),
]);
return {
status: 200,
success: true,
data: { ...verifyResult, parentAccreditation, rootAuthorisation },
data: {
...verifyResult,
parentAccreditation: parentAccreditation.success,
rootAuthorisation: rootAuthorisation.success,
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ test(' Issue and verify a authorize accreditation', async ({ request }) => {
});
expect(didUrls).toHaveLength(2);
expect(didUrls).toContain(
`did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=testAccreditation&resourceType=VerifiableAuthorisationForTrustChain`
`did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain`
);

const verifyResponse = await request.post(`/accreditation/verify`, {
data: JSON.stringify({
subjectDid: `${credentialData.subjectDid}`,
accreditation: `did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=testAccreditation&resourceType=VerifiableAuthorisationForTrustChain`,
accreditation: `did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain`,
}),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand Down

0 comments on commit cb2be30

Please sign in to comment.