mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Adds support to error_log in the regression tests
This commit is contained in:
parent
ae8c2a4865
commit
795994bb0e
@ -50,6 +50,13 @@ void print_help() {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
bool contains(const std::string &s, const std::string &pattern) {
|
||||
bool ret;
|
||||
modsecurity::Utils::Regex re(pattern);
|
||||
ret = modsecurity::Utils::regex_search(s, re);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void actions(ModSecurityTestResults<RegressionTest> *r,
|
||||
modsecurity::Transaction *a) {
|
||||
@ -336,7 +343,7 @@ end:
|
||||
testRes->reason << "Debug log was not matching the " \
|
||||
<< "expected results." << std::endl;
|
||||
testRes->reason << KWHT << "Expecting: " << RESET \
|
||||
<< t->debug_log + ".";
|
||||
<< t->debug_log + "";
|
||||
testRes->passed = false;
|
||||
} else if (r.status != t->http_code) {
|
||||
if (test->m_automake_output) {
|
||||
@ -349,6 +356,18 @@ end:
|
||||
std::to_string(t->http_code) + \
|
||||
" got: " + std::to_string(r.status) + "\n";
|
||||
testRes->passed = false;
|
||||
} else if (!contains(serverLog.str(), t->error_log)) {
|
||||
if (test->m_automake_output) {
|
||||
std::cout << ":test-result: FAIL " << filename \
|
||||
<< ":" << t->name << std::endl;
|
||||
} else {
|
||||
std::cout << KRED << "failed!" << RESET << std::endl;
|
||||
}
|
||||
testRes->reason << "Error log was not matching the " \
|
||||
<< "expected results." << std::endl;
|
||||
testRes->reason << KWHT << "Expecting: " << RESET \
|
||||
<< t->error_log + "";
|
||||
testRes->passed = false;
|
||||
} else {
|
||||
if (test->m_automake_output) {
|
||||
std::cout << ":test-result: PASS " << filename \
|
||||
@ -364,9 +383,12 @@ end:
|
||||
testRes->reason << std::endl;
|
||||
testRes->reason << KWHT << "Debug log:" << RESET << std::endl;
|
||||
testRes->reason << d->log_messages() << std::endl;
|
||||
testRes->reason << KWHT << "Error log:" << RESET << std::endl;
|
||||
testRes->reason << serverLog.str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
after_debug_log:
|
||||
if (d != NULL) {
|
||||
r.log_raw_debug_log = d->log_messages();
|
||||
|
@ -186,7 +186,7 @@ RegressionTest *RegressionTest::from_yajl_node(const yajl_val &node) {
|
||||
u->debug_log = YAJL_GET_STRING(val2);
|
||||
}
|
||||
if (strcmp(key2, "error_log") == 0) {
|
||||
u->error_log = yajl_array_to_str(val2);
|
||||
u->error_log = YAJL_GET_STRING(val2);
|
||||
}
|
||||
if (strcmp(key2, "http_code") == 0) {
|
||||
u->http_code = YAJL_GET_INTEGER(val2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user