Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Empty Env varibales for STSWebIdentity #246

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/credentials_provider_sts_web_identity.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ static void s_check_or_get_with_profile_config(
if ((!(*target) || !(*target)->len)) {
if (*target) {
aws_string_destroy(*target);
*target = NULL;
}
const struct aws_profile_property *property = aws_profile_get_property(profile, config_key);
if (property) {
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ add_test_case(credentials_provider_x509_real_new_destroy)
add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_parameters)
add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_env)
add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_config)
add_net_test_case(credentials_provider_sts_web_identity_fail_with_empty_config_and_env)
add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_cached_config)
add_net_test_case(credentials_provider_sts_web_identity_new_failed_without_env_and_config)
add_net_test_case(credentials_provider_sts_web_identity_connect_failure)
Expand Down
42 changes: 42 additions & 0 deletions tests/credentials_provider_sts_web_identity_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,48 @@ AWS_TEST_CASE(
credentials_provider_sts_web_identity_new_destroy_from_config,
s_credentials_provider_sts_web_identity_new_destroy_from_config);

AWS_STATIC_STRING_FROM_LITERAL(
s_basic_config_file,
"[profile foo]\n"
"region=us-east-1\n");

static int s_credentials_provider_sts_web_identity_fail_with_empty_config_and_env(
struct aws_allocator *allocator,
void *ctx) {
(void)ctx;

s_aws_sts_web_identity_tester_init(allocator);

struct aws_byte_buf content_buf = aws_byte_buf_from_c_str(aws_string_c_str(s_basic_config_file));

struct aws_string *config_file_contents = aws_string_new_from_array(allocator, content_buf.buffer, content_buf.len);
ASSERT_TRUE(config_file_contents != NULL);
aws_byte_buf_clean_up(&content_buf);

s_aws_sts_web_identity_test_init_config_profile(allocator, config_file_contents);
aws_string_destroy(config_file_contents);

s_aws_sts_web_identity_test_init_env_parameters(allocator, "", "", "", "");

struct aws_credentials_provider_sts_web_identity_options options = {
.bootstrap = NULL,
.tls_ctx = s_tester.tls_ctx,
.function_table = &s_mock_function_table,
.shutdown_options =
{
.shutdown_callback = s_on_shutdown_complete,
.shutdown_user_data = NULL,
},
};

ASSERT_NULL(aws_credentials_provider_new_sts_web_identity(allocator, &options));
s_aws_sts_web_identity_tester_cleanup();
return 0;
}
AWS_TEST_CASE(
credentials_provider_sts_web_identity_fail_with_empty_config_and_env,
s_credentials_provider_sts_web_identity_fail_with_empty_config_and_env);

static int s_credentials_provider_sts_web_identity_new_destroy_from_cached_config(
struct aws_allocator *allocator,
void *ctx) {
Expand Down
Loading