Skip to content

Commit

Permalink
Select creds test vector junit report (#344)
Browse files Browse the repository at this point in the history
* adding test vector

* updates

* underscores

* upload junit xml for tests

* fix path

* fix merge

* fix merge

* Update .github/workflows/tests-ci.yml

* Pin mocha-junit-reporter version

Signed-off-by: Frank Hinek <[email protected]>

* Update test-vectors/presentation_exchange/select_credentials.json

Co-authored-by: Frank Hinek <[email protected]>

* remove fs

* remove fs

* remove await

---------

Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: finn <[email protected]>
Co-authored-by: Frank Hinek <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent 3b82fdb commit 05ff2ab
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ jobs:
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV
- name: Run tests for all packages
run: npm run test:node --ws -- --color
run: npm run test:node --ws -- --color --reporter mocha-junit-reporter --reporter-options mochaFile=./results.xml
env:
TEST_DWN_URL: http://localhost:3000

- name: Terminate dwn-server
run: kill $DWN_SERVER_BACKGROUND_PROCESS || true

- name: Upload test results to update SDK reports
uses: actions/upload-artifact@v3
with:
name: junit-results
path: packages/*/results.xml

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
env:
Expand Down Expand Up @@ -141,4 +147,4 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- uses: TBD54566975/[email protected]
- uses: TBD54566975/[email protected]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ dist

# IntelliJ
.idea

results.xml
81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"rimraf": "4.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"rimraf": "4.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.40.1",
"rimraf": "4.4.0",
"typescript": "5.1.6"
Expand Down
1 change: 1 addition & 0 deletions packages/credentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.40.1",
"rimraf": "4.4.0",
"typescript": "5.1.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/credentials/src/presentation-exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class PresentationExchange {
}): string[] {
this.resetPex();
const selectResults: SelectResults = this.pex.selectFrom(presentationDefinition, vcJwts);
return selectResults.verifiableCredential as string[] ?? [];
return Array.from(new Set(selectResults.verifiableCredential as string[] ?? []));
}

/**
Expand Down
17 changes: 17 additions & 0 deletions packages/credentials/tests/presentation-exchange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { Validated, PresentationDefinitionV2 } from '../src/presentation-ex

import { VerifiableCredential } from '../src/verifiable-credential.js';
import { PresentationExchange } from '../src/presentation-exchange.js';
import PresentationExchangeSelectCredentialsSpec from '../../../test-vectors/presentation_exchange/select_credentials.json' assert { type: 'json' };


class BitcoinCredential {
constructor(
Expand Down Expand Up @@ -209,6 +211,21 @@ describe('PresentationExchange', () => {
expect(warnings?.length).to.equal(0);
});
});

describe('Web5TestVectorsPresentationExchangeSpec', () => {
it('select_credentials', async () => {
const vectors = PresentationExchangeSelectCredentialsSpec.vectors;

for (let i = 0; i < vectors.length; i++) {
const input = vectors[i].input;
const expectedOutput = vectors[i].output.selectedCredentials;

const selectedCreds = PresentationExchange.selectCredentials({ vcJwts: input.credentialJwts, presentationDefinition: input.presentationDefinition});

expect(selectedCreds).to.deep.equals(expectedOutput);
}
});
});
});

function createPresentationDefinition(): PresentationDefinitionV2 {
Expand Down
1 change: 1 addition & 0 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.40.1",
"rimraf": "4.4.0",
"sinon": "15.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/dids/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"playwright": "1.40.1",
"rimraf": "4.4.0",
"sinon": "15.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/identity-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"rimraf": "4.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/proxy-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"rimraf": "4.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/user-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"eslint": "8.47.0",
"eslint-plugin-mocha": "10.1.0",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.1",
"node-stdlib-browser": "1.2.0",
"playwright": "1.40.1",
"rimraf": "4.4.0",
Expand Down
59 changes: 59 additions & 0 deletions test-vectors/presentation_exchange/select_credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"description": "Select Credentials",
"vectors": [
{
"description": "select credentials for presentation",
"input": {
"presentationDefinition": {
"id": "test-pd-id",
"name": "simple PD",
"purpose": "pd for testing",
"input_descriptors": [
{
"id": "whatever",
"purpose": "id for testing",
"constraints": {
"fields": [
{
"path": [
"$.vc.credentialSubject.btcAddress",
"$.credentialSubject.btcAddress",
"$.btcAddress"
]
}
]
}
},
{
"id": "whatever2",
"purpose": "id for testing2",
"constraints": {
"fields": [
{
"path": [
"$.vc.credentialSubject.dogeAddress",
"$.credentialSubject.dogeAddress",
"$.dogeAddress"
]
}
]
}
}
]
},
"credentialJwts": [
"eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa2ZIQk5tYzRjQ2hOdER2YXIxOFRaaWdmWHQ3UDY1RkJHd3FRVHR4UW9RUG5HI3o2TWtmSEJObWM0Y0NoTnREdmFyMThUWmlnZlh0N1A2NUZCR3dxUVR0eFFvUVBuRyJ9.eyJpc3MiOiJkaWQ6a2V5Ono2TWtmSEJObWM0Y0NoTnREdmFyMThUWmlnZlh0N1A2NUZCR3dxUVR0eFFvUVBuRyIsInN1YiI6ImRpZDprZXk6ejZNa2ZIQk5tYzRjQ2hOdER2YXIxOFRaaW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