Skip to content

Commit

Permalink
Parallelize negative tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Oct 7, 2024
1 parent 2b7989c commit 81c25eb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/controllers/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class AccreditationController {

if (result.success === false) {
return response.status(result.status).send({
error: `root Authorization or parent Accreditation is not valid`,
error: `Invalid Request: Root Authorization or parent Accreditation is not valid: ${result.error}`,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class AccreditationService {
return {
success: false,
status: StatusCodes.BAD_REQUEST,
error: `Invalid termsOfUse`,
error: `Missing parentAccreditaiton and rootAuthorization in termsOfUse for accreditation: ${accreditationUrl}`,
};
}

Expand Down
40 changes: 40 additions & 0 deletions tests/e2e/parallel/accreditation/negative-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
import * as fs from 'fs';
import { CONTENT_TYPE, PAYLOADS_PATH } from '../../constants';

test.use({ storageState: 'playwright/.auth/user.json' });

test(' Issue accreditation [Negative]: Missing query parameters', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/trust-registry/accreditation/issue`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
});
expect(issueResponse.status()).toBe(StatusCodes.BAD_REQUEST);
});

test(' Verify accreditation [Negative]: Missing request body', async ({ request }) => {
const verifyResponse = await request.post(`/trust-registry/accreditation/verify`, {
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
});
expect(verifyResponse.status()).toBe(StatusCodes.BAD_REQUEST);
});

test(' Issue accreditation [Negative]: Invalid schema', async ({ request }) => {
const credentialData = JSON.parse(
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/invalid-schema-accredit.json`, 'utf-8')
);
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=accredit`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
});

expect(issueResponse.status()).toBe(StatusCodes.UNAUTHORIZED);
});
34 changes: 0 additions & 34 deletions tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,6 @@ test(' Issue and verify a authorize accreditation', async ({ request }) => {
expect(result.verified).toBe(true);
});

test(' Issue accreditation [Negative]', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/trust-registry/accreditation/issue`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
});
expect(issueResponse.status()).toBe(400);
});

test(' Verify accreditation [Negative]', async ({ request }) => {
const verifyResponse = await request.post(`/trust-registry/accreditation/verify`, {
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
});
expect(verifyResponse.status()).toBe(400);
});

test(' Issue and verify a accredit accreditation', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/accredit-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=accredit`, {
Expand Down Expand Up @@ -158,20 +138,6 @@ test(' Issue and verify a child accredit accreditation', async ({ request }) =>
expect(result.verified).toBe(true);
});

test(' Issue invalid schema accreditation', async ({ request }) => {
const credentialData = JSON.parse(
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/invalid-schema-accredit.json`, 'utf-8')
);
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=accredit`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
});

expect(issueResponse.status()).toBe(StatusCodes.UNAUTHORIZED);
});

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

0 comments on commit 81c25eb

Please sign in to comment.