def test_get_secret_binary(self): secret_name = "arn:aws:secretsmanager:us-east-2:999999999999:secret:db_cluster-YYYYYYY" secret_value_binary = base64.b64encode(b'{"username": "******"}') hook = SecretsManagerHook(aws_conn_id='aws_default') param = { 'SecretId': secret_name, 'SecretBinary': secret_value_binary, } hook.get_conn().put_secret_value(**param) secret = hook.get_secret(secret_name) self.assertEqual(secret, base64.b64decode(secret_value_binary))
def test_get_secret_dict(self): secret_name = "arn:aws:secretsmanager:us-east-2:999999999999:secret:db_cluster-YYYYYYY" secret_value = '{"user": "******"}' hook = SecretsManagerHook(aws_conn_id='aws_default') param = { 'SecretId': secret_name, 'SecretString': secret_value, } hook.get_conn().put_secret_value(**param) secret = hook.get_secret_as_dict(secret_name) self.assertEqual(secret, json.loads(secret_value))
def test_get_secret_string(self): secret_name = "arn:aws:secretsmanager:us-east-2:999999999999:secret:db_cluster-YYYYYYY" secret_value = '{"user": "******"}' hook = SecretsManagerHook(aws_conn_id='aws_default') create_param = { 'Name': secret_name, } put_param = { 'SecretId': secret_name, 'SecretString': secret_value, } hook.get_conn().create_secret(**create_param) hook.get_conn().put_secret_value(**put_param) secret = hook.get_secret(secret_name) assert secret == secret_value
def test_get_conn_returns_a_boto3_connection(self): hook = SecretsManagerHook(aws_conn_id='aws_default') self.assertIsNotNone(hook.get_conn())