Skip to content

Commit

Permalink
Merge pull request #461 from Nike-Inc/dev
Browse files Browse the repository at this point in the history
Check config options as Booleans instead of strings
  • Loading branch information
epierce authored Apr 30, 2024
2 parents 6653213 + d06251d commit 763ae83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
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')

0 comments on commit 763ae83

Please sign in to comment.