def test_default_profile_specified_raises_exception(self):
     # If you explicity set the default profile and you don't
     # have that in your config file, an exception is raised.
     config_path = os.path.join(os.path.dirname(__file__), 'cfg',
                                'boto_config_empty')
     self.environ['FOO_CONFIG_FILE'] = config_path
     self.environ['FOO_PROFILE'] = 'default'
     session = create_session(session_vars=self.env_vars)
     # In this case, even though we specified default, because
     # the boto_config_empty config file does not have a default
     # profile, we should be raising an exception.
     with self.assertRaises(ibm_botocore.exceptions.ProfileNotFound):
         session.get_scoped_config()
 def test_profile_does_not_exist_with_default_profile(self):
     session = create_session(session_vars=self.env_vars)
     config = session.get_scoped_config()
     # We should have loaded this properly, and we'll check
     # that foo_access_key which is defined in the config
     # file should be present in the loaded config dict.
     self.assertIn('aws_access_key_id', config)
 def test_config_loader_delegation(self):
     session = create_session(profile='credfile-profile')
     with temporary_file('w') as f:
         f.write('[credfile-profile]\naws_access_key_id=a\n')
         f.write('aws_secret_access_key=b\n')
         f.flush()
         session.set_config_variable('credentials_file', f.name)
         # Now trying to retrieve the scoped config should pull in
         # values from the shared credentials file.
         self.assertEqual(session.get_scoped_config(), {
             'aws_access_key_id': 'a',
             'aws_secret_access_key': 'b'
         })
 def test_profile_does_not_exist_raises_exception(self):
     # Given we have no profile:
     self.environ['FOO_PROFILE'] = 'profile_that_does_not_exist'
     session = create_session(session_vars=self.env_vars)
     with self.assertRaises(ibm_botocore.exceptions.ProfileNotFound):
         session.get_scoped_config()