diff --git a/include/fluent-bit/flb_aws_credentials.h b/include/fluent-bit/flb_aws_credentials.h index 539f124f1f7..d62a8af0cec 100644 --- a/include/fluent-bit/flb_aws_credentials.h +++ b/include/fluent-bit/flb_aws_credentials.h @@ -143,6 +143,12 @@ struct aws_credentials_provider *new_sts_provider(struct flb_config *config, */ struct aws_credentials_provider *new_environment_provider(); + +/* + * New AWS Profile provider, reads from the shared credentials file + */ +struct aws_credentials_provider *new_profile_provider(); + /* * Helper functions */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7a256bfb3b..321f6e693ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,6 +102,7 @@ if(FLB_AWS) "flb_signv4.c" "flb_aws_credentials.c" "flb_aws_credentials_sts.c" + "flb_aws_credentials_profile.c" "flb_aws_util.c" ) endif() diff --git a/src/flb_aws_credentials_profile.c b/src/flb_aws_credentials_profile.c new file mode 100644 index 00000000000..e1bc933033e --- /dev/null +++ b/src/flb_aws_credentials_profile.c @@ -0,0 +1,436 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2019 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #include + #include + #include + #include + #include + + #include + #include + #include + + #include + #include + #include + #include + +#define ACCESS_KEY_PROPERTY_NAME "aws_access_key_id" +#define SECRET_KEY_PROPERTY_NAME "aws_secret_access_key" +#define SESSION_TOKEN_PROPERTY_NAME "aws_session_token" + +#define AWS_PROFILE "AWS_PROFILE" +#define AWS_DEFAULT_PROFILE "AWS_DEFAULT_PROFILE" + +#define AWS_SHARED_CREDENTIALS_FILE "AWS_SHARED_CREDENTIALS_FILE" + +/* Declarations */ +struct aws_credentials_provider_profile; +static int get_profile(struct aws_credentials_provider_profile *implementation); +static int parse_file(char *buf, char *profile, struct aws_credentials *creds); +static flb_sds_t parse_property_value(char *s); +static char *parse_property_line(char *line); +static int has_profile(char *line, char* profile); +static int is_profile_line(char *line); + +/* + * A provider that reads from the shared credentials file. + */ +struct aws_credentials_provider_profile { + struct aws_credentials *credentials; + + flb_sds_t profile; + flb_sds_t path; +}; + +struct aws_credentials *get_credentials_fn_profile(struct + aws_credentials_provider + *provider) +{ + struct aws_credentials *creds; + int ret; + struct aws_credentials_provider_profile *implementation = provider-> + implementation; + + flb_debug("[aws_credentials] Retrieving credentials for " + "AWS Profile %s", implementation->profile); + + if (!implementation->credentials) { + ret = get_profile(implementation); + if (ret < 0) { + flb_error("[aws_credentials] Failed to retrieve credentials for " + "AWS Profile %s", implementation->profile); + return NULL; + } + } + + creds = flb_malloc(sizeof(struct aws_credentials)); + if (!creds) { + flb_errno(); + goto error; + } + + creds->access_key_id = flb_sds_create(implementation->credentials->access_key_id); + if (!creds->access_key_id) { + flb_errno(); + goto error; + } + + creds->secret_access_key = flb_sds_create(implementation->credentials->secret_access_key); + if (!creds->secret_access_key) { + flb_errno(); + goto error; + } + + if (implementation->credentials->session_token) { + creds->session_token = flb_sds_create(implementation->credentials->session_token); + if (!creds->session_token) { + flb_errno(); + goto error; + } + + } else { + creds->session_token = NULL; + } + + return creds; + +error: + aws_credentials_destroy(creds); + return NULL; +} + +int refresh_fn_profile(struct aws_credentials_provider *provider) { + struct aws_credentials_provider_profile *implementation = provider-> + implementation; + flb_debug("[aws_credentials] Refresh called on the profile provider"); + return get_profile(implementation); +} + +void destroy_fn_profile(struct aws_credentials_provider *provider) { + struct aws_credentials_provider_profile *implementation = provider-> + implementation; + + if (implementation) { + if (implementation->credentials) { + aws_credentials_destroy(implementation->credentials); + } + + if (implementation->profile) { + flb_sds_destroy(implementation->profile); + } + + if (implementation->path) { + flb_sds_destroy(implementation->path); + } + + flb_free(implementation); + provider->implementation = NULL; + } + + return; +} + +static struct aws_credentials_provider_vtable profile_provider_vtable = { + .get_credentials = get_credentials_fn_profile, + .refresh = refresh_fn_profile, + .destroy = destroy_fn_profile, +}; + +struct aws_credentials_provider *new_profile_provider() +{ + struct aws_credentials_provider *provider = NULL; + struct aws_credentials_provider_profile *implementation = NULL; + char *path; + char *profile; + char *home; + + provider = flb_calloc(1, sizeof(struct aws_credentials_provider)); + + if (!provider) { + flb_errno(); + return NULL; + } + + implementation = flb_calloc(1, + sizeof( + struct aws_credentials_provider_profile)); + + if (!implementation) { + flb_errno(); + goto error; + } + + provider->provider_vtable = &profile_provider_vtable; + provider->implementation = implementation; + + /* find the shared credentials file */ + path = getenv(AWS_SHARED_CREDENTIALS_FILE); + if (path && strlen(path) > 0) { + implementation->path = flb_sds_create(path); + if (!implementation->path) { + flb_errno(); + goto error; + } + } else { + /* default path: $HOME/.aws/credentials */ + home = getenv("HOME"); + if (!home || strlen(home) == 0) { + flb_warn("[aws_credentials] Failed to initialized profile provider: " + "$HOME not set and AWS_SHARED_CREDENTIALS_FILE not set."); + aws_provider_destroy(provider); + return NULL; + } + + /* join file path */ + implementation->path = flb_sds_create(home); + if (!implementation->path) { + flb_errno(); + goto error; + } + if (home[strlen(home) - 1] == '/') { + implementation->path = flb_sds_cat(implementation->path, + ".aws/credentials", 16); + if (!implementation->path) { + flb_errno(); + goto error; + } + } else { + implementation->path = flb_sds_cat(implementation->path, + "/.aws/credentials", 17); + if (!implementation->path) { + flb_errno(); + goto error; + } + } + } + + /* AWS profile name */ + profile = getenv(AWS_PROFILE); + if (profile && strlen(profile) > 0) { + goto set_profile; + } + + profile = getenv(AWS_DEFAULT_PROFILE); + if (profile && strlen(profile) > 0) { + goto set_profile; + } + + profile = "default"; + +set_profile: + implementation->profile = flb_sds_create(profile); + if (!implementation->profile) { + flb_errno(); + goto error; + } + + return provider; + +error: + aws_provider_destroy(provider); + return NULL; +} + +static int is_profile_line(char *line) { + if (strlen(line) > 1 && line[0] == '[') { + return FLB_TRUE; + } + return FLB_FALSE; +} + +/* Called on lines that have is_profile_line == True */ +static int has_profile(char *line, char* profile) { + char *end_bracket = strchr(line, ']'); + if (!end_bracket) { + flb_warn("[aws_credentials] Profile header has no ending bracket:\n %s", + line); + return FLB_FALSE; + } + *end_bracket = '\0'; + + if (strcmp(&line[1], profile) == 0) { + return FLB_TRUE; + } + + return FLB_FALSE; +} + +/* + * Sets a null byte such that line becomes the property name + * Returns a pointer to the rest of the line (the value), if successful. + */ +static char *parse_property_line(char *line) { + int len = strlen(line); + int found_delimeter = FLB_FALSE; + int i = 0; + + if (isspace(line[0])) { + /* property line can not start with whitespace */ + return NULL; + } + + /* + * Go through the line char by char, once we find whitespace/= we are + * passed the property name. Return the first char of the property value. + * There should be a single "=" separating name and value. + */ + for (i=0; i < (len - 1); i++) { + if (isspace(line[i])) { + line[i] = '\0'; + } else if (found_delimeter == FLB_FALSE && line[i] == '=') { + found_delimeter = FLB_TRUE; + line[i] = '\0'; + } else if (found_delimeter == FLB_TRUE) { + return &line[i]; + } + } + + return NULL; +} + +/* called on the rest of a line after parse_property_line is called */ +static flb_sds_t parse_property_value(char *s) { + int len = strlen(s); + int i = 0; + char *val = NULL; + flb_sds_t prop; + + for (i=0; i < len; i++) { + if (isspace(s[i])) { + s[i] = '\0'; + continue; + } else if (!val) { + val = &s[i]; + } + } + + if (!val) { + flb_error("[aws_credentials] Could not parse credential value from" + "%s", s); + } + + prop = flb_sds_create(val); + if (!prop) { + flb_errno(); + return NULL; + } + + return prop; +} + +/* + * Parses a shared credentials file. + * Expects the contents of 'creds' to be initialized to NULL (i.e use calloc). + */ +static int parse_file(char *buf, char *profile, struct aws_credentials *creds) +{ + char *line; + char *line_end; + char *prop_val = NULL; + int found_profile = FLB_FALSE; + + line = buf; + + while (line[0] != '\0') { + /* turn the line into a C string */ + line_end = strchr(line, '\n'); + if (line_end) { + *line_end = '\0'; + } + + if (is_profile_line(line) == FLB_TRUE) { + if (found_profile == FLB_TRUE) { + break; + } + if (has_profile(line, profile)) { + found_profile = FLB_TRUE; + } + } else { + prop_val = parse_property_line(line); + if (prop_val && found_profile == FLB_TRUE) { + if (strcmp(line, ACCESS_KEY_PROPERTY_NAME) == 0) { + creds->access_key_id = parse_property_value(prop_val); + } + if (strcmp(line, SECRET_KEY_PROPERTY_NAME) == 0) { + creds->secret_access_key = parse_property_value(prop_val); + } + if (strcmp(line, SESSION_TOKEN_PROPERTY_NAME) == 0) { + creds->session_token = parse_property_value(prop_val); + } + } + } + + /* advance to next line */ + if (line_end) { + line = line_end + 1; + } else { + break; + } + } + + if (creds->access_key_id && creds->secret_access_key) { + return 0; + } + flb_error("[aws_credentials] %s and %s keys not parsed in shared " + "credentials file for profile %s.", ACCESS_KEY_PROPERTY_NAME, + SECRET_KEY_PROPERTY_NAME, profile); + return -1; +} + +static int get_profile(struct aws_credentials_provider_profile *implementation) +{ + struct aws_credentials *creds = NULL; + int ret; + char* buf = NULL; + size_t size; + + flb_debug("[aws_credentials] Reading shared credentials file.."); + + creds = flb_calloc(1, sizeof(struct aws_credentials)); + if (!creds) { + flb_errno(); + return -1; + } + + ret = file_to_buf(implementation->path, &buf, &size); + if (ret < 0) { + flb_error("[aws_credentials] Could not read shared credentials file %s", + implementation->path); + goto error; + } + + ret = parse_file(buf, implementation->profile, creds); + flb_free(buf); + + if (ret < 0) { + flb_error("[aws_credentials] Could not parse shared credentials file: " + "valid profile with name '%s' not found", + implementation->profile); + goto error; + } + + implementation->credentials = creds; + return 0; + +error: + aws_credentials_destroy(creds); + return -1; +} diff --git a/tests/internal/CMakeLists.txt b/tests/internal/CMakeLists.txt index a616bd804fd..0ba8d438c2b 100644 --- a/tests/internal/CMakeLists.txt +++ b/tests/internal/CMakeLists.txt @@ -6,6 +6,7 @@ set(UNIT_TESTS_FILES aws_util.c aws_credentials.c aws_credentials_sts.c + aws_credentials_profile.c pack.c pipe.c sds.c diff --git a/tests/internal/aws_credentials_profile.c b/tests/internal/aws_credentials_profile.c new file mode 100644 index 00000000000..f13df829717 --- /dev/null +++ b/tests/internal/aws_credentials_profile.c @@ -0,0 +1,360 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +#include +#include +#include +#include + +#include "flb_tests_internal.h" + +#define TEST_CREDENTIALS_FILE FLB_TESTS_DATA_PATH "/data/aws_credentials/\ +shared_credentials_file.ini" + +/* these credentials look real but are not */ +#define AKID_DEFAULT_PROFILE "ASIASDMPIJWXJAXT3O3T" +#define SKID_DEFAULT_PROFILE "EAUBpd/APPT4Nfi4DWY3gnt5TU/4T49laqS5zh8W" +#define TOKEN_DEFAULT_PROFILE "IQoJb3JpZ2luX2VjEOD//////////wEaCNVzLWVh\ +c3QtMSJHMEUCIKCn7v/EDowMZvJnciSJbxA7rIV4p1K6pOUvcLHM+9EzNgIgeiYbfA47DGS\ +qoEZS3yrRWGN8Fr4Q/bK7ANRgv09Hth8q1gEIWRABGgwxNDQ3MTg3MTE0NzAiDGSqzyXiic\ +OZp63afiqzAUyWOljOn5HaIxRfpQ5pTf+o4roJ2KPlHn+XHEKJZKien4Ydm7zeVi7SbPLKo\ +cjmjYJd31PrlbJ43C6AyrhmY57qaD7Zz4N3N0V6mekzvlAeARXsa4deflsbemqkp1WVsBLk\ +O6qUuk+N04+MxIVXAxkW9RSPRTVjxeS2m5Yobygto58WLFE8gacRoNd4lCK4JUmEdiaxJEQ\ +QO7leZ3v1XxQr6QBS8P/GmcJYcQTxlA6AFQxIMJKGwfAFOuMB2cEc8cF2Htiqf3LVGMk/6b\ +YKkW7fHUtrnttp28jgWtbbLtFbX/zIdlqwm73Ryp7lI+xkM4XNIT+6ZKa4Xw0/Zw3xLzlk3\ +jic6QWPAcffwR6kOunoTOWJzPskK/RZ4Cd+GyGarxG27Cz6xolAzAsDpdGQwV7kCCUPi6/V\ +HjefwKEk9HjZfejC5WuCS173qFrU9kNb4IrYhnK+wmRzzJfgpWUwerdiJKBz95j1iW9rP1a\ +8p1xLR3EXUMN3LIW0+gP8sFjg5iiqDkaS/tUXWZndM2QdJLcrxwAutFchc0nqJHYTijw=" + +#define AKID_NONDEFAULT_PROFILE "akid" +#define SKID_NONDEFAULT_PROFILE "skid" + +#define AKID_NOSPACE_PROFILE "akidnospace" +#define SKID_NOSPACE_PROFILE "skidnospace" +#define TOKEN_NOSPACE_PROFILE "tokennospace" + +#define AKID_WEIRDWHITESPACE_PROFILE "akidweird" +#define SKID_WEIRDWHITESPACE_PROFILE "skidweird" +#define TOKEN_WEIRDWHITESPACE_PROFILE "tokenweird///token==" + +static void test_profile_default() +{ + struct aws_credentials_provider *provider; + struct aws_credentials *creds; + int ret; + + /* set environment */ + ret = setenv("AWS_SHARED_CREDENTIALS_FILE", TEST_CREDENTIALS_FILE, 1); + if (ret < 0) { + flb_errno(); + return; + } + + provider = new_profile_provider(); + if (!provider) { + flb_errno(); + return; + } + + /* repeated calls to get credentials should return the same set */ + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_DEFAULT_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_DEFAULT_PROFILE, creds->secret_access_key) == 0); + TEST_CHECK(strcmp(TOKEN_DEFAULT_PROFILE, creds->session_token) == 0); + + aws_credentials_destroy(creds); + + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_DEFAULT_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_DEFAULT_PROFILE, creds->secret_access_key) == 0); + TEST_CHECK(strcmp(TOKEN_DEFAULT_PROFILE, creds->session_token) == 0); + + aws_credentials_destroy(creds); + + /* refresh should return 0 (success) */ + ret = provider->provider_vtable->refresh(provider); + TEST_CHECK(ret == 0); + + aws_provider_destroy(provider); + + /* unset environment */ + ret = unsetenv("AWS_SHARED_CREDENTIALS_FILE"); + if (ret < 0) { + flb_errno(); + return; + } +} + +static void test_profile_non_default() +{ + struct aws_credentials_provider *provider; + struct aws_credentials *creds; + int ret; + + /* set environment */ + ret = setenv("AWS_SHARED_CREDENTIALS_FILE", TEST_CREDENTIALS_FILE, 1); + if (ret < 0) { + flb_errno(); + return; + } + + ret = setenv("AWS_PROFILE", "nondefault", 1); + if (ret < 0) { + flb_errno(); + return; + } + + provider = new_profile_provider(); + if (!provider) { + flb_errno(); + return; + } + + /* repeated calls to get credentials should return the same set */ + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_NONDEFAULT_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_NONDEFAULT_PROFILE, creds->secret_access_key) == 0); + TEST_CHECK(creds->session_token == NULL); + + aws_credentials_destroy(creds); + + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_NONDEFAULT_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_NONDEFAULT_PROFILE, creds->secret_access_key) == 0); + TEST_CHECK(creds->session_token == NULL); + + aws_credentials_destroy(creds); + + /* refresh should return 0 (success) */ + ret = provider->provider_vtable->refresh(provider); + TEST_CHECK(ret == 0); + + aws_provider_destroy(provider); + + /* unset environment */ + ret = unsetenv("AWS_SHARED_CREDENTIALS_FILE"); + if (ret < 0) { + flb_errno(); + return; + } + ret = unsetenv("AWS_PROFILE"); + if (ret < 0) { + flb_errno(); + return; + } +} + +static void test_profile_no_space() +{ + struct aws_credentials_provider *provider; + struct aws_credentials *creds; + int ret; + + /* set environment */ + ret = setenv("AWS_SHARED_CREDENTIALS_FILE", TEST_CREDENTIALS_FILE, 1); + if (ret < 0) { + flb_errno(); + return; + } + + ret = setenv("AWS_DEFAULT_PROFILE", "nospace", 1); + if (ret < 0) { + flb_errno(); + return; + } + + provider = new_profile_provider(); + if (!provider) { + flb_errno(); + return; + } + + /* repeated calls to get credentials should return the same set */ + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_NOSPACE_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_NOSPACE_PROFILE, creds->secret_access_key) == 0); + TEST_CHECK(strcmp(TOKEN_NOSPACE_PROFILE, creds->session_token) == 0); + + aws_credentials_destroy(creds); + + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_NOSPACE_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_NOSPACE_PROFILE, creds->secret_access_key) == 0); + TEST_CHECK(strcmp(TOKEN_NOSPACE_PROFILE, creds->session_token) == 0); + + aws_credentials_destroy(creds); + + /* refresh should return 0 (success) */ + ret = provider->provider_vtable->refresh(provider); + TEST_CHECK(ret == 0); + + aws_provider_destroy(provider); + + /* unset environment */ + ret = unsetenv("AWS_SHARED_CREDENTIALS_FILE"); + if (ret < 0) { + flb_errno(); + return; + } + ret = unsetenv("AWS_DEFAULT_PROFILE"); + if (ret < 0) { + flb_errno(); + return; + } +} + +static void test_profile_weird_whitespace() +{ + struct aws_credentials_provider *provider; + struct aws_credentials *creds; + int ret; + + /* set environment */ + ret = setenv("AWS_SHARED_CREDENTIALS_FILE", TEST_CREDENTIALS_FILE, 1); + if (ret < 0) { + flb_errno(); + return; + } + + ret = setenv("AWS_DEFAULT_PROFILE", "weirdwhitespace", 1); + if (ret < 0) { + flb_errno(); + return; + } + + provider = new_profile_provider(); + if (!provider) { + flb_errno(); + return; + } + + /* repeated calls to get credentials should return the same set */ + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_WEIRDWHITESPACE_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_WEIRDWHITESPACE_PROFILE, + creds->secret_access_key) == 0); + TEST_CHECK(strcmp(TOKEN_WEIRDWHITESPACE_PROFILE, creds->session_token) == 0); + + aws_credentials_destroy(creds); + + creds = provider->provider_vtable->get_credentials(provider); + if (!creds) { + flb_errno(); + return; + } + TEST_CHECK(strcmp(AKID_WEIRDWHITESPACE_PROFILE, creds->access_key_id) == 0); + TEST_CHECK(strcmp(SKID_WEIRDWHITESPACE_PROFILE, + creds->secret_access_key) == 0); + TEST_CHECK(strcmp(TOKEN_WEIRDWHITESPACE_PROFILE, creds->session_token) == 0); + + aws_credentials_destroy(creds); + + /* refresh should return 0 (success) */ + ret = provider->provider_vtable->refresh(provider); + TEST_CHECK(ret == 0); + + aws_provider_destroy(provider); + + /* unset environment */ + ret = unsetenv("AWS_SHARED_CREDENTIALS_FILE"); + if (ret < 0) { + flb_errno(); + return; + } + ret = unsetenv("AWS_DEFAULT_PROFILE"); + if (ret < 0) { + flb_errno(); + return; + } +} + +static void test_profile_missing() +{ + struct aws_credentials_provider *provider; + struct aws_credentials *creds; + int ret; + + /* set environment */ + ret = setenv("AWS_SHARED_CREDENTIALS_FILE", TEST_CREDENTIALS_FILE, 1); + if (ret < 0) { + flb_errno(); + return; + } + + ret = setenv("AWS_DEFAULT_PROFILE", "missing", 1); + if (ret < 0) { + flb_errno(); + return; + } + + provider = new_profile_provider(); + if (!provider) { + flb_errno(); + return; + } + + /* repeated calls to get credentials should return the same set */ + creds = provider->provider_vtable->get_credentials(provider); + TEST_CHECK(creds == NULL); + + aws_credentials_destroy(creds); + + creds = provider->provider_vtable->get_credentials(provider); + TEST_CHECK(creds == NULL); + + aws_credentials_destroy(creds); + + /* refresh should return -1 (failure) */ + ret = provider->provider_vtable->refresh(provider); + TEST_CHECK(ret < 0); + + aws_provider_destroy(provider); + + /* unset environment */ + ret = unsetenv("AWS_SHARED_CREDENTIALS_FILE"); + if (ret < 0) { + flb_errno(); + return; + } + ret = unsetenv("AWS_DEFAULT_PROFILE"); + if (ret < 0) { + flb_errno(); + return; + } +} + +TEST_LIST = { + { "test_profile_default" , test_profile_default}, + { "test_profile_non_default" , test_profile_non_default}, + { "test_profile_no_space" , test_profile_no_space}, + { "test_profile_weird_whitespace" , test_profile_weird_whitespace}, + { "test_profile_missing" , test_profile_missing}, + { 0 } +}; diff --git a/tests/internal/data/aws_credentials/shared_credentials_file.ini b/tests/internal/data/aws_credentials/shared_credentials_file.ini new file mode 100644 index 00000000000..e45c71b7d21 --- /dev/null +++ b/tests/internal/data/aws_credentials/shared_credentials_file.ini @@ -0,0 +1,24 @@ +[default] +aws_access_key_id = ASIASDMPIJWXJAXT3O3T +aws_secret_access_key = EAUBpd/APPT4Nfi4DWY3gnt5TU/4T49laqS5zh8W +aws_session_token = IQoJb3JpZ2luX2VjEOD//////////wEaCNVzLWVhc3QtMSJHMEUCIKCn7v/EDowMZvJnciSJbxA7rIV4p1K6pOUvcLHM+9EzNgIgeiYbfA47DGSqoEZS3yrRWGN8Fr4Q/bK7ANRgv09Hth8q1gEIWRABGgwxNDQ3MTg3MTE0NzAiDGSqzyXiicOZp63afiqzAUyWOljOn5HaIxRfpQ5pTf+o4roJ2KPlHn+XHEKJZKien4Ydm7zeVi7SbPLKocjmjYJd31PrlbJ43C6AyrhmY57qaD7Zz4N3N0V6mekzvlAeARXsa4deflsbemqkp1WVsBLkO6qUuk+N04+MxIVXAxkW9RSPRTVjxeS2m5Yobygto58WLFE8gacRoNd4lCK4JUmEdiaxJEQQO7leZ3v1XxQr6QBS8P/GmcJYcQTxlA6AFQxIMJKGwfAFOuMB2cEc8cF2Htiqf3LVGMk/6bYKkW7fHUtrnttp28jgWtbbLtFbX/zIdlqwm73Ryp7lI+xkM4XNIT+6ZKa4Xw0/Zw3xLzlk3jic6QWPAcffwR6kOunoTOWJzPskK/RZ4Cd+GyGarxG27Cz6xolAzAsDpdGQwV7kCCUPi6/VHjefwKEk9HjZfejC5WuCS173qFrU9kNb4IrYhnK+wmRzzJfgpWUwerdiJKBz95j1iW9rP1a8p1xLR3EXUMN3LIW0+gP8sFjg5iiqDkaS/tUXWZndM2QdJLcrxwAutFchc0nqJHYTijw= + +[nondefault] +aws_access_key_id = akid +aws_secret_access_key = skid + +#some comment line +sadfjasdlkfajskldfjasd some garbage = not_actually_valid_but=parser_should_handle_it + +[headerwithnokeys] + +[nospace] +aws_access_key_id=akidnospace +aws_secret_access_key=skidnospace +aws_session_token=tokennospace + +[weirdwhitespace] +aws_access_key_id= akidweird +aws_secret_access_key= skidweird + +aws_session_token=tokenweird///token==