diff --git a/src/controllers/api/accreditation.ts b/src/controllers/api/accreditation.ts index 66bc50d3..2be9a8ac 100644 --- a/src/controllers/api/accreditation.ts +++ b/src/controllers/api/accreditation.ts @@ -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}`, }); } } diff --git a/src/services/api/accreditation.ts b/src/services/api/accreditation.ts index ac3173d4..6ecc6db0 100644 --- a/src/services/api/accreditation.ts +++ b/src/services/api/accreditation.ts @@ -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}`, }; } diff --git a/tests/e2e/parallel/accreditation/negative-flow.spec.ts b/tests/e2e/parallel/accreditation/negative-flow.spec.ts new file mode 100644 index 00000000..293907ab --- /dev/null +++ b/tests/e2e/parallel/accreditation/negative-flow.spec.ts @@ -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); +}); diff --git a/tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts b/tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts index eb909b1c..c1d45ebf 100644 --- a/tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts +++ b/tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts @@ -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`, { @@ -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`, {