Exemplo n.º 1
0
 def test_envvars_are_found_access_token(self):
     environ = {'CDP_ACCESS_TOKEN': 'tea'}
     provider = credentials.EnvProvider(environ)
     creds = provider.load()
     self.assertIsNotNone(creds)
     self.assertEqual(creds.access_token, 'tea')
     self.assertEqual(creds.method, 'env')
Exemplo n.º 2
0
 def test_raise_if_not_a_file(self):
     environ = {
         'CDP_ACCESS_KEY_ID': 'foo',
         'CDP_PRIVATE_KEY': self.pem_file + "dose_not_exist",
     }
     provider = credentials.EnvProvider(environ)
     with self.assertRaises(NoCredentialsError):
         provider.load()
Exemplo n.º 3
0
 def test_can_override_env_var_mapping_access_token(self):
     # We can change the env var provider to
     # use our specified env var names.
     environ = {'FOO_ACCESS_token': 'foo'}
     mapping = {'access_token': 'FOO_ACCESS_token'}
     provider = credentials.EnvProvider(environ, mapping)
     creds = provider.load()
     self.assertEqual(creds.access_token, 'foo')
Exemplo n.º 4
0
 def test_partial_creds_is_an_error(self):
     # If the user provides an access key, they must also
     # provide a secret key.  Not doing so will generate an
     # error.
     environ = {
         'CDP_ACCESS_KEY_ID': 'foo',
     }
     provider = credentials.EnvProvider(environ)
     with self.assertRaises(PartialCredentialsError):
         provider.load()
Exemplo n.º 5
0
 def test_envvars_are_found(self):
     environ = {
         'CDP_ACCESS_KEY_ID': 'foo',
         'CDP_PRIVATE_KEY': self.pem_file,
     }
     provider = credentials.EnvProvider(environ)
     creds = provider.load()
     self.assertIsNotNone(creds)
     self.assertEqual(creds.access_key_id, 'foo')
     self.assertEqual(creds.private_key, TestEnvVar.PEM)
     self.assertEqual(creds.method, 'env')
Exemplo n.º 6
0
 def test_ed25519_key_value(self):
     environ = {
         'CDP_ACCESS_KEY_ID': 'foo',
         'CDP_PRIVATE_KEY': ED25519_KEY,
     }
     provider = credentials.EnvProvider(environ)
     creds = provider.load()
     self.assertIsNotNone(creds)
     self.assertEqual(creds.access_key_id, 'foo')
     self.assertEqual(creds.private_key, ED25519_KEY)
     self.assertEqual(creds.method, 'env')
Exemplo n.º 7
0
 def test_can_override_partial_env_var_mapping(self):
     # Only changing the access key mapping.
     # The other 2 use the default values of
     # CDP_SECRET_ACCESS_KEY and CDP_SESSION_TOKEN
     # use our specified env var names.
     environ = {
         'FOO_ACCESS_KEY_ID': 'foo',
         'CDP_PRIVATE_KEY': self.pem_file,
     }
     provider = credentials.EnvProvider(
         environ, {'access_key_id': 'FOO_ACCESS_KEY_ID'})
     creds = provider.load()
     self.assertEqual(creds.access_key_id, 'foo')
     self.assertEqual(creds.private_key, TestEnvVar.PEM)
Exemplo n.º 8
0
 def test_can_override_env_var_mapping(self):
     # We can change the env var provider to
     # use our specified env var names.
     environ = {
         'FOO_ACCESS_KEY_id': 'foo',
         'FOO_PRIVATE_KEY': self.pem_file,
     }
     mapping = {
         'access_key_id': 'FOO_ACCESS_KEY_id',
         'private_key': 'FOO_PRIVATE_KEY',
     }
     provider = credentials.EnvProvider(environ, mapping)
     creds = provider.load()
     self.assertEqual(creds.access_key_id, 'foo')
     self.assertEqual(creds.private_key, TestEnvVar.PEM)
Exemplo n.º 9
0
 def test_envvars_not_found(self):
     provider = credentials.EnvProvider(environ={})
     cred = provider.load()
     self.assertTrue(cred is None)