def test_get_secret_binary(self):
     secret = b'01010101'
     response = {}
     versions = {'01234567890123456789012345678901': ['AWSCURRENT']}
     version_response = {'SecretBinary': secret}
     cache = SecretCache(
         client=self.get_client(response, versions, version_response))
     for _ in range(10):
         self.assertEqual(secret, cache.get_secret_binary('test'))
Beispiel #2
0
    def test_get_secret_binary(self, client, secret_binary):
        cache = SecretCache(client=client)
        secret = client.get_secret_value(
            SecretId=secret_binary['ARN'])['SecretBinary']

        for _ in range(10):
            assert cache.get_secret_binary("{0}{1}{2}".format(
                TestAwsSecretsManagerCachingInteg.fixture_prefix,
                inspect.stack()[0][3],
                TestAwsSecretsManagerCachingInteg.uuid_suffix)) == secret
    def test_calls_hook_binary(self):
        secret = b'01010101'
        hooked_secret = secret + b'1111111100000000'
        response = {}
        versions = {
            '01234567890123456789012345678901': ['AWSCURRENT']
        }
        version_response = {'SecretBinary': secret}

        hook = DummySecretCacheHook()
        config = SecretCacheConfig(secret_cache_hook=hook)

        cache = SecretCache(config=config, client=self.get_client(response,
                                                                  versions,
                                                                  version_response))

        for _ in range(10):
            self.assertEqual(hooked_secret, cache.get_secret_binary('test')[0:24])
Beispiel #4
0
 def test_get_secret_binary_empty(self, client, secret_string):
     cache = SecretCache(client=client)
     assert cache.get_secret_binary("{0}{1}{2}".format(
         TestAwsSecretsManagerCachingInteg.fixture_prefix,
         inspect.stack()[0][3],
         TestAwsSecretsManagerCachingInteg.uuid_suffix)) is None
 def test_get_secret_binary_no_versions(self):
     cache = SecretCache(client=self.get_client())
     self.assertIsNone(cache.get_secret_binary('test'))