Created
March 7, 2023 16:05
-
-
Save kalinchernev/a5068571530e2e6f7e7d5235a172ff6b to your computer and use it in GitHub Desktop.
`npx @mocks-server/main mocks` on yarn install and run `mocks` as documented on mocks-server.org
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
[ | |
{ | |
"id": "get-result", | |
"routes": ["get-result:get-result-actual"] | |
} | |
] |
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
// @see https://www.mocks-server.org/docs/ | |
// place in mocks/routes/logs.js | |
// Values to match conformance service query parameters for the given set of tests | |
const TI_REQUEST_VERIFIABLEAUTHORISATIONTOONBOARD_TEST = | |
"ti_request_verifiableauthorisationtoonboard_test"; | |
const TI_REQUEST_VERIFIABLEACCREDITATIONTOATTEST_TEST = | |
"ti_request_verifiableaccreditationtoattest_test"; | |
const TI_REGISTER_VERIFIABLEACCREDITATIONTOATTEST_TEST = | |
"ti_register_verifiableaccreditationtoattest_test"; | |
const TI_ISSUE_CTREVOCABLE_TEST = "ti_issue_ctrevocable_test"; | |
const TI_VALIDATE_CTREVOCABLE_TEST = "ti_validate_ctrevocable_test"; | |
const TI_REVOKE_CTREVOCABLE_TEST = "ti_revoke_ctrevocable_test"; | |
const results = { | |
"did:ebsi:za1uULvVp78ceJLaFk4WsSN": { | |
[TI_REQUEST_VERIFIABLEAUTHORISATIONTOONBOARD_TEST]: { | |
logs: [], | |
results: { | |
status: "Success", | |
passedTests: [], | |
failedTests: [], | |
}, | |
}, | |
[TI_REQUEST_VERIFIABLEACCREDITATIONTOATTEST_TEST]: { | |
logs: [], | |
results: { | |
status: "Success", | |
passedTests: [], | |
failedTests: [], | |
}, | |
}, | |
[TI_REGISTER_VERIFIABLEACCREDITATIONTOATTEST_TEST]: { | |
logs: [], | |
results: { | |
status: "Success", | |
passedTests: [], | |
failedTests: [], | |
}, | |
}, | |
[TI_ISSUE_CTREVOCABLE_TEST]: { | |
logs: [], | |
results: { | |
status: "Success", | |
passedTests: [], | |
failedTests: [], | |
}, | |
}, | |
[TI_VALIDATE_CTREVOCABLE_TEST]: { | |
logs: [], | |
results: { | |
status: "Success", | |
passedTests: [], | |
failedTests: [], | |
}, | |
}, | |
[TI_REVOKE_CTREVOCABLE_TEST]: { | |
logs: [], | |
results: { | |
status: "Success", | |
passedTests: [], | |
failedTests: [], | |
}, | |
}, | |
}, | |
}; | |
module.exports = [ | |
{ | |
id: "get-result", | |
url: "/logs/:did", | |
method: "GET", | |
variants: [ | |
{ | |
id: "get-result-actual", | |
type: "middleware", | |
options: { | |
middleware: (req, res) => { | |
const did = req.params.did; | |
const test = req.query.test; | |
if (results[did] && results[did][test]) { | |
res.status(200); | |
res.send(results[did][test]); | |
} else { | |
res.status(404); | |
res.send(); | |
} | |
}, | |
}, | |
}, | |
], | |
}, | |
]; |
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
// For a detailed explanation regarding each configuration property, visit: | |
// https://www.mocks-server.org/docs/configuration/how-to-change-settings | |
// https://www.mocks-server.org/docs/configuration/options | |
module.exports = { | |
// Log level. Can be one of silly, debug, verbose, info, warn or error | |
//log: "info", | |
config: { | |
// Allow unknown arguments | |
//allowUnknownArguments: false, | |
}, | |
plugins: { | |
// Plugins to be registered | |
//register: [], | |
proxyRoutesHandler: { | |
}, | |
adminApi: { | |
// Port number for the admin API server to be listening at | |
//port: 3110, | |
// Host for the admin API server | |
//host: "0.0.0.0", | |
https: { | |
// Use https protocol or not | |
//enabled: false, | |
// Path to a TLS/SSL certificate | |
//cert: undefined, | |
// Path to the certificate private key | |
//key: undefined, | |
}, | |
}, | |
inquirerCli: { | |
// Start interactive CLI or not | |
//enabled: true, | |
// Render emojis or not | |
//emojis: true, | |
}, | |
openapi: { | |
collection: { | |
// Name for the collection created from OpenAPI definitions | |
//id: "openapi", | |
// Name of the collection to extend from | |
//from: undefined, | |
}, | |
}, | |
}, | |
mock: { | |
routes: { | |
// Global delay to apply to routes | |
//delay: 0, | |
}, | |
collections: { | |
// Selected collection | |
//selected: "base", | |
}, | |
}, | |
server: { | |
// Port number for the server to be listening at | |
//port: 3100, | |
// Host for the server | |
//host: "0.0.0.0", | |
cors: { | |
// Use CORS middleware or not | |
//enabled: true, | |
// Options for the CORS middleware. Further information at https://github.com/expressjs/cors#configuration-options | |
//options: {"preflightContinue":false}, | |
}, | |
jsonBodyParser: { | |
// Use json body-parser middleware or not | |
//enabled: true, | |
// Options for the json body-parser middleware. Further information at https://github.com/expressjs/body-parser | |
//options: {}, | |
}, | |
urlEncodedBodyParser: { | |
// Use urlencoded body-parser middleware or not | |
//enabled: true, | |
// Options for the urlencoded body-parser middleware. Further information at https://github.com/expressjs/body-parser | |
//options: {"extended":true}, | |
}, | |
https: { | |
// Use https protocol or not | |
//enabled: false, | |
// Path to a TLS/SSL certificate | |
//cert: undefined, | |
// Path to the certificate private key | |
//key: undefined, | |
}, | |
}, | |
files: { | |
// Allows to disable files load | |
//enabled: true, | |
// Define folder from where to load collections and routes | |
//path: "mocks", | |
// Enable/disable files watcher | |
//watch: true, | |
babelRegister: { | |
// Load @babel/register | |
//enabled: false, | |
// Options for @babel/register | |
//options: {}, | |
}, | |
}, | |
variantHandlers: { | |
// Variant Handlers to be registered | |
//register: [], | |
}, | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment