Skip to content

Commit

Permalink
fix test payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Sep 30, 2024
1 parent ec0d373 commit c96b540
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
20 changes: 8 additions & 12 deletions src/controllers/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export class AccreditationController {
];

public static verifyValidator = [
body('accreditation').exists().bail(),
body('subjectDid').exists().bail(),
body('accreditation').exists().withMessage('accreditation should be a DID Url').bail(),
body('subjectDid').exists().isDID().bail(),
query('verifyStatus')
.optional()
.isBoolean()
Expand Down Expand Up @@ -121,11 +121,9 @@ export class AccreditationController {
public async issue(request: Request, response: Response) {
const result = validationResult(request);
if (!result.isEmpty()) {
return response
.json({
message: result.array(),
})
.status(400);
return response.status(400).json({
message: result.array(),
});
}

// Get strategy e.g. postgres or local
Expand Down Expand Up @@ -333,11 +331,9 @@ export class AccreditationController {
public async verify(request: Request, response: Response) {
const result = validationResult(request);
if (!result.isEmpty()) {
return response
.json({
message: result.array(),
})
.status(400);
return response.status(400).json({
message: result.array(),
});
}

// Extract did from params
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/auth/routes/api/accreditation-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export class AccreditationAuthRuleProvider extends AuthRuleProvider {
constructor() {
super();
this.registerRule('/accreditation/issue', 'POST', 'issue:accreditation:testnet');
this.registerRule('/accreditation/verify', 'POST', 'verify:accreditation:testnet');
this.registerRule('/accreditation/verify', 'POST', 'verify:accreditation:testnet', { skipNamespace: true });
}
}
4 changes: 2 additions & 2 deletions tests/e2e/payloads/accreditation/attest-jwt.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"issuerDid": "did:cheqd:testnet:BjS4Nv8bVdxm2WW28MCfXA",
"subjectDid": "did:cheqd:testnet:33c96aca-9c65-4ebf-8807-b40b0fa928f4",
"subjectDid": "did:cheqd:testnet:GEMXDEg5EhL3YdG2qpbspB",
"schemas": [
{
"url": "https://schema.org/Person",
Expand All @@ -9,6 +9,6 @@
],
"format": "jwt",
"accreditationName": "accreditAccreditation",
"parentAccreditation": "did:cheqd:testnet:BjS4Nv8bVdxm2WW28MCfXA?resourceName=accreditAuthorization&resoourceType=",
"parentAccreditation": "did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit",
"rootAuthorization": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ test(' Issue and verify a accredit accreditation', async ({ request }) => {
});

test(' Issue and verify a attest accreditation', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/accredit-jwt.json`, 'utf-8'));
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/attest-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/accreditation/issue?accreditationType=attest`, {
data: JSON.stringify(credentialData),
headers: {
Expand Down

0 comments on commit c96b540

Please sign in to comment.