-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add credential info to access attributes (#254)
- Loading branch information
1 parent
e07b90e
commit 2fef3aa
Showing
14 changed files
with
404 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CredentialInfo } from '../models/CredentialInfo' | ||
|
||
describe('CredentialInfo', () => { | ||
it('should return the correct property values', () => { | ||
const claims = { | ||
name: 'Timo', | ||
date_of_birth: '1998-07-29', | ||
'country-of-residence': 'The Netherlands', | ||
'street name': 'Test street', | ||
age: '22', | ||
} | ||
const metadata = { | ||
credentialDefinitionId: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG', | ||
schemaId: 'TL1EaPFCZ8Si5aUrqScBDt:2:test-schema-1599055118161:1.0', | ||
} | ||
const credentialInfo = new CredentialInfo({ | ||
claims, | ||
metadata, | ||
}) | ||
|
||
expect(credentialInfo.claims).toEqual(claims) | ||
expect(credentialInfo.metadata).toEqual(metadata) | ||
}) | ||
}) |
33 changes: 33 additions & 0 deletions
33
src/modules/credentials/__tests__/CredentialRecord.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { CredentialRecord } from '../repository/CredentialRecord' | ||
import { CredentialState } from '../CredentialState' | ||
import { CredentialPreviewAttribute } from '../messages' | ||
|
||
describe('CredentialRecord', () => { | ||
describe('getCredentialInfo()', () => { | ||
test('creates credential info object from credential record data', () => { | ||
const credentialRecord = new CredentialRecord({ | ||
connectionId: '28790bfe-1345-4c64-b21a-7d98982b3894', | ||
state: CredentialState.Done, | ||
credentialAttributes: [ | ||
new CredentialPreviewAttribute({ | ||
name: 'age', | ||
value: '25', | ||
}), | ||
], | ||
metadata: { | ||
credentialDefinitionId: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG', | ||
schemaId: 'TL1EaPFCZ8Si5aUrqScBDt:2:test-schema-1599055118161:1.0', | ||
}, | ||
}) | ||
|
||
const credentialInfo = credentialRecord.getCredentialInfo() | ||
expect(credentialInfo?.claims).toEqual({ | ||
age: '25', | ||
}) | ||
expect(credentialInfo?.metadata).toEqual({ | ||
credentialDefinitionId: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG', | ||
schemaId: 'TL1EaPFCZ8Si5aUrqScBDt:2:test-schema-1599055118161:1.0', | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.