This repository contains the W3C Verifiable Credentials Working Group test suite. Any conforming implementation MUST pass all tests in the test suite.
There are multiple test suites, each of which is detailed below.
You can review the current draft implementation report.
This test suite will check any application that generates Verifiable Credential Data Model documents to ensure conformance with the specification.
npm install
cp config.json.example config.json
- Modify
config.json
for your run (be sure to remove all comments) npm test
If your tests are timing out (for example, it takes a long time to generate
needed keys), you can use the --timeout
parameter in mocha, and pass in a
higher timeout (in milliseconds). For example, to increase the timeout for
each test to 10 seconds, you would:
npm test -- --timeout 10000
or when generating the report:
mocha --recursive --timeout 10000 test/vc-data-model-1.0/ -R json > implementations/report.json
If your tests fail with the following error:
TypeError: Cannot read property 'es256kPrivateKeyJwk' of undefined
This means that you need to do one of:
- Configure the JWT keys (see the JWT Test Configuration section below)
- Mark the JWT section as not supported, by adding
"sectionsNotSupported": ["jwt"]
toyour config.json
.
For example, the config for the vc-js
implementation is below:
{
"generator": "../vc-js/bin/vc-js test-issue < ",
"presentationGenerator": "../vc-js/bin/vc-js test-presentation <",
"generatorOptions": "",
"sectionsNotSupported": ["jwt", "zkp"]
}
This tells the test harness several things:
- Use the
../vc-js/
implementation directory (you should substitute the path to your own) - Exclude the JWT and ZKP sections (since this particular implementation does not yet have support for those)
For a more in-depth discussion of how the test suite works, see this comment on issue #14.
The following are the command line parameters that JWT generators have to expect (in addition to the filename/path):
Cmd Line Parameter | Description |
---|---|
--jwt <base64-encoded-keys> |
Generators can choose between RS256 and ES256K private keys to generate JWS for verifiable credentials and presentations. contains a base64encoded JSON object containing es256kPrivateKeyJwk and rs256PrivateKeyJwk. |
--jwt-aud <aud> |
Generators have to use <aud> as the aud attribute in all JWTs |
--jwt-no-jws |
Generators have to suppress the JWS although keys are present |
--jwt-presentation |
Generators have to generate a verifiable presentation |
--jwt-decode |
Generators have to generate a credential from a JWT verifiable credential. The input file will be a JWT instead of a JSON-LD file. |
JWT tests belong to any of the following three categories:
- generate (encode) a JWT W3C verifiable credential from a JSON-LD W3C credential (.jsonld file). The following parameters are used:
Cmd Line Parameter | Optional |
---|---|
--jwt <base64-encoded-keys> |
no |
--jwt-aud <aud> |
no |
--jwt-no-jws |
yes |
- generate (encode) a JWT W3C verifiable presentation from a JSON-LD W3C credential (.jsonld file). The generator will have to create a JWT verifiable credential first and then put the verifiable credential into the JWT verifiable presentation (as shown in Example 31). The following command line parameter are used:
Cmd Line Parameter | Optional |
---|---|
--jwt <base64-encoded-keys> |
no |
--jwt-aud <aud> |
no |
--jwt-presentation |
yes |
- generate (decode) a JSON-LD W3C credential from a JWT W3C verifiable credential (.jwt).
Cmd Line Parameter | Optional |
---|---|
--jwt-decode |
no |
NOTE: the command line parameters will be provided by the JWT tests based on the configuration in config.json
.
See config.json.example
for all possible JWT specific config parameters, and see config.json.jwt.example
for an example
JWT configuration.
npm install
cp config.json.example config.json
- Modify
config.json
for your run. mocha --recursive --timeout 10000 test/vc-data-model-1.0/ -R json > implementations/report.json
mv implementations/report.json implementations/{YOUR_IMPLEMENTATION}-report.json
git add implementations/{YOUR_IMPLEMENTATION}-report.json
node implementations/generate.js
- Submit a pull request for your implementation.
You may contribute to this test suite by submitting pull requests here:
https://github.com/w3c/vc-test-suite/
New BSD License (3-clause) © Digital Bazaar