@mojaloop/ml-testing-toolkit-client-lib 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +4 -3
- package/audit-ci.jsonc +9 -2
- package/package.json +9 -9
- package/src/client.js +1 -0
- package/src/modes/outbound.js +27 -1
- package/src/router.js +1 -0
- package/src/utils/templateGenerator.js +1 -1
- package/test/unit/outbound-mode.test.js +40 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.2.0](https://github.com/mojaloop/ml-testing-toolkit-client-lib/compare/v1.1.1...v1.2.0) (2023-03-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mojaloop/#3133:** add option to specify report name saved to TTK backend ([#6](https://github.com/mojaloop/ml-testing-toolkit-client-lib/issues/6)) ([8043e4f](https://github.com/mojaloop/ml-testing-toolkit-client-lib/commit/8043e4fb5a94972c8dae7cd6f25b303e5fce275c)), closes [mojaloop/#3133](https://github.com/mojaloop/project/issues/3133)
|
|
11
|
+
|
|
5
12
|
### [1.1.1](https://github.com/mojaloop/ml-testing-toolkit-client-lib/compare/v1.1.0...v1.1.1) (2022-12-15)
|
|
6
13
|
|
|
7
14
|
## [1.1.0](https://github.com/mojaloop/ml-testing-toolkit-client-lib/compare/v1.0.0...v1.1.0) (2022-12-15)
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ ml-ttk-cli
|
|
|
62
62
|
|
|
63
63
|
The help screen allows you to see the usage, possible options and default values
|
|
64
64
|
|
|
65
|
-
command:
|
|
65
|
+
command:
|
|
66
66
|
|
|
67
67
|
```
|
|
68
68
|
ml-ttk-cli -h
|
|
@@ -81,10 +81,11 @@ Options:
|
|
|
81
81
|
-i, --input-files <inputFiles> csv list of json files or directories; required when the mode is "outbound" --- supported formats: "json"
|
|
82
82
|
-e, --environment-file <environmentFile> required when the mode is "outbound" --- supported formats: "json"
|
|
83
83
|
-s, --save-report <saveReport> To save the report on TTK backend server. default: false --- supported values: "false/true"
|
|
84
|
+
-n, --report-name <reportName> Specify the name of report on TTK backend server.
|
|
84
85
|
--save-report-base-url <saveReportBaseUrl> Incase if the base-url is not accessible publicly, this option replaces the base URL in the report URLs published in console log and slack messages default: same as base-url
|
|
85
86
|
--report-format <reportFormat> default: "json" --- supported formats: "json", "html", "printhtml"
|
|
86
87
|
--report-auto-filename-enable <reportAutoFilenameEnable> default: false, if true the file name will be generated by the backend
|
|
87
|
-
--report-target <reportTarget> default: "file://<
|
|
88
|
+
--report-target <reportTarget> default: "file://<file_name_generated_by_backend>" --- supported targets: "file://path_to_file", "s3://<bucket_name>[/<file_path>]"
|
|
88
89
|
--slack-webhook-url <slackWebhookUrl> default: "Disabled" --- supported formats: "https://....."
|
|
89
90
|
-h, --help output usage information
|
|
90
91
|
|
|
@@ -146,7 +147,7 @@ You could Send Transfer from postman or execute outbound mode with an example fr
|
|
|
146
147
|
|
|
147
148
|
This sections will enable you to intiate requests from the cli to your DFSP implementation.
|
|
148
149
|
|
|
149
|
-
The user can create a collection of operations and add a number of assertions to these operations. The assertions can be setup and customized to support your testing requirements and verify both positive and negative requests and responses.
|
|
150
|
+
The user can create a collection of operations and add a number of assertions to these operations. The assertions can be setup and customized to support your testing requirements and verify both positive and negative requests and responses.
|
|
150
151
|
|
|
151
152
|
#### Default values
|
|
152
153
|
|
package/audit-ci.jsonc
CHANGED
|
@@ -3,5 +3,12 @@
|
|
|
3
3
|
// audit-ci supports reading JSON, JSONC, and JSON5 config files.
|
|
4
4
|
// Only use one of ["low": true, "moderate": true, "high": true, "critical": true]
|
|
5
5
|
"moderate": true,
|
|
6
|
-
"allowlist": [
|
|
7
|
-
|
|
6
|
+
"allowlist": [
|
|
7
|
+
// @mojaloop/sdk-standard-components>jsonwebtoken
|
|
8
|
+
"GHSA-hjrf-2m68-5959",
|
|
9
|
+
"GHSA-qwph-4952-7xr6",
|
|
10
|
+
"GHSA-8cf7-32gw-wr33",
|
|
11
|
+
// request-promise-native>request-promise-core>request
|
|
12
|
+
"GHSA-p8p7-x288-28g6"
|
|
13
|
+
]
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/ml-testing-toolkit-client-lib",
|
|
3
3
|
"description": "Testing Toolkit Client Library",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Vijaya Kumar Guthi, ModusBox Inc. ",
|
|
7
7
|
"contributors": [
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"@mojaloop/sdk-standard-components": "17.1.1",
|
|
67
67
|
"@slack/webhook": "^6.1.0",
|
|
68
68
|
"atob": "2.1.2",
|
|
69
|
-
"aws-sdk": "^2.
|
|
70
|
-
"axios": "^1.
|
|
69
|
+
"aws-sdk": "^2.1337.0",
|
|
70
|
+
"axios": "^1.3.4",
|
|
71
71
|
"cli-table3": "0.6.3",
|
|
72
|
-
"commander": "
|
|
72
|
+
"commander": "10.0.0",
|
|
73
73
|
"dotenv": "^16.0.3",
|
|
74
74
|
"fs": "0.0.1-security",
|
|
75
75
|
"lodash": "^4.17.21",
|
|
@@ -81,18 +81,18 @@
|
|
|
81
81
|
"rc": "1.2.8",
|
|
82
82
|
"request": "^2.88.2",
|
|
83
83
|
"request-promise-native": "1.0.8",
|
|
84
|
-
"socket.io-client": "^4.
|
|
84
|
+
"socket.io-client": "^4.6.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"audit-ci": "^6.
|
|
88
|
-
"jest": "^29.
|
|
87
|
+
"audit-ci": "^6.6.1",
|
|
88
|
+
"jest": "^29.5.0",
|
|
89
89
|
"jest-junit": "^15.0.0",
|
|
90
|
-
"npm-check-updates": "16.
|
|
90
|
+
"npm-check-updates": "16.7.12",
|
|
91
91
|
"nyc": "^15.1.0",
|
|
92
92
|
"parse-strings-in-object": "1.6.0",
|
|
93
93
|
"pre-commit": "1.2.2",
|
|
94
94
|
"replace": "^1.2.2",
|
|
95
|
-
"sinon": "15.0.
|
|
95
|
+
"sinon": "15.0.2",
|
|
96
96
|
"standard": "^17.0.0",
|
|
97
97
|
"standard-version": "^9.5.0"
|
|
98
98
|
},
|
package/src/client.js
CHANGED
|
@@ -34,6 +34,7 @@ program
|
|
|
34
34
|
.option('-l, --log-level <logLevel>', 'default: 0 --- supported levels: "0-Show only requests and assertion counts, 1-Show failed assertions only, 2-Show all assertions"')
|
|
35
35
|
.option('-b, --break-run-on-error <breakRunOnError>', 'default: false --- supported values: "false/true"')
|
|
36
36
|
.option('-s, --save-report <saveReport>', 'To save the report on TTK backend server. default: false --- supported values: "false/true"')
|
|
37
|
+
.option('-n, --report-name <reportName>', 'Specify the name of report on TTK backend server. default: "test_run"')
|
|
37
38
|
.option('--save-report-base-url <saveReportBaseUrl>', 'Incase if the base-url is not accessible publicly, this option replaces the base URL in the report URLs published in console log and slack messages default: same as base-url. default: same as base-url')
|
|
38
39
|
.option('--labels <labels>', 'csv list of labels, examples: "p2p,settlements,quotes"')
|
|
39
40
|
.option('--report-format <reportFormat>', 'default: "none" --- supported formats: "none", "json", "html", "printhtml"')
|
package/src/modes/outbound.js
CHANGED
|
@@ -60,6 +60,30 @@ const printTotalProgressCounts = () => {
|
|
|
60
60
|
process.stdout.write(progressStr)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
const determineTemplateName = (paths) => {
|
|
64
|
+
let templateName
|
|
65
|
+
// Find folders based on string format
|
|
66
|
+
const folders = paths.filter(x => x.slice((x.lastIndexOf('.') - 1 >>> 0) + 2) === '')
|
|
67
|
+
const config = objectStore.get('config')
|
|
68
|
+
if (config.reportName) {
|
|
69
|
+
templateName = config.reportName
|
|
70
|
+
} else if (paths.length === 1) {
|
|
71
|
+
// Sanitize file path for a suitable name
|
|
72
|
+
templateName = paths[0]
|
|
73
|
+
.replace(/\.[^/.]+$/, '') // Remove extension
|
|
74
|
+
.replace(/^.+\.\//, '') // Remove relative paths
|
|
75
|
+
.replace(/\\|\//g, '_') // Convert path to snake case
|
|
76
|
+
// Ensure when a single folder is selected that all files belong to that folder
|
|
77
|
+
} else if (folders.length === 1 && paths.every(filePath => filePath.includes(folders[0]))) {
|
|
78
|
+
templateName = folders[0]
|
|
79
|
+
.replace(/^.+\.\//, '') // Remove relative paths
|
|
80
|
+
.replace(/\\|\//g, '_') // Convert path to snake case
|
|
81
|
+
} else {
|
|
82
|
+
templateName = 'test_run'
|
|
83
|
+
}
|
|
84
|
+
return templateName
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
const printProgress = (progress) => {
|
|
64
88
|
const config = objectStore.get('config')
|
|
65
89
|
switch (config.logLevel) {
|
|
@@ -127,6 +151,7 @@ const sendTemplate = async (sessionId) => {
|
|
|
127
151
|
const template = await TemplateGenerator.generateTemplate(inputFiles, selectedLabels)
|
|
128
152
|
template.inputValues = JSON.parse(await readFileAsync(config.environmentFile, 'utf8')).inputValues
|
|
129
153
|
template.saveReport = config.saveReport
|
|
154
|
+
template.name = determineTemplateName(inputFiles)
|
|
130
155
|
|
|
131
156
|
template.test_cases.forEach(testCase => {
|
|
132
157
|
totalProgress.totalTestCases++
|
|
@@ -189,5 +214,6 @@ const handleIncomingProgress = async (progress) => {
|
|
|
189
214
|
|
|
190
215
|
module.exports = {
|
|
191
216
|
sendTemplate,
|
|
192
|
-
handleIncomingProgress
|
|
217
|
+
handleIncomingProgress,
|
|
218
|
+
determineTemplateName
|
|
193
219
|
}
|
package/src/router.js
CHANGED
|
@@ -52,6 +52,7 @@ const cli = (commanderOptions) => {
|
|
|
52
52
|
breakRunOnError: commanderOptions.breakRunOnError || configFile.breakRunOnError,
|
|
53
53
|
saveReport: commanderOptions.saveReport || configFile.saveReport,
|
|
54
54
|
saveReportBaseUrl: commanderOptions.saveReportBaseUrl || configFile.saveReportBaseUrl,
|
|
55
|
+
reportName: commanderOptions.reportName,
|
|
55
56
|
environmentFile: commanderOptions.environmentFile,
|
|
56
57
|
reportFormat: commanderOptions.reportFormat || configFile.reportFormat,
|
|
57
58
|
reportAutoFilenameEnable: commanderOptions.reportAutoFilenameEnable === 'true' || configFile.reportAutoFilenameEnable === true,
|
|
@@ -52,7 +52,7 @@ const generateTemplate = async (inputFiles, selectedLabels = null) => {
|
|
|
52
52
|
FolderParser.sequenceTestCases(testCases)
|
|
53
53
|
const template = {}
|
|
54
54
|
template.test_cases = testCases
|
|
55
|
-
template.name = '
|
|
55
|
+
template.name = 'test_run'
|
|
56
56
|
return template
|
|
57
57
|
} catch (err) {
|
|
58
58
|
console.log(err)
|
|
@@ -189,4 +189,44 @@ describe('Cli client', () => {
|
|
|
189
189
|
await expect(outbound.sendTemplate()).resolves.toBe(undefined)
|
|
190
190
|
})
|
|
191
191
|
})
|
|
192
|
+
describe('run determineTemplateName', () => {
|
|
193
|
+
it('when determineTemplateName is given a list with a single file it should use the file as the template name', () => {
|
|
194
|
+
const paths = ['sample-cli.json']
|
|
195
|
+
const name = outbound.determineTemplateName(paths)
|
|
196
|
+
expect(name).toBe('sample-cli')
|
|
197
|
+
})
|
|
198
|
+
it('when determineTemplateName is given a list with a single file path it converts to snakecase', () => {
|
|
199
|
+
const paths = ['docs/sample-cli.json']
|
|
200
|
+
const name = outbound.determineTemplateName(paths)
|
|
201
|
+
expect(name).toBe('docs_sample-cli')
|
|
202
|
+
})
|
|
203
|
+
it('when determineTemplateName is given a list with a relative path it is santitized', () => {
|
|
204
|
+
const paths = ['../sample-cli.json']
|
|
205
|
+
const name = outbound.determineTemplateName(paths)
|
|
206
|
+
expect(name).toBe('sample-cli')
|
|
207
|
+
})
|
|
208
|
+
it('when determineTemplateName is given a list with a single folder and the children', () => {
|
|
209
|
+
const paths = ['docs' , 'docs/sample-cli.json']
|
|
210
|
+
const name = outbound.determineTemplateName(paths)
|
|
211
|
+
expect(name).toBe('docs')
|
|
212
|
+
})
|
|
213
|
+
it('when determineTemplateName is run with cli flag reportName set the template sets that name', () => {
|
|
214
|
+
const paths = ['docs' , 'docs/sample-cli.json']
|
|
215
|
+
const config = {
|
|
216
|
+
reportName: "my-test-report",
|
|
217
|
+
}
|
|
218
|
+
objectStore.set('config', config)
|
|
219
|
+
|
|
220
|
+
const name = outbound.determineTemplateName(paths)
|
|
221
|
+
expect(name).toBe('my-test-report')
|
|
222
|
+
})
|
|
223
|
+
it('when determineTemplateName is run with no reportName set and mixture of files and folder paths', () => {
|
|
224
|
+
const paths = ['docs' , 'docs/sample-cli.json', 'next-test.json']
|
|
225
|
+
const config = {}
|
|
226
|
+
objectStore.set('config', config)
|
|
227
|
+
|
|
228
|
+
const name = outbound.determineTemplateName(paths)
|
|
229
|
+
expect(name).toBe('test_run')
|
|
230
|
+
})
|
|
231
|
+
})
|
|
192
232
|
})
|