Skip to content

Commit

Permalink
tests: internal: aws_credentials_http: fix leaks
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <eduardo@calyptia.com>
  • Loading branch information
edsiper committed Aug 27, 2024
1 parent f0e6f2b commit ec2209c
Showing 1 changed file with 3 additions and 48 deletions.
51 changes: 3 additions & 48 deletions tests/internal/aws_credentials_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ static void test_http_provider()
struct flb_aws_credentials *creds;
int ret;
struct flb_config *config;
flb_sds_t host;
flb_sds_t path;

g_request_count = 0;

Expand All @@ -194,19 +192,6 @@ static void test_http_provider()
return;
}

host = flb_sds_create("127.0.0.1");
if (!host) {
flb_errno();
flb_config_exit(config);
return;
}
path = flb_sds_create("/happy-case");
if (!path) {
flb_errno();
flb_config_exit(config);
return;
}

provider = flb_http_provider_create(config, generator_in_test());

if (!provider) {
Expand Down Expand Up @@ -261,8 +246,6 @@ static void test_http_provider_error_case()
struct flb_aws_credentials *creds;
int ret;
struct flb_config *config;
flb_sds_t host;
flb_sds_t path;

g_request_count = 0;

Expand All @@ -272,21 +255,7 @@ static void test_http_provider_error_case()
return;
}

host = flb_sds_create("127.0.0.1");
if (!host) {
flb_errno();
flb_config_exit(config);
return;
}
path = flb_sds_create("/error-case");
if (!path) {
flb_errno();
flb_config_exit(config);
return;
}

provider = flb_http_provider_create(config, generator_in_test());

if (!provider) {
flb_errno();
flb_config_exit(config);
Expand All @@ -311,6 +280,7 @@ static void test_http_provider_error_case()
*/
TEST_CHECK(g_request_count == 3);


flb_aws_provider_destroy(provider);
flb_config_exit(config);
}
Expand All @@ -321,8 +291,6 @@ static void test_http_provider_malformed_response()
struct flb_aws_credentials *creds;
int ret;
struct flb_config *config;
flb_sds_t host;
flb_sds_t path;

g_request_count = 0;

Expand All @@ -334,19 +302,6 @@ static void test_http_provider_malformed_response()

mk_list_init(&config->upstreams);

host = flb_sds_create("127.0.0.1");
if (!host) {
flb_errno();
flb_config_exit(config);
return;
}
path = flb_sds_create("/malformed");
if (!path) {
flb_errno();
flb_config_exit(config);
return;
}

provider = flb_http_provider_create(config, generator_in_test());

if (!provider) {
Expand Down Expand Up @@ -774,7 +729,6 @@ static void test_http_validator_invalid_host()

flb_aws_client_mock_destroy_generator();
flb_free(config);

}

static void test_http_validator_invalid_port()
Expand All @@ -789,6 +743,8 @@ static void test_http_validator_invalid_port()

config = flb_calloc(1, sizeof(struct flb_config));
TEST_ASSERT(config != NULL);
TEST_ASSERT(config != NULL);

mk_list_init(&config->upstreams);

/* provider creation will fail with error message indicating port was invalid */
Expand All @@ -797,7 +753,6 @@ static void test_http_validator_invalid_port()

flb_aws_client_mock_destroy_generator();
flb_free(config);

}

TEST_LIST = {
Expand Down

0 comments on commit ec2209c

Please sign in to comment.