mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 19:24:26 +03:00
sync code
This commit is contained in:
@@ -71,24 +71,24 @@ TEST_F(HttpAttachmentUtilTest, GetValidAttachmentConfiguration)
|
||||
|
||||
HttpAttachmentConfiguration conf_data_out;
|
||||
EXPECT_EQ(conf_data_out.init(attachment_configuration_file_name), 1);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("is_fail_open_mode_enabled"), 0);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("fail_open_timeout"), 1234);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("is_fail_open_mode_hold_enabled"), 0);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("fail_open_hold_timeout"), 4321);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("is_fail_open_mode_enabled"), 0u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("fail_open_timeout"), 1234u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("is_fail_open_mode_hold_enabled"), 0u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("fail_open_hold_timeout"), 4321u);
|
||||
EXPECT_EQ(conf_data_out.getStringValue("sessions_per_minute_limit_verdict"), "Accept");
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("max_sessions_per_minute"), 0);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("num_of_nginx_ipc_elements"), 200);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("keep_alive_interval_msec"), 10000);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("max_sessions_per_minute"), 0u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("num_of_nginx_ipc_elements"), 200u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("keep_alive_interval_msec"), 10000u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("dbg_level"), 2u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("res_proccessing_timeout_msec"), 420);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("req_proccessing_timeout_msec"), 42);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("registration_thread_timeout_msec"), 101);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("req_header_thread_timeout_msec"), 10);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("req_body_thread_timeout_msec"), 155);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("res_header_thread_timeout_msec"), 1);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("res_body_thread_timeout_msec"), 80);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("waiting_for_verdict_thread_timeout_msec"), 60);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("nginx_inspection_mode"), 1);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("res_proccessing_timeout_msec"), 420u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("req_proccessing_timeout_msec"), 42u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("registration_thread_timeout_msec"), 101u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("req_header_thread_timeout_msec"), 10u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("req_body_thread_timeout_msec"), 155u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("res_header_thread_timeout_msec"), 1u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("res_body_thread_timeout_msec"), 80u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("waiting_for_verdict_thread_timeout_msec"), 60u);
|
||||
EXPECT_EQ(conf_data_out.getNumericalValue("nginx_inspection_mode"), 1u);
|
||||
}
|
||||
|
||||
TEST_F(HttpAttachmentUtilTest, GetMalformedAttachmentConfiguration)
|
||||
|
@@ -306,6 +306,7 @@ private:
|
||||
string log_files_prefix = "/var/log";
|
||||
string default_config_directory_path = "/conf/";
|
||||
string config_directory_path = "";
|
||||
string error_to_report = "";
|
||||
|
||||
TypeWrapper empty;
|
||||
};
|
||||
@@ -802,6 +803,7 @@ bool
|
||||
ConfigComponent::Impl::commitFailure(const string &error)
|
||||
{
|
||||
dbgError(D_CONFIG) << error;
|
||||
error_to_report = error;
|
||||
new_resource_nodes.clear();
|
||||
new_configuration_nodes.clear();
|
||||
new_settings_nodes.clear();
|
||||
@@ -937,7 +939,7 @@ ConfigComponent::Impl::reloadConfigurationContinuesWrapper(const string &version
|
||||
|
||||
mainloop->stop(routine_id);
|
||||
LoadNewConfigurationStatus finished(id, service_name, !res, true);
|
||||
if (!res) finished.setError("Failed to reload configuration");
|
||||
if (!res) finished.setError(error_to_report);
|
||||
I_TimeGet *time = Singleton::Consume<I_TimeGet>::by<ConfigComponent>();
|
||||
auto send_status_time_out = time->getMonotonicTime() + chrono::seconds(180);
|
||||
while (time->getMonotonicTime() < send_status_time_out) {
|
||||
|
@@ -151,10 +151,10 @@ TEST(TempCaching, capacity)
|
||||
cache.createEntry(3);
|
||||
cache.createEntry(4);
|
||||
|
||||
EXPECT_EQ(cache.size(), 5);
|
||||
EXPECT_EQ(cache.capacity(), 0);
|
||||
EXPECT_EQ(cache.size(), 5u);
|
||||
EXPECT_EQ(cache.capacity(), 0u);
|
||||
cache.capacity(3);
|
||||
EXPECT_EQ(cache.size(), 3);
|
||||
EXPECT_EQ(cache.size(), 3u);
|
||||
EXPECT_FALSE(cache.doesKeyExists(0));
|
||||
EXPECT_FALSE(cache.doesKeyExists(1));
|
||||
EXPECT_TRUE(cache.doesKeyExists(2));
|
||||
@@ -162,7 +162,7 @@ TEST(TempCaching, capacity)
|
||||
EXPECT_TRUE(cache.doesKeyExists(4));
|
||||
|
||||
cache.createEntry(5);
|
||||
EXPECT_EQ(cache.size(), 3);
|
||||
EXPECT_EQ(cache.size(), 3u);
|
||||
EXPECT_FALSE(cache.doesKeyExists(2));
|
||||
EXPECT_TRUE(cache.doesKeyExists(3));
|
||||
EXPECT_TRUE(cache.doesKeyExists(4));
|
||||
@@ -170,7 +170,7 @@ TEST(TempCaching, capacity)
|
||||
|
||||
cache.capacity(0);
|
||||
cache.createEntry(6);
|
||||
EXPECT_EQ(cache.size(), 4);
|
||||
EXPECT_EQ(cache.size(), 4u);
|
||||
EXPECT_TRUE(cache.doesKeyExists(3));
|
||||
EXPECT_TRUE(cache.doesKeyExists(4));
|
||||
EXPECT_TRUE(cache.doesKeyExists(5));
|
||||
@@ -178,7 +178,7 @@ TEST(TempCaching, capacity)
|
||||
|
||||
cache.deleteEntry(5);
|
||||
cache.capacity(2);
|
||||
EXPECT_EQ(cache.size(), 2);
|
||||
EXPECT_EQ(cache.size(), 2u);
|
||||
EXPECT_TRUE(cache.doesKeyExists(4));
|
||||
EXPECT_TRUE(cache.doesKeyExists(6));
|
||||
}
|
||||
|
@@ -161,6 +161,7 @@ public:
|
||||
public:
|
||||
MyValue(int _x) : x(_x) { addObj(this); }
|
||||
MyValue(const MyValue &other) : x(other.x) { addObj(this); }
|
||||
MyValue & operator=(const MyValue &other) = default;
|
||||
~MyValue() { delObj(this); }
|
||||
bool operator==(const MyValue &other) const { return x==other.x; }
|
||||
bool operator!=(const MyValue &other) const { return x!=other.x; }
|
||||
@@ -208,9 +209,9 @@ TEST_F(MaybeAssignments, ValValRval)
|
||||
Maybe<MyValue, MyValue> m(MyValue(1));
|
||||
|
||||
// Change the value
|
||||
EXPECT_EQ(1, m->x);
|
||||
EXPECT_EQ(m->x, 1);
|
||||
m = 2;
|
||||
EXPECT_EQ(2, m->x);
|
||||
EXPECT_EQ(m->x, 2);
|
||||
}
|
||||
|
||||
TEST_F(MaybeAssignments, ValValLval)
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <sys/types.h>
|
||||
@@ -145,6 +146,30 @@ operator<<(ostream &os, const vector<Printable> &obj)
|
||||
return os;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START Reason: Currently not used in 4.8 coverage but is used in alpine.
|
||||
template <typename PrintableKey, typename PrintableValue>
|
||||
ostream &
|
||||
operator<<(ostream &os, const pair<PrintableKey, PrintableValue> &)
|
||||
{
|
||||
// Uncomment when g++ 4.8 is no longer supported
|
||||
// return os << obj.first << ':' << obj.second;
|
||||
return os;
|
||||
}
|
||||
// LCOL_EXCL_STOP
|
||||
|
||||
template <typename PrintableKey, typename PrintableValue>
|
||||
ostream &
|
||||
operator<<(ostream &os, const map<PrintableKey, PrintableValue> &)
|
||||
{
|
||||
// Uncomment when g++ 4.8 is no longer supported
|
||||
// bool first = true;
|
||||
// for (const auto &pair : obj) {
|
||||
// os << (first ? "" : ", ") << pair;
|
||||
// first = false;
|
||||
// }
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // __COMMON_H__
|
||||
|
@@ -1,3 +1,7 @@
|
||||
#include <sstream>
|
||||
namespace Intelligence { class Response; }
|
||||
std::ostream & operator<<(std::ostream &os, const Intelligence::Response &);
|
||||
|
||||
#include "intelligence_comp_v2.h"
|
||||
|
||||
#include "config.h"
|
||||
@@ -642,7 +646,7 @@ TEST_F(IntelligenceComponentTestV2, multiAssetsIntelligenceTest)
|
||||
auto maybe_ans = intell->queryIntelligence<Profile>(request);
|
||||
EXPECT_TRUE(maybe_ans.ok());
|
||||
auto vec = maybe_ans.unpack();
|
||||
EXPECT_EQ(vec.size(), 3);
|
||||
EXPECT_EQ(vec.size(), 3u);
|
||||
|
||||
auto iter = vec.begin();
|
||||
|
||||
@@ -962,11 +966,11 @@ TEST_F(IntelligenceComponentTestV2, pagingQueryTest)
|
||||
).WillOnce(Return(HTTPResponse(HTTPStatusCode::HTTP_OK, paging_in_progress_response_str1)));
|
||||
|
||||
request.setAssetsLimit(2);
|
||||
EXPECT_EQ(request.getAssetsLimit(), 2);
|
||||
EXPECT_EQ(request.getAssetsLimit(), 2u);
|
||||
auto maybe_ans1 = intell->queryIntelligence<Profile>(request);
|
||||
EXPECT_TRUE(maybe_ans1.ok());
|
||||
auto vec1 = maybe_ans1.unpack();
|
||||
EXPECT_EQ(vec1.size(), 1);
|
||||
EXPECT_EQ(vec1.size(), 1u);
|
||||
EXPECT_EQ(request.isPagingFinished(), false);
|
||||
|
||||
EXPECT_CALL(messaging_mock, sendSyncMessage(HTTPMethod::POST, _, _, MessageCategory::INTELLIGENCE, _)
|
||||
@@ -975,7 +979,7 @@ TEST_F(IntelligenceComponentTestV2, pagingQueryTest)
|
||||
auto maybe_ans2 = intell->queryIntelligence<Profile>(request);
|
||||
EXPECT_TRUE(maybe_ans2.ok());
|
||||
auto vec2 = maybe_ans2.unpack();
|
||||
EXPECT_EQ(vec2.size(), 2);
|
||||
EXPECT_EQ(vec2.size(), 2u);
|
||||
EXPECT_EQ(request.isPagingFinished(), false);
|
||||
|
||||
EXPECT_CALL(messaging_mock, sendSyncMessage(HTTPMethod::POST, _, _, MessageCategory::INTELLIGENCE, _)
|
||||
@@ -985,7 +989,7 @@ TEST_F(IntelligenceComponentTestV2, pagingQueryTest)
|
||||
if (!maybe_ans3.ok()) cout << maybe_ans3.getErr() + "\n";
|
||||
EXPECT_TRUE(maybe_ans3.ok());
|
||||
auto vec3 = maybe_ans3.unpack();
|
||||
EXPECT_EQ(vec3.size(), 1);
|
||||
EXPECT_EQ(vec3.size(), 1u);
|
||||
EXPECT_EQ(request.isPagingFinished(), true);
|
||||
|
||||
vector<AssetReply<Profile>>::iterator assets_iter = vec3.begin();
|
||||
@@ -1316,7 +1320,6 @@ TEST_F(IntelligenceComponentTestV2, ignoreInProgressQueryTest_2)
|
||||
QueryRequest request(Condition::EQUALS, "category", "cloud", true, AttributeKeyType::NONE);
|
||||
request.activatePaging();
|
||||
request.setAssetsLimit(10);
|
||||
vector<AssetReply<Profile>> objects_reply;
|
||||
vector<string> objects_ids;
|
||||
do {
|
||||
auto object_result = intell->queryIntelligence<Profile>(request, true);
|
||||
@@ -1325,10 +1328,9 @@ TEST_F(IntelligenceComponentTestV2, ignoreInProgressQueryTest_2)
|
||||
break;
|
||||
}
|
||||
|
||||
objects_reply = object_result.unpack();
|
||||
if (objects_reply.empty()) break;
|
||||
if ((*object_result).empty()) break;
|
||||
|
||||
for (const AssetReply<Profile> ¤t_object : objects_reply) {
|
||||
for (const AssetReply<Profile> ¤t_object : *object_result) {
|
||||
if (current_object.getMainAttributes().empty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -1337,5 +1339,5 @@ TEST_F(IntelligenceComponentTestV2, ignoreInProgressQueryTest_2)
|
||||
}
|
||||
} while (!request.isPagingFinished());
|
||||
|
||||
EXPECT_EQ(objects_ids.size(), 2);
|
||||
EXPECT_EQ(objects_ids.size(), 2u);
|
||||
}
|
||||
|
@@ -609,7 +609,7 @@ TEST_F(IntelligenceInvalidation, invalidation_callback)
|
||||
json << invalidation2.genObject();
|
||||
mock_invalidation->performRestCall(json);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 1);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 1u);
|
||||
EXPECT_EQ(recieved_invalidations[0].getMainAttributes().begin()->getStringSetAttr("attr2").unpack(), vals);
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ TEST_F(IntelligenceInvalidation, delete_invalidation_callback)
|
||||
json << invalidation2.genObject();
|
||||
mock_invalidation->performRestCall(json);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 0);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(IntelligenceInvalidation, invalidation_short_handling)
|
||||
@@ -697,7 +697,7 @@ TEST_F(IntelligenceInvalidation, invalidation_short_handling)
|
||||
json << invalidation2.genObject();
|
||||
mock_invalidation->performRestCall(json);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 0);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(IntelligenceInvalidation, routine_registration)
|
||||
@@ -792,7 +792,7 @@ TEST_F(IntelligenceInvalidation, invalidation_flow_with_multiple_assets)
|
||||
json1 << not_matching_invalidation.genObject();
|
||||
mock_invalidation->performRestCall(json1);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 0);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 0u);
|
||||
|
||||
auto matching_second_main_attribute = StrAttributes()
|
||||
.addStringAttr("attr3", "3");
|
||||
@@ -808,7 +808,7 @@ TEST_F(IntelligenceInvalidation, invalidation_flow_with_multiple_assets)
|
||||
json2 << matching_invalidation.genObject();
|
||||
mock_invalidation->performRestCall(json2);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 1);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 1u);
|
||||
}
|
||||
|
||||
TEST_F(IntelligenceInvalidation, invalidation_cb_match_2_registred_assets)
|
||||
@@ -868,7 +868,7 @@ TEST_F(IntelligenceInvalidation, invalidation_cb_match_2_registred_assets)
|
||||
json << matching_invalidation.genObject();
|
||||
mock_invalidation->performRestCall(json);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 2);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(IntelligenceInvalidation, invalidation_cb_match_by_registration_id)
|
||||
@@ -931,5 +931,5 @@ TEST_F(IntelligenceInvalidation, invalidation_cb_match_by_registration_id)
|
||||
cout << json.str() << endl;
|
||||
mock_invalidation->performRestCall(json);
|
||||
|
||||
EXPECT_EQ(recieved_invalidations.size(), 1);
|
||||
EXPECT_EQ(recieved_invalidations.size(), 1u);
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ addSlashesToSpecialChars(const string &input)
|
||||
case '\"':
|
||||
case '\\':
|
||||
output += '\\';
|
||||
//no break
|
||||
// fallthrough
|
||||
default:
|
||||
output += c;
|
||||
break;
|
||||
|
@@ -136,12 +136,12 @@ TEST(QueryRequestTestV2, AttributesTest)
|
||||
request.setRequestedAttr("countryName");
|
||||
SerializableAttributesMap request_attributes_map2 = request.getRequestedAttributes();
|
||||
|
||||
EXPECT_EQ(request_attributes_map2.getAttributeByKey("attributes.countryName"), 500);
|
||||
EXPECT_EQ(request_attributes_map2.getAttributeByKey("attributes.countryName"), 500u);
|
||||
|
||||
request.setRequestedAttr("reputationSeverity", 30);
|
||||
SerializableAttributesMap request_attributes_map3 = request.getRequestedAttributes();
|
||||
|
||||
EXPECT_EQ(request_attributes_map3.getAttributeByKey("attributes.reputationSeverity"), 30);
|
||||
EXPECT_EQ(request_attributes_map3.getAttributeByKey("attributes.reputationSeverity"), 30u);
|
||||
|
||||
string output_json =
|
||||
"{\n"
|
||||
|
@@ -155,13 +155,13 @@ TEST(QueryResponseTestV2, QueryResponseTestV2)
|
||||
obj2.loadFromJson(ss.str());
|
||||
}
|
||||
|
||||
EXPECT_EQ(obj.getAmountOfAssets(), 2);
|
||||
EXPECT_EQ(obj2.getAmountOfAssets(), 2);
|
||||
EXPECT_EQ(obj.getAmountOfAssets(), 2u);
|
||||
EXPECT_EQ(obj2.getAmountOfAssets(), 2u);
|
||||
EXPECT_EQ(obj.getResponseStatus(), ResponseStatus::DONE);
|
||||
EXPECT_EQ(obj2.getResponseStatus(), ResponseStatus::DONE);
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetSchemaVersion(), 1);
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetSchemaVersion(), 1u);
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetType(), "workload-cloud-ip");
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetTypeSchemaVersion(), 1);
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetTypeSchemaVersion(), 1u);
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetPermissionGroupId(), "some-group-id");
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetName(), "[1.1.1.1]");
|
||||
EXPECT_EQ(obj.getData().begin()->getAssetClass(), "workload");
|
||||
@@ -188,7 +188,7 @@ TEST(QueryResponseTestV2, QueryResponseTestV2)
|
||||
EXPECT_EQ(soucres_it->getAssetId(), "50255c3172b4fb7fda93025f0bfaa7abefd1");
|
||||
EXPECT_EQ(soucres_it->getTTL(), chrono::seconds(120));
|
||||
EXPECT_EQ(soucres_it->getExpirationTime(), "2020-07-29T11:21:12.253Z");
|
||||
EXPECT_EQ(soucres_it->getConfidence(), 500);
|
||||
EXPECT_EQ(soucres_it->getConfidence(), 500u);
|
||||
EXPECT_EQ(soucres_it->getAttributes().begin()->getData().toString(), "red");
|
||||
EXPECT_EQ(soucres_it->getAttributes().begin()->getData1().toString(), "Omry");
|
||||
|
||||
@@ -198,15 +198,15 @@ TEST(QueryResponseTestV2, QueryResponseTestV2)
|
||||
EXPECT_EQ(soucres_it->getAssetId(), "cb068860528cb6bfb000cc35e79f11aeefed2");
|
||||
EXPECT_EQ(soucres_it->getTTL(), chrono::seconds(120));
|
||||
EXPECT_EQ(soucres_it->getExpirationTime(), "2020-07-29T11:21:12.253Z");
|
||||
EXPECT_EQ(soucres_it->getConfidence(), 600);
|
||||
EXPECT_EQ(soucres_it->getConfidence(), 600u);
|
||||
EXPECT_EQ(soucres_it->getAttributes().begin()->getData().toString(), "white");
|
||||
EXPECT_EQ(soucres_it->getAttributes().begin()->getData1().toString(), "Max");
|
||||
|
||||
vector<AssetReply<stringData1>> asset_collections = obj.getData();
|
||||
EXPECT_EQ(asset_collections.size(), 1);
|
||||
EXPECT_EQ(asset_collections.size(), 1u);
|
||||
vector<AssetReply<stringData1>>::const_iterator asset_collections_it = asset_collections.begin();
|
||||
vector<stringData1> asset_sources = asset_collections_it->getData();
|
||||
EXPECT_EQ(asset_sources.size(), 2);
|
||||
EXPECT_EQ(asset_sources.size(), 2u);
|
||||
vector<stringData1>::iterator asset_sources_it = asset_sources.begin();
|
||||
|
||||
EXPECT_EQ(asset_sources_it->getData().toString(), "red");
|
||||
|
@@ -101,7 +101,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LogTest : public testing::TestWithParam<bool>
|
||||
class LogTest : public testing::Test
|
||||
{
|
||||
public:
|
||||
LogTest()
|
||||
@@ -909,7 +909,7 @@ TEST_F(LogTest, OfflineK8sSvcBulkLogs)
|
||||
EXPECT_EQ(local_body, str1);
|
||||
}
|
||||
|
||||
TEST_P(LogTest, metrics_check)
|
||||
TEST_F(LogTest, metrics_check)
|
||||
{
|
||||
loadFakeConfiguration(true, false, "", 3);
|
||||
Tags tag1 = Tags::POLICY_INSTALLATION;
|
||||
@@ -935,16 +935,10 @@ TEST_P(LogTest, metrics_check)
|
||||
" \"sentLogsBulksSum\": 3\n"
|
||||
"}";
|
||||
|
||||
bool is_named_query = GetParam();
|
||||
if (is_named_query) {
|
||||
EXPECT_THAT(AllMetricEvent().performNamedQuery(), ElementsAre(Pair("Logging data", logging_metric_str)));
|
||||
} else {
|
||||
EXPECT_THAT(AllMetricEvent().query(), ElementsAre(logging_metric_str));
|
||||
}
|
||||
EXPECT_THAT(AllMetricEvent().performNamedQuery(), ElementsAre(Pair("Logging data", logging_metric_str)));
|
||||
EXPECT_THAT(AllMetricEvent().query(), ElementsAre(logging_metric_str));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(metrics_check, LogTest, ::testing::Values(false, true));
|
||||
|
||||
TEST_F(LogTest, DeleteStreamTest)
|
||||
{
|
||||
loadFakeConfiguration(false);
|
||||
@@ -1564,7 +1558,7 @@ TEST_F(LogTest, ObfuscationTest)
|
||||
EXPECT_EQ(getBodyFogMessage(), expected_obfuscated_log);
|
||||
ASSERT_NE(sysog_routine, nullptr);
|
||||
sysog_routine();
|
||||
EXPECT_EQ(capture_syslog_cef_data.size(), 2);
|
||||
EXPECT_EQ(capture_syslog_cef_data.size(), 2u);
|
||||
for (const string &str : capture_syslog_cef_data) {
|
||||
EXPECT_THAT(str, AnyOf(HasSubstr("String='Another string'"), HasSubstr("String=\"Another string\"")));
|
||||
}
|
||||
|
@@ -504,7 +504,7 @@ TEST_F(MainloopTest, get_routine_id)
|
||||
{
|
||||
cptestPrepareToDie();
|
||||
auto cb = [this] () {
|
||||
EXPECT_EQ(mainloop->getCurrentRoutineId().unpack(), 1);
|
||||
EXPECT_EQ(mainloop->getCurrentRoutineId().unpack(), 1u);
|
||||
EXPECT_DEATH(mainloop->run(), "MainloopComponent::Impl::run was called while it was already running");
|
||||
};
|
||||
mainloop->addOneTimeRoutine(
|
||||
|
@@ -76,7 +76,7 @@ public:
|
||||
writeToSocket(const std::string &msg)
|
||||
{
|
||||
acceptSocket();
|
||||
EXPECT_EQ(write(connection_fd, msg.data(), msg.size()), msg.size());
|
||||
EXPECT_EQ(write(connection_fd, msg.data(), msg.size()), static_cast<int>(msg.size()));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -176,6 +176,8 @@ Report::getSyslog() const
|
||||
if (!origin_syslog.empty()) {
|
||||
report.push(origin_syslog);
|
||||
}
|
||||
auto severity_str = "eventSeverity=\"" + TagAndEnumManagement::convertToString(severity) + '"';
|
||||
report.push(severity_str);
|
||||
if (!event_data_syslog.empty()) {
|
||||
report.push(event_data_syslog);
|
||||
}
|
||||
@@ -218,6 +220,8 @@ Report::getCef() const
|
||||
if (!origin_cef.empty()) {
|
||||
report.pushExtension(origin_cef);
|
||||
}
|
||||
auto severity_str = "eventSeverity=\"" + TagAndEnumManagement::convertToString(severity) + '"';
|
||||
report.pushExtension(severity_str);
|
||||
if (!event_data_cef.empty()) {
|
||||
report.pushExtension(event_data_cef);
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ TEST(TagTest, TagStringTest)
|
||||
set<string> tags_string;
|
||||
for (Tags tag : makeRange<Tags>()) {
|
||||
tags_string = TagAndEnumManagement::convertToString({tag});
|
||||
ASSERT_EQ(tags_string.size(), 1);
|
||||
ASSERT_EQ(tags_string.size(), 1u);
|
||||
Maybe<Tags> tag_from_string = TagAndEnumManagement::convertStringToTag(*tags_string.begin());
|
||||
ASSERT_TRUE(tag_from_string.ok());
|
||||
EXPECT_EQ(tag_from_string.unpack(), tag);
|
||||
@@ -571,7 +571,8 @@ TEST_F(ReportTest, testSyslogWithoutServiceName)
|
||||
report.getSyslog(),
|
||||
"<133>1 0:0:0.123Z cpnano-agent-001 UnnamedNanoService - 0 - "
|
||||
"title='Log Test' agent=\"Secret\" eventTraceId=\"\" eventSpanId=\"\" "
|
||||
"issuingEngineVersion=\"\" serviceName=\"Unnamed Nano Service\" serviceId=\"\" serviceFamilyId=\"\""
|
||||
"issuingEngineVersion=\"\" serviceName=\"Unnamed Nano Service\" serviceId=\"\" serviceFamilyId=\"\" "
|
||||
"eventSeverity=\"Info\""
|
||||
);
|
||||
}
|
||||
|
||||
@@ -612,6 +613,7 @@ TEST_F(ReportTest, testSyslog)
|
||||
"title='Log Test' agent=\"Secret\"") +
|
||||
" eventTraceId=\"\" eventSpanId=\"\" issuingEngineVersion=\"\"" +
|
||||
" serviceName=\"Access Control App\" serviceId=\"\" serviceFamilyId=\"\"" +
|
||||
" eventSeverity=\"Info\"" +
|
||||
string(" ArrayOfArraies=\"[ [ a, b \\], [ 1, 2 \\] \\]\"") +
|
||||
string(" DataWithNewLine=\"new\\r\\nline\"") +
|
||||
string(" DataWithQuote=\"data\\'bla\"");
|
||||
@@ -654,7 +656,9 @@ TEST_F(ReportTest, testCef)
|
||||
"CEF:0|Check Point|AccessControlApp||Event Driven|Log Test|Low|"
|
||||
"eventTime=0:0:0.123 agent=\"Secret\" eventTraceId=\"\" eventSpanId=\"\" issuingEngineVersion=\"\""
|
||||
" serviceName=\"Access Control App\" serviceId=\"\""
|
||||
" serviceFamilyId=\"\" Bond=\"1\" DataWithQuote=\"data\\'bla\""
|
||||
" serviceFamilyId=\"\" Bond=\"1\""
|
||||
" eventSeverity=\"Info\""
|
||||
" DataWithQuote=\"data\\'bla\""
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -162,7 +162,7 @@ TEST_F(RestConfigTest, basic_flow)
|
||||
I_MainLoop::Routine stop_routine = [&] () {
|
||||
EXPECT_EQ(connect(file_descriptor, (struct sockaddr*)&sa, sizeof(struct sockaddr)), 0);
|
||||
string msg = "POST /add-test HTTP/1.1\r\nContent-Length: 10\r\n\r\n{\"num\": 5}";
|
||||
EXPECT_EQ(write(file_descriptor, msg.data(), msg.size()), msg.size());
|
||||
EXPECT_EQ(write(file_descriptor, msg.data(), msg.size()), static_cast<int>(msg.size()));
|
||||
|
||||
while(!TestServer::g_num) {
|
||||
mainloop->yield(true);
|
||||
|
@@ -264,8 +264,8 @@ TEST_F(SharedIPCTest, ensure_right_permissions)
|
||||
stat(queue_name, &info);
|
||||
EXPECT_EQ(info.st_uid, uid);
|
||||
EXPECT_EQ(info.st_gid, gid);
|
||||
EXPECT_EQ(info.st_mode & S_IRUSR, S_IRUSR);
|
||||
EXPECT_EQ(info.st_mode & S_IWUSR, S_IWUSR);
|
||||
EXPECT_NE(info.st_mode & S_IXUSR, S_IXUSR);
|
||||
EXPECT_EQ(info.st_mode & S_IRUSR, static_cast<uint>(S_IRUSR));
|
||||
EXPECT_EQ(info.st_mode & S_IWUSR, static_cast<uint>(S_IWUSR));
|
||||
EXPECT_NE(info.st_mode & S_IXUSR, static_cast<uint>(S_IXUSR));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user