From 33778b875f97fb429f03784b353bd7d40f60cc79 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Sun, 17 Nov 2019 00:23:16 +0530 Subject: [PATCH 01/21] MASTER- recursive directories --- bin/allrounder | 4 +- extractArgs.js | 10 +- mocha-test.js | 2 +- tests/testjson/src/another/index.spec.json | 111 +++++++++++++++++++++ tests/testjson/src/reducer.spec.json | 2 +- 5 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 tests/testjson/src/another/index.spec.json diff --git a/bin/allrounder b/bin/allrounder index 149d342..bdad56e 100755 --- a/bin/allrounder +++ b/bin/allrounder @@ -21,7 +21,7 @@ if (showHelp === undefined || showHelp) { console.log(' OR to make http(s) call: '+name+' [options] -e [method=GET] https://myrestcallurl?withquery=parametersifany [headers^2] [payload^2]'); console.log(''); console.log(' Options:'); - console.log(' -r, --read [value] : Read the configuration from a json file, rather than passing from command line.^1'); + console.log(' -c, --conf [value] : Read the configuration from a json file, rather than passing from command line.^1'); console.log(' -f, --file [value] : The json file which contains the set of tests (a test suite) you want to execute.^1'); console.log(' -j, --jsondir [value] : The directory which contains the set of json files each of which is a test suite.^1'); console.log(' -b, --bail : If present, it will exit upon the first failure and ignore the rest.'); @@ -33,7 +33,7 @@ if (showHelp === undefined || showHelp) { console.log(' -o, --timeout : The timeout value that will abort testcase, if not finished in miliseconds'); console.log(' -w, --whileinterval : Miliseconds to wait for betweeen while loop iterations.'); console.log(' -t, --type [value] : What kind of test case if type if not present in testcase or testsuite.'); - console.log(' Should be on of rest,unit,db,command.'); + console.log(' Should be one of rest,unit,db,command.'); console.log(' -u, --utility [value] : The javascript filepath that will have utility functions.^1'); console.log(' It will be used for replacing method variables in test cases.'); console.log(' -s, --srcdir [value] : The source directory^1, which will be used to map the unit test file to corresponding source file'); diff --git a/extractArgs.js b/extractArgs.js index f678d3b..46668df 100644 --- a/extractArgs.js +++ b/extractArgs.js @@ -180,10 +180,10 @@ function parseArguments() { options.file = getStringValue(value, true); } break; - case '-r': - case '--read': + case '-c': + case '--conf': if (value) { - options.read = getStringValue(read, true); + options.confs = getStringValue(value, true); } break; case '-j': @@ -481,9 +481,7 @@ function afterResolve(fa) { */ exports.getOptions = function getOptions(options) { const OPTS = {}; - if (!options.read){ - const readFile = join(cwd, 'allrounder.json'); - } + const readFile = options.confs || join(cwd, 'allrounder.json'); let read = {}; try { read = require(readFile); diff --git a/mocha-test.js b/mocha-test.js index 2ac65bb..48ff1e9 100644 --- a/mocha-test.js +++ b/mocha-test.js @@ -4,6 +4,6 @@ const testFile = require('./index'); if (!options.jsondir && !options.file && !options.srcdir) { throw new Error('`jsondir` or `file` argument is a must.'); } -delete options.read; +delete options.confs; testFile.init(options,true); testFile.start(); diff --git a/tests/testjson/src/another/index.spec.json b/tests/testjson/src/another/index.spec.json new file mode 100644 index 0000000..bcfc601 --- /dev/null +++ b/tests/testjson/src/another/index.spec.json @@ -0,0 +1,111 @@ +{ + "type": "unit", + "tests" : [ + { + "summary": "Requiring the file", + "request": { + "method": "default" + }, + "assertions": { + "error.message": "Cannot read property 'type' of undefined" + } + }, + { + "require": "immutable", + "summary": "Getting first immutable object", + "request": { + "method": "fromJS", + "params": { + "todos": { + } + } + }, + "assertions": { + "error": null + }, + "extractors": { + "state": "output" + } + }, + { + "summary": "Adding an entry", + "request": { + "method": "default", + "params": [ + "{{state}}", + { + "type": "ADD", + "todo": "todo 1" + } + ] + }, + "assertions": { + "error": null, + "output.size": 2, + "output._root.entries.0.1.size": 1 + }, + "extractors": { + "todo1Id": "output._root.entries.1.1" + } + }, + { + "summary": "Updating an entry", + "request": { + "method": "default", + "params": [ + "{{state}}", + { + "type": "EDIT", + "id": "{{todo1Id}}", + "patch": { + "todo": "todo 1" + } + } + ] + }, + "assertions": { + "error": null, + "output._root.entries.0.1._root.entries.0.1.todo": "todo 1" + } + }, + { + "summary": "Deleting an entry", + "request": { + "method": "default", + "params": [ + "{{state}}", + { + "type": "DELETE", + "id": "{{todo1Id}}" + } + ] + }, + "assertions": { + "error": null, + "output.size": 1, + "output._root.entries.0.1.size": 0 + } + }, + { + "import": "reducer", + "steps": 2 + }, + { + "summary": "Deleting all", + "request": { + "method": "default", + "params": [ + "{{state}}", + { + "type": "DELETE_ALL" + } + ] + }, + "assertions": { + "error": null, + "output.size": 1, + "output._root.entries.0.1.size": 0 + } + } + ] +} diff --git a/tests/testjson/src/reducer.spec.json b/tests/testjson/src/reducer.spec.json index fff338d..bcfc601 100644 --- a/tests/testjson/src/reducer.spec.json +++ b/tests/testjson/src/reducer.spec.json @@ -7,7 +7,7 @@ "method": "default" }, "assertions": { - "error": {} + "error.message": "Cannot read property 'type' of undefined" } }, { From 9c326bd334365eb58d1ced67587996e9dbf02ec7 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Sun, 17 Nov 2019 00:25:27 +0530 Subject: [PATCH 02/21] MASTER- fixed version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d2aa93..43fd605 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.7.0", + "version": "0.7.1", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 98babd228bc6a559b7129d3ed2c68516ff2ee80d Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Sun, 15 Dec 2019 22:28:21 +0530 Subject: [PATCH 03/21] MASTER- upgrading mocha --- package.json | 4 ++-- types/unit/index.js | 1 + utils.js | 26 ++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 43fd605..4ec2d10 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.7.1", + "version": "0.7.2", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -29,6 +29,6 @@ "dependencies": { "json2server": "latest", "jsonpath": "^1.0.0", - "mocha": "^4.1.0" + "mocha": "^6.2.2" } } diff --git a/types/unit/index.js b/types/unit/index.js index a3bdae4..0d63511 100644 --- a/types/unit/index.js +++ b/types/unit/index.js @@ -77,6 +77,7 @@ module.exports = function forTC(OPTS, test, fileData, done, noti) { } else { unit = global; } + if (typeof reqObj.method !== 'string') return callback({ error: null, output: true }) const method = OPTS.jsonquery(unit, OPTS.replace(reqObj.method, vars, methods)); let payload = (reqObj.payload === undefined) ? [] : OPTS.replace(reqObj.payload, vars, methods); if (!Array.isArray(payload)) { payload = [payload]; } diff --git a/utils.js b/utils.js index e373ee2..f214fce 100644 --- a/utils.js +++ b/utils.js @@ -60,22 +60,20 @@ exports.cropString = function cropString(str, ln = 100) { exports.jsonquery = function jsonquery(data, path) { let res = data; - if (typeof data === 'object' && data !== null) { - if (path.indexOf('LEN()<') === 0) { - return jsonpath.query(data, path.substring(6)).length; - } else if(typeof path === 'string' && path.indexOf('TYPEOF<') === 0) { - return (typeof jsonpath.query(data, path.substring(7))[0]); - } else if (path.indexOf('ARRAY<') === 0) { - return jsonpath.query(data, path.substring(6)); - } else if (path.indexOf('<') === 5) { - const count = parseInt(path.substr(0, 5), 10); - if (!isNaN(count)) { - return jsonpath.query(data, path.substring(6), count); - } + if (path.indexOf('LEN()<') === 0) { + return jsonpath.query(data, path.substring(6)).length; + } else if(typeof path === 'string' && path.indexOf('TYPEOF<') === 0) { + return (typeof jsonpath.query(data, path.substring(7))[0]); + } else if (path.indexOf('ARRAY<') === 0) { + return jsonpath.query(data, path.substring(6)); + } else if (path.indexOf('<') === 5) { + const count = parseInt(path.substr(0, 5), 10); + if (!isNaN(count)) { + return jsonpath.query(data, path.substring(6), count); } - res = jsonpath.query(data, path, 1); - res = (Array.isArray(res) && res.length < 2) ? res[0] : res; } + res = jsonpath.query(data, path, 1); + res = (Array.isArray(res) && res.length < 2) ? res[0] : res; return res; }; From 6c22d3122ba99bc0030359817003dc890301e2df Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Thu, 19 Dec 2019 13:23:37 +0530 Subject: [PATCH 04/21] MASTER- correct test suite path instead of index --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 65214ff..67d8f5e 100644 --- a/index.js +++ b/index.js @@ -216,7 +216,7 @@ exports.start = function start(){ } OPTS.fileArray.forEach((fileData) => { if (!fileData[1].disabled && (!OPTS.file || OPTS.file === fileData[0])) { - describe(fileData[1].testsuite || fileData[1].scenario || basename(fileData[0].split('.').shift()), function(){ + describe(fileData[1].testsuite || fileData[1].scenario || fileData[0].split(OPTS.jsondir)[1], function(){ exports.forTS.call(this, fileData); }); } From 0ce68b0bfd022d12d1ad212c583c6d27e719ba08 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Fri, 28 Feb 2020 12:41:36 +0530 Subject: [PATCH 05/21] MASTER- inc mocha version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4ec2d10..a15bf61 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.7.2", + "version": "0.8.0", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -29,6 +29,6 @@ "dependencies": { "json2server": "latest", "jsonpath": "^1.0.0", - "mocha": "^6.2.2" + "mocha": "^7.1.0" } } From 13b0ccdf49e7510af4794eed68cd083ec7132554 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Sun, 8 Mar 2020 23:05:34 +0530 Subject: [PATCH 06/21] MASTER- updateRequire fix --- extractArgs.js | 13 ++++++++----- types/unit/index.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/extractArgs.js b/extractArgs.js index 46668df..4b1a51a 100644 --- a/extractArgs.js +++ b/extractArgs.js @@ -370,6 +370,7 @@ function getArp(fn) { } function getTests(fl) { + if (!fl.type && fl.require) fl.type = 'unit' return fl.tests || fl.testcases || fl.steps || fl.entries || fl.records; } @@ -384,9 +385,10 @@ function getNthActiveElement(ar, ind, retInd) { } } -function createNewStep(og, ae) { +function createNewStep(require, og, ae) { if (typeof ae !== 'object' || ae === null || typeof og !== 'object' || og === null) return ae; return Object.assign(ae, { + require: require, neg: ae.neg === undefined ? og.neg : ae.neg, condition: ae.condition === undefined ? og.condition : (og.condition ? `(${og.condition}) && (${ae.condition})` : ae.condition), }); @@ -400,6 +402,7 @@ function resolveJson (vars, replace, fa) { for (let z = 0; z < ln; z++) { const steps = tests[z].steps; if (typeof tests[z].import === 'string' && !replace(tests[z].disabled, Object.assign(fl.vars || {}, vars), globalMethods)) { + let fixRequire = tests[z].require || (fl.type === 'unit' ? tests[z].import : undefined) if (!tests[z].import.endsWith('.json')) { tests[z].import += (options.srcdir ? ('.'+options.speckey) : '') + '.json'; } @@ -427,7 +430,7 @@ function resolveJson (vars, replace, fa) { if (Array.isArray(steps)) { steps.forEach(st => { if (typeof st === 'number' && ar[st]) { - let toPush = createNewStep(tests[z], getNthActiveElement(ar, st)); + let toPush = createNewStep(fixRequire, tests[z], getNthActiveElement(ar, st)); if (toPush) art.push(toPush); } }); @@ -436,17 +439,17 @@ function resolveJson (vars, replace, fa) { let ffrom = getNthActiveElement(ar, steps.from || 0, true); let fto = typeof steps.to !== 'number' ? ar.length - 1 : getNthActiveElement(ar, steps.to, true); for (let st = ffrom; ar[st] && st <= fto; st++) { - let toPush = createNewStep(tests[z], ar[st]); + let toPush = createNewStep(fixRequire, tests[z], ar[st]); if (toPush) art.push(toPush); } } else if (typeof steps === 'number' && ar[steps]) { - toPush = createNewStep(tests[z], getNthActiveElement(ar, steps)); + const toPush = createNewStep(fixRequire, tests[z], getNthActiveElement(ar, steps)); if (toPush) art.push(toPush); } ar = art; tests.splice.bind(tests, z, 1).apply(tests, ar); } else { - tests.splice.bind(tests, z, 1).apply(tests, ar.map(createNewStep.bind(null, tests[z]))); + tests.splice.bind(tests, z, 1).apply(tests, ar.map(createNewStep.bind(null, fixRequire, tests[z]))); } if (preVars && tests[z]) tests[z].vars = Object.assign(preVars, tests[z].vars); ln += ar.length - 1; diff --git a/types/unit/index.js b/types/unit/index.js index 0d63511..9e6a716 100644 --- a/types/unit/index.js +++ b/types/unit/index.js @@ -62,7 +62,7 @@ module.exports = function forTC(OPTS, test, fileData, done, noti) { unit = require(path); } else { try { - unit = require(require.resolve(path, { paths : [OPTS.jsondir] })); + unit = require(join(OPTS.jsondir, path)); } catch (er) { try { unit = require(path); From 2faf310ca47288ffc52eeb31c4bbe0a7399f73b0 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 9 Mar 2020 01:49:55 +0530 Subject: [PATCH 07/21] MASTER- fixing the require in units --- extractArgs.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/extractArgs.js b/extractArgs.js index 4b1a51a..feed6fd 100644 --- a/extractArgs.js +++ b/extractArgs.js @@ -385,13 +385,14 @@ function getNthActiveElement(ar, ind, retInd) { } } -function createNewStep(require, og, ae) { +function createNewStep(prefixedObject, og, ae) { if (typeof ae !== 'object' || ae === null || typeof og !== 'object' || og === null) return ae; - return Object.assign(ae, { - require: require, + return Object.assign({}, ae, { neg: ae.neg === undefined ? og.neg : ae.neg, + summary: prefixedObject.summaryPrefix ? prefixedObject.summaryPrefix + ' > ' + (ae.summary || ae.import) : ae.summary, + require: ae.require || ae.import || prefixedObject.fixRequire, condition: ae.condition === undefined ? og.condition : (og.condition ? `(${og.condition}) && (${ae.condition})` : ae.condition), - }); + }) } function resolveJson (vars, replace, fa) { @@ -402,10 +403,12 @@ function resolveJson (vars, replace, fa) { for (let z = 0; z < ln; z++) { const steps = tests[z].steps; if (typeof tests[z].import === 'string' && !replace(tests[z].disabled, Object.assign(fl.vars || {}, vars), globalMethods)) { - let fixRequire = tests[z].require || (fl.type === 'unit' ? tests[z].import : undefined) + const fixRequire = tests[z].require || (fl.type === 'unit' ? tests[z].import : undefined) + const summaryPrefix = tests[z].summary || tests[z].import if (!tests[z].import.endsWith('.json')) { tests[z].import += (options.srcdir ? ('.'+options.speckey) : '') + '.json'; } + const prefixedObject = { fixRequire, summaryPrefix } let arp = getArp(isAbsolute(tests[z].import) ? tests[z].import : join(dirname(fa[0]), tests[z].import)); let ar = JSON.parse(arp[3]); if (tests[z].fetchVars !== false) { @@ -430,7 +433,7 @@ function resolveJson (vars, replace, fa) { if (Array.isArray(steps)) { steps.forEach(st => { if (typeof st === 'number' && ar[st]) { - let toPush = createNewStep(fixRequire, tests[z], getNthActiveElement(ar, st)); + let toPush = createNewStep(prefixedObject, tests[z], getNthActiveElement(ar, st)); if (toPush) art.push(toPush); } }); @@ -439,17 +442,17 @@ function resolveJson (vars, replace, fa) { let ffrom = getNthActiveElement(ar, steps.from || 0, true); let fto = typeof steps.to !== 'number' ? ar.length - 1 : getNthActiveElement(ar, steps.to, true); for (let st = ffrom; ar[st] && st <= fto; st++) { - let toPush = createNewStep(fixRequire, tests[z], ar[st]); + let toPush = createNewStep(prefixedObject, tests[z], ar[st]); if (toPush) art.push(toPush); } } else if (typeof steps === 'number' && ar[steps]) { - const toPush = createNewStep(fixRequire, tests[z], getNthActiveElement(ar, steps)); + const toPush = createNewStep(prefixedObject, tests[z], getNthActiveElement(ar, steps)); if (toPush) art.push(toPush); } ar = art; tests.splice.bind(tests, z, 1).apply(tests, ar); } else { - tests.splice.bind(tests, z, 1).apply(tests, ar.map(createNewStep.bind(null, fixRequire, tests[z]))); + tests.splice.bind(tests, z, 1).apply(tests, ar.map(createNewStep.bind(null, prefixedObject, tests[z]))); } if (preVars && tests[z]) tests[z].vars = Object.assign(preVars, tests[z].vars); ln += ar.length - 1; From 21160b05664980e0b02e48c1a47d37cf341798aa Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 9 Mar 2020 18:02:30 +0530 Subject: [PATCH 08/21] MASTER- fixing the arrow --- extractArgs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extractArgs.js b/extractArgs.js index feed6fd..4ae7c0f 100644 --- a/extractArgs.js +++ b/extractArgs.js @@ -389,7 +389,7 @@ function createNewStep(prefixedObject, og, ae) { if (typeof ae !== 'object' || ae === null || typeof og !== 'object' || og === null) return ae; return Object.assign({}, ae, { neg: ae.neg === undefined ? og.neg : ae.neg, - summary: prefixedObject.summaryPrefix ? prefixedObject.summaryPrefix + ' > ' + (ae.summary || ae.import) : ae.summary, + summary: prefixedObject.summaryPrefix ? prefixedObject.summaryPrefix + ' => ' + (ae.summary || ae.import) : ae.summary, require: ae.require || ae.import || prefixedObject.fixRequire, condition: ae.condition === undefined ? og.condition : (og.condition ? `(${og.condition}) && (${ae.condition})` : ae.condition), }) From c9095f2a9d787f0b1983cbe20bcedfe11212b15a Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 9 Mar 2020 18:57:42 +0530 Subject: [PATCH 09/21] MASTER- doing -e fix --- bin/allrounder | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/allrounder b/bin/allrounder index bdad56e..d26ca32 100755 --- a/bin/allrounder +++ b/bin/allrounder @@ -97,6 +97,7 @@ const resolveFile = function resolveFile(cb){ } } options.file = path.join(tmpdir, 'allroundertests', 'test.json'); + options.jsondir = path.join(tmpdir, 'allroundertests'); writeFileSync(options.file, JSON.stringify(resp, undefined, 2)); options.fileArray = [[options.file, resp, { EVAL: eval }]]; cb(); From 16182edbc3b3d4461de901fef8cf315a44c1fb55 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 9 Mar 2020 19:08:02 +0530 Subject: [PATCH 10/21] MASTER- validating conn refused --- utils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.js b/utils.js index f214fce..aacd83f 100644 --- a/utils.js +++ b/utils.js @@ -31,7 +31,12 @@ exports.logger = function logger(test, debug, debugonfail, header, data) { let toDebug = false; ((debug ? (debug + ',') : '') + (debugonfail || '')).split(',').forEach((db) => { if (db.length){ - let queryVal = exports.jsonquery(data, db); + let queryVal + if (typeof data === "object") { + queryVal = exports.jsonquery(data, db); + } else { + queryVal = data + } if (queryVal !== undefined) { qr.push([db, queryVal]); toDebug = true; From 2fc4ef5ba6a551e0109f82933502bf38c26c9092 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 9 Mar 2020 21:26:33 +0530 Subject: [PATCH 11/21] MASTER- fixing the version --- package.json | 4 ++-- utils.js | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index a15bf61..51a452f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.8.0", + "version": "0.8.1", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -28,7 +28,7 @@ "homepage": "https://github.com/codeofnode/allrounder", "dependencies": { "json2server": "latest", - "jsonpath": "^1.0.0", + "jsonpath": "^1.0.2", "mocha": "^7.1.0" } } diff --git a/utils.js b/utils.js index aacd83f..97b2fb3 100644 --- a/utils.js +++ b/utils.js @@ -31,12 +31,7 @@ exports.logger = function logger(test, debug, debugonfail, header, data) { let toDebug = false; ((debug ? (debug + ',') : '') + (debugonfail || '')).split(',').forEach((db) => { if (db.length){ - let queryVal - if (typeof data === "object") { - queryVal = exports.jsonquery(data, db); - } else { - queryVal = data - } + let queryVal = exports.jsonquery(data, db); if (queryVal !== undefined) { qr.push([db, queryVal]); toDebug = true; @@ -77,7 +72,9 @@ exports.jsonquery = function jsonquery(data, path) { return jsonpath.query(data, path.substring(6), count); } } - res = jsonpath.query(data, path, 1); + if (data instanceof Object && typeof path === 'string' && path) { + res = jsonpath.query(data, path, 1); + } res = (Array.isArray(res) && res.length < 2) ? res[0] : res; return res; }; From 8f55a78e2a943f487691a98c5c1354aea80f896b Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Wed, 11 Mar 2020 22:09:33 +0530 Subject: [PATCH 12/21] MASTER- added build dir --- build/Dockerfile | 5 +++++ build/it.sh | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 build/Dockerfile create mode 100644 build/it.sh diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..2914e8b --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,5 @@ +FROM node:13-alpine +ARG VERSION +RUN npm install -g allrounder@${VERSION} --allow-root --unsafe-perm=true +USER nobody:nobody +ENTRYPOINT ["allrounder"] diff --git a/build/it.sh b/build/it.sh new file mode 100644 index 0000000..e60fa26 --- /dev/null +++ b/build/it.sh @@ -0,0 +1,7 @@ + +set -e +VER=`sed 's/.*"version": "\(.*\)".*/\1/;t;d' ../package.json` +docker build . -t codeofnode/allrounder:$VER +docker tag codeofnode/allrounder:$VER codeofnode/allrounder:latest +docker push codeofnode/allrounder:$VER +docker push codeofnode/allrounder:latest From 0e2b5af88fae2ecde5f5c0c0456f53a99bd7b138 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Thu, 9 Apr 2020 12:00:32 +0530 Subject: [PATCH 13/21] MASTER- adding test ar index --- bin/allrounder | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/allrounder b/bin/allrounder index d26ca32..17ee71b 100755 --- a/bin/allrounder +++ b/bin/allrounder @@ -99,6 +99,7 @@ const resolveFile = function resolveFile(cb){ options.file = path.join(tmpdir, 'allroundertests', 'test.json'); options.jsondir = path.join(tmpdir, 'allroundertests'); writeFileSync(options.file, JSON.stringify(resp, undefined, 2)); + if (Array.isArray(resp.tests)) resp.tests.forEach((tt,ind) => { tt.ARtestIndex = ind; }); options.fileArray = [[options.file, resp, { EVAL: eval }]]; cb(); }).catch(function(er){ diff --git a/package.json b/package.json index 51a452f..9fccc0a 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.8.1", + "version": "0.8.2", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From e9987e9f921cbe552f130c16126336b102087507 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Thu, 9 Apr 2020 12:55:02 +0530 Subject: [PATCH 14/21] MASTER- fixing the build arg --- .gitignore | 1 + build/it.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 19b8ac3..0446ef0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ npm-debug.log* node_modules tests/testrepo +build/.docker package-lock.json .npm diff --git a/build/it.sh b/build/it.sh index e60fa26..aa01551 100644 --- a/build/it.sh +++ b/build/it.sh @@ -1,7 +1,7 @@ set -e VER=`sed 's/.*"version": "\(.*\)".*/\1/;t;d' ../package.json` -docker build . -t codeofnode/allrounder:$VER +docker build . --build-arg VERSION=${VER} -t codeofnode/allrounder:$VER docker tag codeofnode/allrounder:$VER codeofnode/allrounder:latest docker push codeofnode/allrounder:$VER docker push codeofnode/allrounder:latest From edd6d0862078ff6230a91cacac6038db2099194c Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Fri, 10 Apr 2020 23:01:02 +0530 Subject: [PATCH 15/21] MASTER- fixed warning etc --- package.json | 2 +- types/db/dbconnectors/mongodb.js | 3 ++- types/unit/index.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9fccc0a..4f30e90 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.8.2", + "version": "0.8.3", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/types/db/dbconnectors/mongodb.js b/types/db/dbconnectors/mongodb.js index cd991b4..2acdd41 100644 --- a/types/db/dbconnectors/mongodb.js +++ b/types/db/dbconnectors/mongodb.js @@ -62,7 +62,7 @@ module.exports = function mongodb(reqObj, dbConfig, next) { } const query = reqObj.payload; let col; - try { col = db.collection(query && query.collection); } catch(erm){ } + try { col = db.collection(query && query.collection); } catch(erm){ console.log(erm) } if (!col){ return next({error : "Collection not available", code : 'COL_NOT_AVL', status : 400 }); } @@ -119,6 +119,7 @@ module.exports = function mongodb(reqObj, dbConfig, next) { if (connectionMap.hasOwnProperty(dbConfig.connectionName)) { afterConnection(null, connectionMap[dbConfig.connectionName]); } else { + dbConfig.options = Object.assign({ useUnifiedTopology: true }, dbConfig.options || {}) MongoClient.connect(dbConfig.dbUrl, dbConfig.options, afterConnection); } }; diff --git a/types/unit/index.js b/types/unit/index.js index 9e6a716..a765dfe 100644 --- a/types/unit/index.js +++ b/types/unit/index.js @@ -77,7 +77,7 @@ module.exports = function forTC(OPTS, test, fileData, done, noti) { } else { unit = global; } - if (typeof reqObj.method !== 'string') return callback({ error: null, output: true }) + if (typeof reqObj.method !== 'string') return callback({ error: null, output: unit }) const method = OPTS.jsonquery(unit, OPTS.replace(reqObj.method, vars, methods)); let payload = (reqObj.payload === undefined) ? [] : OPTS.replace(reqObj.payload, vars, methods); if (!Array.isArray(payload)) { payload = [payload]; } From e7651a33da30caec0ce6b5a563c2c10849dc087d Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 23 May 2022 11:36:00 +0530 Subject: [PATCH 16/21] Updated with support of http2 request and ca file. --- extractArgs.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extractArgs.js b/extractArgs.js index 4ae7c0f..2015fdb 100644 --- a/extractArgs.js +++ b/extractArgs.js @@ -109,6 +109,14 @@ function parseReq(splits) { } break; default: + if (splits[1].indexOf('caFile=') === 0) { + request.caFile = splits[1].substring(7); + splits.splice(1, 1); + } + if (splits[1].indexOf('http2=') === 0) { + request.http2Options = getObjectFromFileOrArgument(splits[1].substring(6)); + splits.splice(1, 1); + } if (splits[1].indexOf('http') === 0) { splits.splice(1, 0, 'GET'); } From ad99650da3f30a1360a247050cbc445f0f6d25c4 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 23 May 2022 11:55:43 +0530 Subject: [PATCH 17/21] Updated package.json with 0.8.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f30e90..668308d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.8.3", + "version": "0.8.4", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 819de718eae75ee73f7b4299353337f2d33b3471 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 23 May 2022 16:13:19 +0530 Subject: [PATCH 18/21] Added workdir in Dockerfile --- build/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/build/Dockerfile b/build/Dockerfile index 2914e8b..9c13a62 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -2,4 +2,5 @@ FROM node:13-alpine ARG VERSION RUN npm install -g allrounder@${VERSION} --allow-root --unsafe-perm=true USER nobody:nobody +WORKDIR /app ENTRYPOINT ["allrounder"] From a4ecca1698cc5b8013768e0e0079c3057a09cff7 Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Mon, 23 May 2022 16:15:40 +0530 Subject: [PATCH 19/21] updated to node 18 --- build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Dockerfile b/build/Dockerfile index 9c13a62..32040a3 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -FROM node:13-alpine +FROM node:18-alpine ARG VERSION RUN npm install -g allrounder@${VERSION} --allow-root --unsafe-perm=true USER nobody:nobody From 2e735341dc94347e2f6351736086f48b639a595a Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Wed, 25 May 2022 09:32:22 +0000 Subject: [PATCH 20/21] more flexible test file based options --- index.js | 8 ++++---- package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 67d8f5e..e1f5013 100644 --- a/index.js +++ b/index.js @@ -38,11 +38,11 @@ function ifConditionFailed(condition){ } } -function resolveWhile(inputwhile, OPTS, ts){ +function resolveWhile(inputwhile, OPTS, ts, vars, methods){ if (typeof inputwhile === 'string') { return { while : inputwhile, - interval: typeof ts.whileinterval === 'number' ? ts.whileinterval : OPTS.whileinterval + interval: ts.whileinterval !== undefined ? OPTS.replace(ts.whileinterval, vars, methods) : OPTS.replace(OPTS.whileinterval, vars, methods) }; } else if (typeof inputwhile === 'object' && inputwhile !== null && typeof inputwhile.while === 'string' && typeof inputwhile.interval === 'number') { @@ -129,7 +129,7 @@ exports.forTS = function forTS(fileData) { require(`./types/${test.type || fileData[1].type || OPTS.type}`) .call(that, OPTS, test, fileData, cb, OPTS.logger.bind(OPTS, that.test, getFinalDebug(currDebug, mainDebug, OPTS.debug), getFinalDebug(currDebugOnFail, mainDebugOnFail, OPTS.debugonfail))); } - const resolvedwhile = resolveWhile(test.while, OPTS, fileData[1]); + const resolvedwhile = resolveWhile(test.while, OPTS, fileData[1], vars, methods); if (resolvedwhile) { that.ARshouldClone = true; function loopingFunction(curIndex){ @@ -153,7 +153,7 @@ exports.forTS = function forTS(fileData) { tto = false; } if (sleep) { - that.timeout(sleep + (tto || OPTS.timeout || 2000)); + that.timeout(sleep + (tto || fileData[1].timeout || OPTS.timeout || 2000)); setTimeout(execNow, sleep); } else { if (tto) that.timeout(tto); diff --git a/package.json b/package.json index 668308d..763f264 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.8.4", + "version": "0.8.5", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -27,7 +27,7 @@ "license": "MIT", "homepage": "https://github.com/codeofnode/allrounder", "dependencies": { - "json2server": "latest", + "json2server": "^0.1.30", "jsonpath": "^1.0.2", "mocha": "^7.1.0" } From cd2cb95c4dd0bfa66703d48c9e1b2bad38741eda Mon Sep 17 00:00:00 2001 From: Ramesh Kumar Date: Wed, 15 Jun 2022 18:30:50 +0000 Subject: [PATCH 21/21] new json2server 0.1.31 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 763f264..bbde6f7 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "allrounder", - "version": "0.8.5", + "version": "0.8.6", "description": "All in one validator for testing, under one roof. From rest call to dbvalidation to system commands to unit tests. Just almost everything", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -27,7 +27,7 @@ "license": "MIT", "homepage": "https://github.com/codeofnode/allrounder", "dependencies": { - "json2server": "^0.1.30", + "json2server": "^0.1.31", "jsonpath": "^1.0.2", "mocha": "^7.1.0" }