Skip to content

Commit

Permalink
Update accreditation auth
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Oct 4, 2024
1 parent 60ce93f commit 8696023
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/controllers/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class AccreditationController {
/**
* @openapi
*
* /accreditation/issue:
* /trust-registry/accreditation/issue:
* post:
* tags: [ Trust Registry ]
* summary: Publish a verifiable accreditation for a DID.
Expand Down Expand Up @@ -290,7 +290,7 @@ export class AccreditationController {
/**
* @openapi
*
* /accreditation/verify:
* /trust-registry/accreditation/verify:
* post:
* tags: [ Trust Registry ]
* summary: Verify a verifiable accreditation for a DID.
Expand Down
26 changes: 18 additions & 8 deletions src/middleware/auth/routes/api/accreditation-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ import { AuthRuleProvider } from '../auth-rule-provider.js';
export class AccreditationAuthRuleProvider extends AuthRuleProvider {
constructor() {
super();
this.registerRule('/trust-registry/accreditation/issue', 'POST', 'issue:accreditation:testnet');
this.registerRule('/trust-registry/accreditation/verify', 'POST', 'verify:accreditation:testnet', {
skipNamespace: true,
});
this.registerRule('/trust-registry/accreditation/issue', 'POST', 'issue:accreditation:mainnet');
this.registerRule('/trust-registry/accreditation/verify', 'POST', 'verify:accreditation:mainnet', {
skipNamespace: true,
});
this.registerRule('/trust-registry/accreditation/issue', 'POST', 'issue-accreditation:trust-registry:testnet');
this.registerRule(
'/trust-registry/accreditation/verify',
'POST',
'verify-accreditation:trust-registry:testnet',
{
skipNamespace: true,
}
);
this.registerRule('/trust-registry/accreditation/issue', 'POST', 'issue-accreditation:trust-registry:mainnet');
this.registerRule(
'/trust-registry/accreditation/verify',
'POST',
'verify-accreditation:trust-registry:mainnet',
{
skipNamespace: true,
}
);
}
}
16 changes: 8 additions & 8 deletions tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test.use({ storageState: 'playwright/.auth/user.json' });

test(' Issue and verify a authorize accreditation', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/accreditation/issue?accreditationType=authorize`, {
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorize`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand All @@ -31,7 +31,7 @@ test(' Issue and verify a authorize accreditation', async ({ request }) => {
`did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain`
);

const verifyResponse = await request.post(`/accreditation/verify`, {
const verifyResponse = await request.post(`/trust-registry/accreditation/verify`, {
data: JSON.stringify({
subjectDid: `${credentialData.subjectDid}`,
accreditation: `did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain`,
Expand All @@ -49,7 +49,7 @@ test(' Issue and verify a authorize accreditation', async ({ request }) => {

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(`/accreditation/issue`, {
const issueResponse = await request.post(`/trust-registry/accreditation/issue`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand All @@ -59,7 +59,7 @@ test(' Issue accreditation [Negative]', async ({ request }) => {
});

test(' Verify accreditation [Negative]', async ({ request }) => {
const verifyResponse = await request.post(`/accreditation/verify`, {
const verifyResponse = await request.post(`/trust-registry/accreditation/verify`, {
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
},
Expand All @@ -69,7 +69,7 @@ test(' Verify accreditation [Negative]', async ({ request }) => {

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(`/accreditation/issue?accreditationType=accredit`, {
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=accredit`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand All @@ -93,7 +93,7 @@ test(' Issue and verify a accredit accreditation', async ({ request }) => {
`did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit`
);

const verifyResponse = await request.post(`/accreditation/verify`, {
const verifyResponse = await request.post(`/trust-registry/accreditation/verify`, {
data: JSON.stringify({
subjectDid: `${credentialData.subjectDid}`,
accreditation: `did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit`,
Expand All @@ -111,7 +111,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}/attest-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/accreditation/issue?accreditationType=attest`, {
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=attest`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand All @@ -135,7 +135,7 @@ test(' Issue and verify a attest accreditation', async ({ request }) => {
`did:cheqd:testnet:BjS4Nv8bVdxm2WW28MCfXA?resourceName=attestAccreditation&resourceType=VerifiableAccreditationToAttest`
);

const verifyResponse = await request.post(`/accreditation/verify`, {
const verifyResponse = await request.post(`/trust-registry/accreditation/verify`, {
data: JSON.stringify({
subjectDid: `${credentialData.subjectDid}`,
accreditation: `did:cheqd:testnet:BjS4Nv8bVdxm2WW28MCfXA?resourceName=attestAccreditation&resourceType=VerifiableAccreditationToAttest`,
Expand Down

0 comments on commit 8696023

Please sign in to comment.