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

feat: support account name as cred_profile option #438

Merged
merged 1 commit into from Nov 13, 2023

Conversation

abarrak
Copy link
Contributor

@abarrak abarrak commented Nov 1, 2023

Description

Hi, This PR supports account name or id (depends on alias resolve option) as a credential profile name.

Related Issue

N/A.

Motivation and Context

Simplifying workflow I have where config profiles is inconsistent with creds names authoried by gimme-aws-creds

How Has This Been Tested?

Unit tests passing:

(venv) ❯ pytest -vv tests
======================================================================== test session starts =========================================================================
platform darwin -- Python 3.11.2, pytest-7.4.3, pluggy-1.3.0 -- ~/code/gimme-aws-creds/venv/bin/python3.11
cachedir: .pytest_cache
rootdir: ~/code/gimme-aws-creds
collected 78 items           

tests/test_aws_resolver.py::TestAwsResolver::test_display_role PASSED [  1%]
tests/test_aws_resolver.py::TestAwsResolver::test_enumerate_saml_roles PASSED                                   [  2%]
tests/test_aws_resolver.py::TestAwsResolver::test_enumerate_saml_roles_nextjs PASSED                            [  3%]
tests/test_config.py::TestConfig::test_fail_if_profile_not_found PASSED                                         [  5%]
tests/test_config.py::TestConfig::test_get_args_username PASSED                                                 [  6%]
tests/test_config.py::TestConfig::test_read_config PASSED                                                       [  7%]
tests/test_config.py::TestConfig::test_read_config_inherited PASSED                                             [  8%]
tests/test_config.py::TestConfig::test_read_nested_config_inherited PASSED                                      [ 10%]
tests/test_main.py::TestMain::test_choose_roles_app_0 PASSED                                                    [ 11%]
tests/test_main.py::TestMain::test_choose_roles_app_1 PASSED                                                    [ 12%]
tests/test_main.py::TestMain::test_choose_roles_app_2 PASSED                                                    [ 14%]
tests/test_main.py::TestMain::test_choose_roles_app_a PASSED                                                    [ 15%]
tests/test_main.py::TestMain::test_choose_roles_app_neg1 PASSED                                                 [ 16%]
tests/test_main.py::TestMain::test_get_alias_from_friendly_name_no_alias PASSED                                 [ 17%]
tests/test_main.py::TestMain::test_get_alias_from_friendly_name_with_alias PASSED                               [ 19%]
tests/test_main.py::TestMain::test_get_partition_aws PASSED                                                     [ 20%]
tests/test_main.py::TestMain::test_get_partition_china PASSED                                                   [ 21%]
tests/test_main.py::TestMain::test_get_partition_govcloud PASSED                                                [ 23%]
tests/test_main.py::TestMain::test_get_partition_unkown PASSED                                                  [ 24%]
tests/test_main.py::TestMain::test_get_profile_accrole_name_do_not_resolve_alias_do_not_include_paths PASSED    [ 25%]
tests/test_main.py::TestMain::test_get_profile_accrole_name_do_not_resolve_alias_include_paths PASSED           [ 26%]
tests/test_main.py::TestMain::test_get_profile_name_account_do_not_resolve_alias PASSED                         [ 28%]
tests/test_main.py::TestMain::test_get_profile_name_account_resolve_alias PASSED                                [ 29%]
tests/test_main.py::TestMain::test_get_profile_name_accrole_resolve_alias_do_not_include_paths PASSED           [ 30%]
tests/test_main.py::TestMain::test_get_profile_name_default PASSED                                              [ 32%]
tests/test_main.py::TestMain::test_get_profile_name_else PASSED                                                 [ 33%]
tests/test_main.py::TestMain::test_get_profile_name_role PASSED                                                 [ 34%]
tests/test_main.py::TestMain::test_get_region_partition_aws PASSED                                              [ 35%]
tests/test_main.py::TestMain::test_get_region_partition_china PASSED                                            [ 37%]
tests/test_main.py::TestMain::test_get_region_partition_govcloud PASSED                                         [ 38%]
tests/test_main.py::TestMain::test_get_selected_app_from_config_0 PASSED                                        [ 39%]
tests/test_main.py::TestMain::test_get_selected_app_from_config_1 PASSED                                        [ 41%]
tests/test_main.py::TestMain::test_get_selected_roles_all PASSED                                                [ 42%]
tests/test_main.py::TestMain::test_get_selected_roles_from_config_0 PASSED                                      [ 43%]
tests/test_main.py::TestMain::test_get_selected_roles_from_config_1 PASSED                                      [ 44%]
tests/test_main.py::TestMain::test_get_selected_roles_multiple PASSED                                           [ 46%]
tests/test_main.py::TestMain::test_get_selected_roles_multiple_list PASSED                                      [ 47%]
tests/test_main.py::TestMain::test_missing_app_from_config PASSED                                               [ 48%]
tests/test_main.py::TestMain::test_missing_role_from_config PASSED                                              [ 50%]
tests/test_main.py::TestMain::test_parse_role_arn_base_path PASSED                                              [ 51%]
tests/test_main.py::TestMain::test_parse_role_arn_extended_path PASSED                                          [ 52%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_authenticator_enrollment PASSED                  [ 53%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_email PASSED                   [ 55%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_hardware PASSED                [ 56%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_push PASSED                    [ 57%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_sms PASSED                     [ 58%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_totp PASSED                    [ 60%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_unknown PASSED                 [ 61%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_webauthn_registered PASSED     [ 62%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_webauthn_unregistered PASSED   [ 64%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_build_factor_name_webauthn_unregistered_with_authenticator_name PASSED [ 65%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_check_push_result PASSED                         [ 66%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_choose_bad_factor_totp PASSED                    [ 67%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_choose_factor_push PASSED                        [ 69%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_choose_factor_sms PASSED                         [ 70%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_choose_factor_totp PASSED                        [ 71%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_choose_factor_webauthn PASSED                    [ 73%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_choose_non_number_factor_totp PASSED             [ 74%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_get_headers PASSED                               [ 75%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_get_saml_response PASSED                         [ 76%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_get_state_token PASSED                           [ 78%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_get_username_password_creds PASSED               [ 79%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_login_input_mfa_challenge PASSED                 [ 80%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_login_send_email PASSED                          [ 82%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_login_send_push PASSED                           [ 83%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_login_send_sms PASSED                            [ 84%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_login_username_password PASSED                   [ 85%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_missing_password PASSED                          [ 87%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_missing_saml_response PASSED                     [ 88%]
tests/test_okta_classic_client.py::TestOktaClassicClient::test_passed_username PASSED                           [ 89%]
tests/test_okta_identity_engine_client.py::TestOktaIdentityEngineClient::test_auth_session PASSED               [ 91%]
tests/test_okta_identity_engine_client.py::TestOktaIdentityEngineClient::test_get_headers PASSED                [ 92%]
tests/test_okta_identity_engine_client.py::TestOktaIdentityEngineClient::test_get_user_tokens PASSED            [ 93%]
tests/test_okta_identity_engine_client.py::TestOktaIdentityEngineClient::test_saml_response PASSED              [ 94%]
tests/test_okta_identity_engine_client.py::TestOktaIdentityEngineClient::test_start_device_flow PASSED          [ 96%]
tests/test_registered_authenticators.py::TestConfig::test_add_authenticator_sanity PASSED                       [ 97%]
tests/test_registered_authenticators.py::TestConfig::test_file_creation_post_init PASSED                        [ 98%]
tests/test_registered_authenticators.py::TestConfig::test_get_authenticator_user_sanity PASSED                  [100%]

========================================================================= 78 passed in 1.52s =========================================================================

Screenshots (if appropriate):

N/A.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: Abdullah Barrak <abdullahalotaibi@lucidmotors.com>
@sbates
Copy link

sbates commented Nov 10, 2023

I actually came here looking for how to do this. My multi account pipeline thanks you.

@abarrak
Copy link
Contributor Author

abarrak commented Nov 11, 2023

Hi @epierce, can you take a look here? If meged, this will simplify things for me. Thanks.

Copy link
Member

@epierce epierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good.

@epierce epierce merged commit b5cafac into Nike-Inc:master Nov 13, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants