Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
adds edges coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Griffin <[email protected]>
  • Loading branch information
m00sey committed Oct 4, 2023
1 parent 5d7d569 commit a29a3c5
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 24 deletions.
18 changes: 9 additions & 9 deletions src/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,29 +181,29 @@ namespace edges {
}

/**
* OfficialOrganizationalRoleEdgeArgs
* OfficialOrganizationalRoleCredentialEdgeArgs
*
* Parameters for {@link OfficialOrganizationalRoleEdge}
* Parameters for {@link OfficialOrganizationalRoleCredentialEdge}
*
* @property {auth OfficialOrganizationalRoleCredentialEdgeData} data for the edge
*/
export interface OfficialOrganizationalRoleEdgeArgs {
export interface OfficialOrganizationalRoleCredentialEdgeArgs {
auth: OfficialOrganizationalRoleCredentialEdgeData;
}

/**
* OfficialOrganizationalRoleEdge
* OfficialOrganizationalRoleCredentialEdge
*
* Used as edge property for {@link createOfficialOrganizationalRoleCredential}
*
* @property {d string} digest of {@link OfficialOrganizationalRoleEdge} block
* @property {auth OfficialOrganizationalRoleEdgeData} nested block of {@link OfficialOrganizationalRoleEdgeData}
* @property {d string} digest of {@link OfficialOrganizationalRoleCredentialEdge} block
* @property {auth OfficialOrganizationalRoleCredentialEdgeData} nested block of {@link OfficialOrganizationalRoleCredentialEdgeData}
*/
export class OfficialOrganizationalRoleEdge {
export class OfficialOrganizationalRoleCredentialEdge {
readonly d: string;
readonly auth: OfficialOrganizationalRoleCredentialEdgeData;

constructor({ auth }: OfficialOrganizationalRoleEdgeArgs) {
constructor({ auth }: OfficialOrganizationalRoleCredentialEdgeArgs) {
this.d = Saider.saidify({ d: '', auth: auth })[1]['d'];
this.auth = auth;
}
Expand All @@ -223,7 +223,7 @@ namespace edges {
/**
* OfficialOrganizationalRoleCredentialEdgeData
*
* Nested property for {@link OfficialOrganizationalRoleEdge}
* Nested property for {@link OfficialOrganizationalRoleCredentialEdge}
*
* @property {n string} SAID of previously issued Legal Entity credential
* @property {s string} SAID of Engagement Context Authorization credential schema
Expand Down
2 changes: 1 addition & 1 deletion src/qvi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class QVI {
public async createOfficialOrganizationRoleCredential(
issuee: AID,
data: credentials.OfficialOrganizationalRoleCredentialData,
edge: edges.OfficialOrganizationalRoleEdge
edge: edges.OfficialOrganizationalRoleCredentialEdge
) {
return await this.client
.credentials()
Expand Down
86 changes: 74 additions & 12 deletions test/edges.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,79 @@
import { describe, expect, it } from '@jest/globals';
import { credentials } from '../src/credentials';

describe('ecr credentials', () => {
it('should create ecr data', () => {
let data = new credentials.LegalEntityCredentialData({
issuee: 'issuee',
timestamp: 'timestamp',
LEI: 'lei',
import { edges } from '../src/edges';
import { schema } from '../src/schema';

describe('edges', () => {
it('should create legal entity credential edge', () => {
let data = new edges.LegalEntityCredentialEdgeData({
qviCredentialSAID: 'my qvi credential said',
});

let edge = new edges.LegalEntityCredentialEdge({ qvi: data });

expect(edge.d).toBe('EErRQydqQppqs8OsX5XPwbXvItMWx3U6jwmqiJR15IXc');
expect(edge.qvi.n).toBe('my qvi credential said');
expect(edge.qvi.s).toBe(schema.QVI);
});

it('should create engagement context role credential edge', () => {
let data = new edges.EngagementContextRoleCredentialEdgeData({
engagementContextRoleAuthorizationCredentialSAID:
'my ecr auth credential said',
});

let edge = new edges.EngagementContextRoleCredentialEdge({
auth: data,
});

expect(edge.d).toBe('ENmhHNmmrYqAWhisnSyQyQlsUrn5HFpDvUjZ5_ev043_');
expect(edge.auth.n).toBe('my ecr auth credential said');
expect(edge.auth.s).toBe(schema.ECRAuth);
});

it('should create official organizational role credential edge', () => {
let data = new edges.OfficialOrganizationalRoleCredentialEdgeData({
officialOrganizationalRoleAuthorizationCredentialSAID:
'my oor auth credential said',
});

let edge = new edges.OfficialOrganizationalRoleCredentialEdge({
auth: data,
});

expect(edge.d).toBe('EOshmoza8V7wyEMOC0e4Qh31MP89hAo9GJwyctOTFvgg');
expect(edge.auth.n).toBe('my oor auth credential said');
expect(edge.auth.s).toBe(schema.OORAuth);
});

it('should create engagement context role authorization credential edge', () => {
let data =
new edges.EngagementContextRoleAuthorizationCredentialEdgeData({
legalEntityCredentialSAID: 'my ecr auth credential said',
});

let edge = new edges.EngagementContextRoleAuthorizationEdge({
le: data,
});

expect(edge.d).toBe('EFmitYRo5Dgijnr0rtQ0QW0A-MGPxozV3e4F6BUSVWSR');
expect(edge.le.n).toBe('my ecr auth credential said');
expect(edge.le.s).toBe(schema.LE);
});

it('should create official organizational role authorization credential edge', () => {
let data =
new edges.OfficialOrganizationalRoleAuthorizationCredentialEdgeData(
{
legalEntityCredentialSAID: 'my ecr auth credential said',
}
);

let edge = new edges.OfficialOrganizationalRoleAuthorizationEdge({
le: data,
});

expect(data.d).toBe('EN04IEg4A-w_CN8-hb2YfZsl9k7pyH9uUOYJR2rhbWKn');
expect(data.i).toBe('issuee');
expect(data.dt).toBe('timestamp');
expect(data.LEI).toBe('lei');
expect(edge.d).toBe('EFmitYRo5Dgijnr0rtQ0QW0A-MGPxozV3e4F6BUSVWSR');
expect(edge.le.n).toBe('my ecr auth credential said');
expect(edge.le.s).toBe(schema.LE);
});
});
4 changes: 2 additions & 2 deletions test/qvi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('a qvi', () => {
legalEntityCredentialSAID: 'a SAID',
}
);
let edge = new edges.OfficialOrganizationalRoleEdge({
let edge = new edges.OfficialOrganizationalRoleCredentialEdge({
auth: edgeData,
});

Expand All @@ -149,7 +149,7 @@ describe('a qvi', () => {
credentials.OfficialOrganizationalRoleCredentialData
),
rules.OOR,
anyOfClass(edges.OfficialOrganizationalRoleEdge),
anyOfClass(edges.OfficialOrganizationalRoleCredentialEdge),
false
)
).once();
Expand Down

0 comments on commit a29a3c5

Please sign in to comment.