Skip to content

Commit a16fe0b

Browse files
committed
Merge branch 'master' into dev
2 parents 3ce9554 + 4515c88 commit a16fe0b

3 files changed

Lines changed: 37 additions & 11 deletions

File tree

gimme_aws_creds/config.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,22 @@ def _handle_config(self, config, profile_config, include_inherits = True):
220220
profile_config[key] = True
221221
elif profile_config[key] == 'False':
222222
profile_config[key] = False
223-
224-
# Empty string in force_classic should be handled as True - this makes sure that migrating from Classic to OIE is seamless
225-
if profile_config.get('force_classic') == '' or profile_config.get('force_classic') is None:
226-
profile_config['force_classic'] = True
227223

228224
if "inherits" in profile_config.keys() and include_inherits:
229225
self.ui.message("Using inherited config: " + profile_config["inherits"])
230226
if profile_config["inherits"] not in config:
231227
raise errors.GimmeAWSCredsError(self.conf_profile + " inherits from " + profile_config["inherits"] + ", but could not find " + profile_config["inherits"])
232-
combined_config = {
228+
profile_config = {
233229
**self._handle_config(config, dict(config[profile_config["inherits"]])),
234230
**profile_config,
235231
}
236-
del combined_config["inherits"]
237-
return combined_config
238-
else:
239-
return profile_config
232+
del profile_config["inherits"]
233+
234+
# Empty string in force_classic should be handled as True - this makes sure that migrating from Classic to OIE is seamless
235+
if profile_config.get('force_classic') == '' or profile_config.get('force_classic') is None:
236+
profile_config['force_classic'] = True
237+
238+
return profile_config
240239

241240
def get_config_dict(self, include_inherits = True):
242241
"""returns the conf dict from the okta config file"""

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/test_config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,35 @@ def test_read_nested_config_inherited(self):
171171
"force_classic": True
172172
})
173173

174+
def test_read_nested_config_inherited_no_force_classic(self):
175+
"""Test to make sure getting config works when inherited"""
176+
test_ui = MockUserInterface(argv = [
177+
"--profile",
178+
"myprofile",
179+
])
180+
with open(test_ui.HOME + "/.okta_aws_login_config", "w") as config_file:
181+
config_file.write("""
182+
[mybase-level1]
183+
client_id = bar
184+
[mybase-level2]
185+
inherits = mybase-level1
186+
aws_appname = baz
187+
force_classic = False
188+
[myprofile]
189+
inherits = mybase-level2
190+
client_id = foo
191+
aws_rolename = myrole
192+
""")
193+
config = Config(gac_ui=test_ui, create_config=False)
194+
config.conf_profile = "myprofile"
195+
profile_config = config.get_config_dict()
196+
self.assertEqual(profile_config, {
197+
"client_id": "foo",
198+
"aws_appname": "baz",
199+
"aws_rolename": "myrole",
200+
"force_classic": False
201+
})
202+
174203
def test_fail_if_profile_not_found(self):
175204
"""Test to make sure missing Default fails properly"""
176205
test_ui = MockUserInterface(argv=[])

0 commit comments

Comments
 (0)