moto/tests/test_secretsmanager/test_secretsmanager.py

36 lines
1.2 KiB
Python
Raw Normal View History

2018-06-08 05:31:44 +00:00
from __future__ import unicode_literals
import boto3
from moto import mock_secretsmanager
from botocore.exceptions import ClientError
2018-06-08 05:31:44 +00:00
import sure # noqa
from nose.tools import assert_raises
2018-06-08 05:31:44 +00:00
@mock_secretsmanager
def test_get_secret_value():
2018-06-10 05:08:10 +00:00
conn = boto3.client('secretsmanager', region_name='us-west-2')
2018-06-08 05:31:44 +00:00
create_secret = conn.create_secret(Name='java-util-test-password',
SecretString="foosecret")
2018-06-08 05:31:44 +00:00
result = conn.get_secret_value(SecretId='java-util-test-password')
assert result['SecretString'] == 'foosecret'
@mock_secretsmanager
def test_get_secret_that_does_not_exist():
conn = boto3.client('secretsmanager', region_name='us-west-2')
with assert_raises(ClientError):
result = conn.get_secret_value(SecretId='i-dont-exist')
@mock_secretsmanager
def test_create_secret():
conn = boto3.client('secretsmanager', region_name='us-east-1')
result = conn.create_secret(Name='test-secret', SecretString="foosecret")
assert result['ARN'] == (
'arn:aws:secretsmanager:us-east-1:1234567890:secret:test-secret-rIjad')
assert result['Name'] == 'test-secret'
secret = conn.get_secret_value(SecretId='test-secret')
assert secret['SecretString'] == 'foosecret'