Skip to content

Commit

Permalink
Rename cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 committed May 2, 2024
1 parent 16d4a00 commit 40f0e92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion source/credentials_provider_ecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,11 @@ struct aws_credentials_provider *aws_credentials_provider_new_ecs_from_environme
relative_uri_str != NULL && relative_uri_str->len != 0) {

/* Using RELATIVE_URI */
AWS_LOGF_INFO(
AWS_LS_AUTH_CREDENTIALS_PROVIDER,
"ECS provider: using relative uri %s",
aws_string_c_str(relative_uri_str));

explicit_options.path_and_query = aws_byte_cursor_from_string(relative_uri_str);
explicit_options.host = aws_byte_cursor_from_string(s_ecs_host);
explicit_options.port = 80;
Expand All @@ -674,13 +679,15 @@ struct aws_credentials_provider *aws_credentials_provider_new_ecs_from_environme
full_uri_str != NULL && full_uri_str->len != 0) {

/* Using FULL_URI */
AWS_LOGF_INFO(
AWS_LS_AUTH_CREDENTIALS_PROVIDER, "ECS provider: using full uri %s", aws_string_c_str(full_uri_str));
struct aws_byte_cursor full_uri_cursor = aws_byte_cursor_from_string(full_uri_str);
if (aws_uri_init_parse(&full_uri, allocator, &full_uri_cursor)) {
goto cleanup;
}

explicit_options.host = *aws_uri_host_name(&full_uri);
explicit_options.path_and_query = *aws_uri_path_and_query(&full_uri); // TODO: / defaut???
explicit_options.path_and_query = *aws_uri_path_and_query(&full_uri);
if (explicit_options.path_and_query.len == 0) {
explicit_options.path_and_query = aws_byte_cursor_from_c_str("/");
}
Expand Down
10 changes: 5 additions & 5 deletions tests/credentials_provider_ecs_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ AWS_STATIC_STRING_FROM_LITERAL(s_good_response_expiration, "2020-02-25T06:03:31Z

/* Check that expected URI and Authorization token were used to make request.
* URI must be super explicit, specifying scheme and port. */
static int s_check_ecs_tester_request(const char *expected_uri_cstr, const char *expected_token) {
static int s_check_ecs_tester_request_uri_and_authorization(const char *expected_uri_cstr, const char *expected_token) {
struct aws_byte_cursor expected_uri_cursor = aws_byte_cursor_from_c_str(expected_uri_cstr);
struct aws_uri expected_uri;
ASSERT_SUCCESS(aws_uri_init_parse(&expected_uri, s_tester.allocator, &expected_uri_cursor));
Expand Down Expand Up @@ -516,7 +516,7 @@ static int s_do_ecs_success_test(
s_aws_wait_for_credentials_result();

aws_mutex_lock(&s_tester.lock);
ASSERT_SUCCESS(s_check_ecs_tester_request(expected_uri, expected_token));
ASSERT_SUCCESS(s_check_ecs_tester_request_uri_and_authorization(expected_uri, expected_token));
ASSERT_TRUE(s_tester.has_received_credentials_callback == true);
ASSERT_TRUE(s_tester.credentials != NULL);
ASSERT_CURSOR_VALUE_STRING_EQUALS(aws_credentials_get_access_key_id(s_tester.credentials), s_good_access_key_id);
Expand Down Expand Up @@ -584,7 +584,7 @@ static int s_do_ecs_env_success_test(
s_aws_wait_for_credentials_result();

aws_mutex_lock(&s_tester.lock);
ASSERT_SUCCESS(s_check_ecs_tester_request(expected_uri, expected_token));
ASSERT_SUCCESS(s_check_ecs_tester_request_uri_and_authorization(expected_uri, expected_token));

ASSERT_TRUE(s_tester.has_received_credentials_callback == true);
ASSERT_TRUE(s_tester.credentials != NULL);
Expand Down Expand Up @@ -688,7 +688,7 @@ static int s_credentials_provider_ecs_basic_success_token_file(struct aws_alloca
s_aws_wait_for_credentials_result();

aws_mutex_lock(&s_tester.lock);
ASSERT_SUCCESS(s_check_ecs_tester_request(
ASSERT_SUCCESS(s_check_ecs_tester_request_uri_and_authorization(
"http://www.xxx123321testmocknonexsitingawsservice.com:80/path/to/resource/?a=b&c=d",
aws_string_c_str(auth_token)));

Expand All @@ -707,7 +707,7 @@ static int s_credentials_provider_ecs_basic_success_token_file(struct aws_alloca
s_aws_wait_for_credentials_result();

aws_mutex_lock(&s_tester.lock);
ASSERT_SUCCESS(s_check_ecs_tester_request(
ASSERT_SUCCESS(s_check_ecs_tester_request_uri_and_authorization(
"http://www.xxx123321testmocknonexsitingawsservice.com:80/path/to/resource/?a=b&c=d",
aws_string_c_str(auth_token2)));

Expand Down

0 comments on commit 40f0e92

Please sign in to comment.