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

Check config options as Booleans instead of strings #461

Merged
merged 2 commits into from
Apr 30, 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
4 changes: 2 additions & 2 deletions gimme_aws_creds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def get_profile_name(self, cred_profile, include_path, naming_data, resolve_alia
account = self._get_account_name(naming_data['account'], role, resolve_alias)
role_name = naming_data['role']
path = naming_data['path']
if include_path == 'True':
if include_path is True:
role_name = ''.join([path, role_name])
profile_name = '-'.join([account,
role_name])
Expand All @@ -827,7 +827,7 @@ def get_profile_name(self, cred_profile, include_path, naming_data, resolve_alia
return profile_name

def _get_account_name(self, account, role, resolve_alias):
if resolve_alias == "False":
if resolve_alias is False:
return account
account_alias = self._get_alias_from_friendly_name(role.friendly_account_name)
return account_alias or account
Expand Down
32 changes: 16 additions & 16 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def test_get_profile_name_accrole_resolve_alias_do_not_include_paths(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'acc-role'
resolve_alias = 'True'
include_path = 'False'
resolve_alias = True
include_path = False
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role), "my-org-master-administrator")

def test_get_profile_accrole_name_do_not_resolve_alias_do_not_include_paths(self):
Expand All @@ -210,8 +210,8 @@ def test_get_profile_accrole_name_do_not_resolve_alias_do_not_include_paths(self
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'acc-role'
resolve_alias = 'False'
include_path = 'False'
resolve_alias = False
include_path = False
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
"123456789012-administrator")

Expand All @@ -224,8 +224,8 @@ def test_get_profile_accrole_name_do_not_resolve_alias_include_paths(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'acc-role'
resolve_alias = 'False'
include_path = 'True'
resolve_alias = False
include_path = True
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
"123456789012-/some/long/extended/path/administrator")

Expand All @@ -238,8 +238,8 @@ def test_get_profile_name_role(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'role'
resolve_alias = 'False'
include_path = 'True'
resolve_alias = False
include_path = True
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
'administrator')

Expand All @@ -252,8 +252,8 @@ def test_get_profile_name_account_resolve_alias(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'acc'
resolve_alias = 'True'
include_path = 'True'
resolve_alias = True
include_path = True
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
'my-org-master')

Expand All @@ -266,8 +266,8 @@ def test_get_profile_name_account_do_not_resolve_alias(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'acc'
resolve_alias = 'False'
include_path = 'True'
resolve_alias = False
include_path = True
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
'123456789012')

Expand All @@ -280,8 +280,8 @@ def test_get_profile_name_default(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'default'
resolve_alias = 'False'
include_path = 'True'
resolve_alias = False
include_path = True
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
'default')

Expand All @@ -294,7 +294,7 @@ def test_get_profile_name_else(self):
friendly_account_name='Account: my-org-master (123456789012)',
friendly_role_name='administrator/administrator')
cred_profile = 'foo'
resolve_alias = 'False'
include_path = 'True'
resolve_alias = False
include_path = True
self.assertEqual(creds.get_profile_name(cred_profile, include_path, naming_data, resolve_alias, role),
'foo')