mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Add support for disabled test cases.
This commit adds support for skipping test cases that have enabled=0 in their JSON body. A separate counter is kept and reported in the final non-automake output, detailing disabled as a separate field. Ref: #1513
This commit is contained in:
parent
ab14b7c083
commit
d66f0c7e0d
@ -94,10 +94,6 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
ModSecurityTestResults<RegressionTestResult> *res, int *count) {
|
||||
|
||||
for (RegressionTest *t : *tests) {
|
||||
if (t->enabled == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CustomDebugLog *debug_log = new CustomDebugLog();
|
||||
modsecurity::ModSecurity *modsec = NULL;
|
||||
modsecurity::Rules *modsec_rules = NULL;
|
||||
@ -105,6 +101,7 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
ModSecurityTestResults<RegressionTest> r;
|
||||
std::stringstream serverLog;
|
||||
RegressionTestResult *testRes = new RegressionTestResult();
|
||||
|
||||
testRes->test = t;
|
||||
r.status = 200;
|
||||
(*count)++;
|
||||
@ -125,6 +122,19 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
std::cout << std::setw(70) << std::left << t->name;
|
||||
}
|
||||
|
||||
if (t->enabled == 0) {
|
||||
if (test->m_automake_output) {
|
||||
std::cout << ":test-result: disabled" << filename \
|
||||
<< ":" << t->name << std::endl;
|
||||
} else {
|
||||
std::cout << KCYN << "disabled" << RESET << std::endl;
|
||||
}
|
||||
res->push_back(testRes);
|
||||
testRes->disabled = true;
|
||||
testRes->reason << "JSON disabled";
|
||||
continue;
|
||||
}
|
||||
|
||||
modsec = new modsecurity::ModSecurity();
|
||||
modsec->setConnectorInformation("ModSecurity-regression v0.0.1-alpha" \
|
||||
" (ModSecurity regression test utility)");
|
||||
@ -473,17 +483,22 @@ int main(int argc, char **argv) {
|
||||
|
||||
int passed = 0;
|
||||
int failed = 0;
|
||||
int disabled = 0;
|
||||
int skipped = 0;
|
||||
|
||||
for (RegressionTestResult *r : res) {
|
||||
if (r->skipped == true) {
|
||||
skipped++;
|
||||
}
|
||||
if (r->passed == true && r->skipped == false) {
|
||||
if (r->disabled == true) {
|
||||
disabled++;
|
||||
}
|
||||
if (r->passed == true) {
|
||||
passed++;
|
||||
} else if (r->skipped == false) {
|
||||
if (test.m_automake_output) {
|
||||
// m_automake_output
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!r->passed && !r->skipped && !r->disabled) {
|
||||
if (!test.m_automake_output) {
|
||||
std::cout << KRED << "Test failed." << RESET << KWHT \
|
||||
<< " From: " \
|
||||
<< RESET << r->test->filename << "." << std::endl;
|
||||
@ -507,13 +522,11 @@ int main(int argc, char **argv) {
|
||||
std::cout << KRED << failed << " failed. " << RESET;
|
||||
}
|
||||
|
||||
if (skipped > 0) {
|
||||
std::cout << KCYN << " " << std::to_string(skipped) << " ";
|
||||
std::cout << "skipped tests." << RESET << std::endl;
|
||||
} else {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << KCYN << std::to_string(skipped) << " ";
|
||||
std::cout << "skipped test(s). " << std::to_string(disabled) << " ";
|
||||
std::cout << "disabled test(s)." << RESET << std::endl;
|
||||
}
|
||||
|
||||
for (std::pair<std::string, std::vector<RegressionTest *> *> a : test) {
|
||||
std::vector<RegressionTest *> *vec = a.second;
|
||||
for (int i = 0; i < vec->size(); i++) {
|
||||
|
@ -83,10 +83,12 @@ class RegressionTestResult {
|
||||
RegressionTestResult() :
|
||||
passed(false),
|
||||
skipped(false),
|
||||
disabled(false),
|
||||
test(NULL) { }
|
||||
|
||||
bool passed;
|
||||
bool skipped;
|
||||
bool disabled;
|
||||
RegressionTest *test;
|
||||
std::stringstream reason;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user