|
1 | 1 | # VC JSON Schema Test Suite
|
2 | 2 |
|
3 | 3 | Test suite for the [VC JSON Schema](https://github.com/w3c/vc-json-schema/) specification in the W3C.
|
| 4 | + |
| 5 | +The suite makes use Digital Bazaar's [mocha-w3c-interop-reporter](https://github.com/digitalbazaar/mocha-w3c-interop-reporter). |
| 6 | + |
| 7 | +## Building & Testing |
| 8 | + |
| 9 | +To build and test the suite, run the following commands: |
| 10 | + |
| 11 | +```bash |
| 12 | +npm install |
| 13 | +npm test |
| 14 | +``` |
| 15 | + |
| 16 | +You can remove all generated test cases by running: |
| 17 | + |
| 18 | +```bash |
| 19 | +npm clean |
| 20 | +``` |
| 21 | + |
| 22 | +A report will be generated to the [reports](reports) directory after a successful run. |
| 23 | + |
| 24 | +## Implementations |
| 25 | + |
| 26 | +Implementations are tested on two dimensions: support for defined types (`JsonSchema` and `JsonSchemaCredential`), and |
| 27 | +support for specified JSON Schema versions (`Draft-7`, `2019-09`, and `2020-12`). |
| 28 | + |
| 29 | +### How Implementations Work |
| 30 | +Implementations are run using [docker compose](https://docs.docker.com/compose/). Each container is called once |
| 31 | +per test case. The container is expected take the following inputs: |
| 32 | + |
| 33 | +* `format` - either `JsonSchema` or `JsonSchemaCredential` |
| 34 | +* `schema` - a path to the input schema file |
| 35 | +* `credential` - a path to the input credential file |
| 36 | +* `output` - a path to where the container will write an output |
| 37 | + |
| 38 | +An example command for a container that takes the above inputs would be: |
| 39 | + |
| 40 | +```bash |
| 41 | +docker-compose -f ./implementations/docker-compose.yml \ |
| 42 | + run -d tbd validate \ |
| 43 | + --format JsonSchemaCredential \ |
| 44 | + --schema /tests/input/jsonschemacredential/Draft-7/11-schema.json \ |
| 45 | + --credential /tests/input/jsonschemacredential/Draft-7/1-credential.json \ |
| 46 | + --output /tests/output/jsonschemacredential/Draft-7/18-tbd.json |
| 47 | +``` |
| 48 | + |
| 49 | +### Adding an Implementation |
| 50 | + |
| 51 | +To add an implementation to the test suite, add a new entry to the `implementations` array in `implementations.json`. |
| 52 | +The entry should have the following properties: `name` and `specs`, where `specs` is an object with the supported |
| 53 | +[JSON Schema versions](https://json-schema.org/) as keys and an array of supported |
| 54 | +[VC JSON Schema Types](https://w3c.github.io/vc-json-schema/#data-model) as values. |
| 55 | + |
| 56 | +```json |
| 57 | +{ |
| 58 | + "name": "sample", |
| 59 | + "specs": { |
| 60 | + "2020-12": [ |
| 61 | + "JsonSchema", |
| 62 | + "JsonSchemaCredential" |
| 63 | + ], |
| 64 | + "2019-09": [ |
| 65 | + "JsonSchema", |
| 66 | + "JsonSchemaCredential" |
| 67 | + ], |
| 68 | + "Draft-7": [ |
| 69 | + "JsonSchema", |
| 70 | + "JsonSchemaCredential" |
| 71 | + ] |
| 72 | + } |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +Next, you'll need to add a new entry for the implementation in the [`docker-compose.yml`](implementations/docker-compose.yml) |
| 77 | +file. You may optionally add a directory to the [`implementations`](implementations) directory with the same name as the |
| 78 | +implementation which houses the implementation's code. |
0 commit comments