def test_read_nested_config_inherited(self): """Test to make sure getting config works when inherited""" test_ui = MockUserInterface(argv=[ "--profile", "myprofile", ]) with open(test_ui.HOME + "/.okta_aws_login_config", "w") as config_file: config_file.write(""" [mybase-level1] client_id = bar [mybase-level2] inherits = mybase-level1 aws_appname = baz [myprofile] inherits = mybase-level2 client_id = foo aws_rolename = myrole """) config = Config(gac_ui=test_ui, create_config=False) config.conf_profile = "myprofile" profile_config = config.get_config_dict() self.assertEqual(profile_config, { "client_id": "foo", "aws_appname": "baz", "aws_rolename": "myrole", })
def test_read_config(self): """Test to make sure getting config works""" test_ui = MockUserInterface(argv=[ "--profile", "myprofile", ]) with open(test_ui.HOME + "/.okta_aws_login_config", "w") as config_file: config_file.write(""" [myprofile] client_id = foo """) config = Config(gac_ui=test_ui, create_config=False) config.conf_profile = "myprofile" profile_config = config.get_config_dict() self.assertEqual(profile_config, {"client_id": "foo"})
def test_fail_if_profile_not_found(self): """Test to make sure missing Default fails properly""" test_ui = MockUserInterface(argv=[]) with open(test_ui.HOME + "/.okta_aws_login_config", "w") as config_file: config_file.write(""" [myprofile] client_id = foo """) config = Config(gac_ui=test_ui, create_config=False) config.conf_profile = "DEFAULT" with self.assertRaises(errors.GimmeAWSCredsError) as context: config.get_config_dict() self.assertTrue( 'DEFAULT profile is missing! This is profile is required when not using --profile' == context.exception.message)