Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localConfig instructions. #46

Merged
merged 7 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ reports/**
credentials/*.json
.vscode
.localImplementationsConfig.cjs
localConfig.cjs
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed
- `respecConfig.json` is now `config/respec.json`.
- `abstract.hbs` is now `config/abstract.hbs`.
- `localImplementationsConfig.cjs` is now `localConfig.cjs`

### Added
- Add `config/runner.json` for configuring the tag used for the suite.
Expand Down
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,47 +86,47 @@ Content-Type: application/ld+json

### Testing Locally
If you want to test implementations or just endpoints running locally, you can
copy `localImplementationsConfig.example.cjs` to `.localImplementationsConfig.cjs`
copy `localConfig.example.cjs` to `localConfig.cjs`
in the root directory of the test suite.

```bash
cp localImplementationsConfig.example.cjs .localImplementationsConfig.cjs
cp localConfig.example.cjs localConfig.cjs
```

Git is set to ignore `.localImplementationsConfig.cjs` by default.
Git is set to ignore `localConfig.cjs` by default.

This file must be a CommonJS module that exports an array of implementations:

```js
// .localImplementationsConfig.cjs defining local implementations
// .localConfig.cjs defining local implementations
// you can specify a BASE_URL before running the tests such as:
// BASE_URL=http://localhost:40443/zDdfsdfs npm test
const baseUrl = process.env.BASE_URL || 'https://localhost:40443/id';
module.exports = [{
name: 'My Company',
implementation: 'My Implementation Name',
issuers: [{
id: 'did:myMethod:implementation:issuer:id',
endpoint: `${baseUrl}/credentials/issue`,
tags: ['eddsa-rdfc-2022', 'localhost']
}],
verifiers: [{
id: 'did:myMethod:implementation:verifier:id',
endpoint: `${baseUrl}/credentials/verify`,
tags: ['eddsa-rdfc-2022', 'localhost']
}]
}];
module.exports = {
settings: {
enableInteropTests: false, // default
testAllImplementations: false // default
},
implementations: [{
name: 'My Company',
implementation: 'My Implementation Name',
issuers: [{
id: 'did:myMethod:implementation:issuer:id',
endpoint: `${baseUrl}/credentials/issue`,
supports: {
vc: ['1.1', '2.0']
},
tags: ['eddsa-rdfc-2022', 'localhost']
}],
verifiers: [{
id: 'did:myMethod:implementation:verifier:id',
endpoint: `${baseUrl}/credentials/verify`,
tags: ['eddsa-rdfc-2022', 'localhost']
}]
}];
}
```

After adding the config file, both the localhost implementations and other
implementations matching the test tag will be included in the test run.

To specifically test only the localhost implementation, modify the test suite to
filter implementations based on a specific tag in your local configuration file.

For instance, if your `.localImplementationsConfig.cjs` config file looks like
the config above, you can adjust the tag used in each test suite by modifying `./config/runner.json`
to filter the implementations by `localhost` and other tags.
To specifically test only the implementations in `localConfig.cjs`, change `settings.testAllImplementations` to `false`.
BigBlueHat marked this conversation as resolved.
Show resolved Hide resolved

### Running Specific Tests
This suite uses [mocha.js](https://mochajs.org) as the test runner.
Expand Down
32 changes: 32 additions & 0 deletions localConfig.example.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*!
* Copyright (c) 2022-2024 Digital Bazaar, Inc.
* SPDX-License-Identifier: BSD-3-Clause
*/
// Rename this file to .localConfig.cjs
// you can specify a BASE_URL before running the tests such as:
// BASE_URL=http://localhost:40443/zDdfsdfs npm test
const baseUrl = process.env.BASE_URL || 'https://localhost:34557';

module.exports = {
settings: {
enableInteropTests: false, // default
testAllImplementations: false // default
},
implementations: [{
name: 'My Company',
implementation: 'My Implementation Name',
issuers: [{
id: 'did:myMethod:implementation:issuer:id',
endpoint: `${baseUrl}/credentials/issue`,
supports: {
vc: ['1.1', '2.0']
},
tags: ['eddsa-rdfc-2022', 'localhost']
}],
verifiers: [{
id: 'did:myMethod:implementation:verifier:id',
endpoint: `${baseUrl}/credentials/verify`,
tags: ['eddsa-rdfc-2022', 'localhost']
}]
}]
};
22 changes: 0 additions & 22 deletions localImplementationsConfig.example.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"test": "mocha tests/ --reporter @digitalbazaar/mocha-w3c-interop-reporter --reporter-options abstract=\"$PWD/config/abstract.hbs\",reportDir=\"$PWD/reports\",respec=\"$PWD/config/respec.json\",suiteLog='./suite.log',templateData=\"$PWD/reports/index.json\",title=\"Data Integrity eddsa 2022 Interoperability Report 1.0\" --timeout 15000 --preserve-symlinks",
"lint": "eslint ."
"lint": "eslint --ext .js,.cjs ."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an eslint config file? These can go there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kind of surprised me, but actually I don't think there is a config file way of specifying the file extensions, but there is an eslint config file way of specifying the file glob patterns so I used that here: 40e0733

},
"author": {
"name": "W3C, Inc.",
Expand Down