Skip to content

Commit

Permalink
chore(appsec: tests): apply feedbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Rulleau <[email protected]>
  • Loading branch information
Leiyks committed Nov 20, 2024
1 parent bff8feb commit f8f3c99
Show file tree
Hide file tree
Showing 3 changed files with 571 additions and 26 deletions.
38 changes: 18 additions & 20 deletions appsec/tests/helper/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,9 @@ int count_schemas(const std::map<std::string, std::string> &meta)
return schemas;
}

network::client_init::request get_default_client_init_msg(
std::string rule_config = "valid")
network::client_init::request get_default_client_init_msg()
{
std::string fn;
if (rule_config == "valid")
fn = create_sample_rules_ok();
else if (rule_config == "fingerprint")
fn = create_sample_rules_ok_with_fingerprint();
else
fn = create_sample_rules_invalid();

auto fn = create_sample_rules_ok();
network::client_init::request msg;
msg.pid = 1729;
msg.enabled_configuration = true;
Expand All @@ -101,11 +93,10 @@ network::client_init::request get_default_client_init_msg(
return msg;
}

void set_extension_configuration_to(mock::broker *broker, client &c,
std::optional<bool> status, std::string rule_config = "valid")
void set_extension_configuration_to(
mock::broker *broker, client &c, std::optional<bool> status)
{
network::client_init::request msg =
get_default_client_init_msg(rule_config);
network::client_init::request msg = get_default_client_init_msg();
msg.enabled_configuration = status;

send_client_init(broker, c, std::move(msg));
Expand Down Expand Up @@ -1781,8 +1772,11 @@ TEST(ClientTest, RequestInitWithFingerprint)

client c(smanager, std::unique_ptr<mock::broker>(broker));

set_extension_configuration_to(
broker, c, EXTENSION_CONFIGURATION_ENABLED, "fingerprint");
network::client_init::request msg = get_default_client_init_msg();
msg.engine_settings.rules_file = create_sample_rules_ok_with_fingerprint();
msg.enabled_configuration = EXTENSION_CONFIGURATION_ENABLED;

send_client_init(broker, c, std::move(msg));

// Request Init
{
Expand Down Expand Up @@ -1867,9 +1861,11 @@ TEST(ClientTest, RequestExecWithFingerprint)

client c(smanager, std::unique_ptr<mock::broker>(broker));

set_extension_configuration_to(
broker, c, EXTENSION_CONFIGURATION_ENABLED, "fingerprint");
network::client_init::request msg = get_default_client_init_msg();
msg.engine_settings.rules_file = create_sample_rules_ok_with_fingerprint();
msg.enabled_configuration = EXTENSION_CONFIGURATION_ENABLED;

send_client_init(broker, c, std::move(msg));
request_init(broker, c);

// Request Exec
Expand Down Expand Up @@ -1953,9 +1949,11 @@ TEST(ClientTest, RequestShutdownWithFingerprint)

client c(smanager, std::unique_ptr<mock::broker>(broker));

set_extension_configuration_to(
broker, c, EXTENSION_CONFIGURATION_ENABLED, "fingerprint");
network::client_init::request msg = get_default_client_init_msg();
msg.engine_settings.rules_file = create_sample_rules_ok_with_fingerprint();
msg.enabled_configuration = EXTENSION_CONFIGURATION_ENABLED;

send_client_init(broker, c, std::move(msg));
request_init(broker, c);

// Request Shutdown
Expand Down
Loading

0 comments on commit f8f3c99

Please sign in to comment.