From 6aa8dd27a5605c66b62009d1fd9c31de54633e5b Mon Sep 17 00:00:00 2001 From: "sofiia.pasichnyk" Date: Wed, 13 May 2020 10:23:54 +0200 Subject: [PATCH 1/2] TSERV-697: add security test support --- README.md | 5 +++-- bin/jobs_functions.js | 14 +++++++++----- bin/run_functions.js | 14 +++++++++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f6da916..3d38288 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,11 @@ table includes the currently implemented options. | skipdeps | N/A | Do not scan project for dependencies. This will improve performance for large projects without dependences to external files | | testsuite | TestSuite1 | Name of a test suite to run| | testcase | JRA-11224 | Name of a specific test case to run. Typically used together with **testsuite** because a project can have several test cases with the same name in different test suites.| +| securitytest | SecurityTest1 | Name of a security test to run. Can not be used with **testsuite** or **testcase**. | tags | smoketest | Comma separated list of tags. For a test case to be run, it should have all the listed tags. When specifying many tags, or using tags with space in the name, it is possible to surround them with either (), [] or "" but be aware that different operating systems can have special meanings for brackets which requires quoting. Tags cannot be used together with testsuite/testcase specification.| | tags | "smoketest,regression" | See description above| | output | c:\\temp\\reports | Directory to store reports in.| -| reportFileName | File name for the report. If omitted, the report will get a name based on the test job ID| +| reportFileName | N/A | File name for the report. If omitted, the report will get a name based on the test job ID| | format | excel | Specify the file type of the report. Currently supported formats are json, junit, excel and pdf. The default format is junit| | proxyHost | 172.0.1.10 | Hostname or IP of the server to use as a proxy for outgoing requests (from TestEngine)| | proxyPort | 8888 | Port of the proxyHost to contact for outgoing requests (from TestEngine)| @@ -123,7 +124,7 @@ The "output" argument is mandatory, "format" is optional. | Option | Sample Value | Description| |---|---|---| | output | c:\\temp\\reports | Directory to store reports in.| -| reportFileName | File name for the report. If omitted, the report will get a name based on the test job ID| +| reportFileName | N/A | File name for the report. If omitted, the report will get a name based on the test job ID| | format | excel | Specify the file type of the report. Currently supported formats are json, junit, excel and pdf. The default format is junit| ### Clean up old jobs from the server database diff --git a/bin/jobs_functions.js b/bin/jobs_functions.js index 0bf9697..d401149 100644 --- a/bin/jobs_functions.js +++ b/bin/jobs_functions.js @@ -328,9 +328,9 @@ function dumpArrayAsJson(jsonData) { function csvLine(data, header = false) { if (header) { - return '"Status", "Project", "User", "Submitted", "Submitted Millis", "Time in Queue (ms)", "Run time (ms)", "Test Suite", "Test Case", "Tags", "Job Id"'; + return '"Status", "Project", "User", "Submitted", "Submitted Millis", "Time in Queue (ms)", "Run time (ms)", "Test Suite", "Test Case", "Security Test", "Tags", "Job Id"'; } else { - return sprintf('"%s", "%s", "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s"', + return sprintf('"%s", "%s", "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s"', util.csvQuoteQuotes(data.status), util.csvQuoteQuotes(data.projectName), util.csvQuoteQuotes(data.userName), @@ -342,6 +342,8 @@ function csvLine(data, header = false) { util.csvQuoteQuotes(data.executionParameters['testSuiteName']) : '', 'testCaseName' in data.executionParameters ? util.csvQuoteQuotes(data.executionParameters['testCaseName']) : '', + 'securityTestName' in data.executionParameters ? + util.csvQuoteQuotes(data.executionParameters['securityTestName']) : '', 'tags' in data.executionParameters ? util.csvQuoteQuotes(data.executionParameters['tags'].join(', ')) : '', util.csvQuoteQuotes(data.testjobId), @@ -351,11 +353,11 @@ function csvLine(data, header = false) { function textLine(data, header = false) { if (header) { - return sprintf('%-10s %-20s %-10s %-25s %-13s %-11s %-13s %-30s %-20s %-20s %-20s' + + return sprintf('%-10s %-20s %-10s %-25s %-13s %-11s %-13s %-30s %-20s %-20s %-20s %-20s' + '\n==========================================================================================================================================================================================================================', - "Status", "Project", "User", "Submitted", "Submitted ms", "Queued (ms)", "Run time (ms)", "Test Suite", "Test Case", "Tags", "Job Id"); + "Status", "Project", "User", "Submitted", "Submitted ms", "Queued (ms)", "Run time (ms)", "Test Suite", "Test Case", "Security Test", "Tags", "Job Id"); } else { - return sprintf('%-10s %-20s %-10s %-25s %13d %11d %13d %-30s %-20s %-20s %-20s', + return sprintf('%-10s %-20s %-10s %-25s %13d %11d %13d %-30s %-20s %-20s %-20s %-20s', util.csvQuoteQuotes(data.status), util.csvQuoteQuotes(data.projectName), util.csvQuoteQuotes(data.userName), @@ -367,6 +369,8 @@ function textLine(data, header = false) { util.csvQuoteQuotes(data.executionParameters['testSuiteName']) : '', 'testCaseName' in data.executionParameters ? util.csvQuoteQuotes(data.executionParameters['testCaseName']) : '', + 'securityTestName' in data.executionParameters ? + util.csvQuoteQuotes(data.executionParameters['securityTestName']) : '', 'tags' in data.executionParameters ? util.csvQuoteQuotes(data.executionParameters['tags'].join(', ')) : '', util.csvQuoteQuotes(data.testjobId), diff --git a/bin/run_functions.js b/bin/run_functions.js index f501601..97f578d 100644 --- a/bin/run_functions.js +++ b/bin/run_functions.js @@ -24,6 +24,7 @@ module.exports.dispatcher = function (args) { '=async', '=skipdeps', 'testsuite', + 'securitytest', 'tags', 'environment', 'output', @@ -47,7 +48,7 @@ module.exports.dispatcher = function (args) { printModuleHelp(); break; default: - util.error("Unknown operatation"); + util.error("Unknown operation"); break; } }; @@ -55,16 +56,20 @@ module.exports.dispatcher = function (args) { function printModuleHelp() { util.error("Usage: testengine run "); util.error("Commands: "); - util.error(" project [testsuite=] [async] [skipdeps] [testcase=] [timeout=] [tags=(tag1,tag2)] [output=] [reportFileName=] [format=junit/excel/json/pdf] [environment=]"); + util.error(" project [testsuite=] [async] [skipdeps] [testcase=] [securitytest=] [timeout=] [tags=(tag1,tag2)] [output=] [reportFileName=] [format=junit/excel/json/pdf] [environment=]"); util.error(" [projectPassword=] [proxyHost=] [proxyPort=] [proxyUser=]"); util.error(" [proxyPassword=] "); util.error(" help"); } function conflictingOptionsCheck(options) { + if (('securitytest' in options) && (('testcase' in options) || ('testsuite' in options))) { + util.error('Error: You can specify only functional test (testsuite and/or testscase) or security test (securitytest) in one go'); + return false; + } if ('tags' in options) { if (('testsuite' in options) || ('testcase' in options)) { - util.error('Error: tags are cannot be used together with testcase/testsuite '); + util.error('Error: tags cannot be used together with testcase/testsuite '); return false; } } @@ -164,6 +169,9 @@ function getQueryStringFromOptions(options) { case 'testcase': queryStringPart = 'testCaseName=' + encodeURI(options[key]); break; + case 'securitytest': + queryStringPart = 'securityTestName=' + encodeURI(options[key]); + break; case 'tags': { let tags = options[key]; let mr = /[("[]?([^)"\]]+)[)"\]]?/.exec(tags); From 500d52151e71440b7dce377a02c245320596d6b0 Mon Sep 17 00:00:00 2001 From: "sofiia.pasichnyk" Date: Wed, 13 May 2020 16:40:27 +0200 Subject: [PATCH 2/2] TSERV-697: improved error message for conflicting parameters --- bin/run_functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run_functions.js b/bin/run_functions.js index 97f578d..7c92b00 100644 --- a/bin/run_functions.js +++ b/bin/run_functions.js @@ -64,7 +64,7 @@ function printModuleHelp() { function conflictingOptionsCheck(options) { if (('securitytest' in options) && (('testcase' in options) || ('testsuite' in options))) { - util.error('Error: You can specify only functional test (testsuite and/or testscase) or security test (securitytest) in one go'); + util.error('Error: Parameters testsuite and testcase are not allowed when securitytest is used'); return false; } if ('tags' in options) {