Moto-1781: finish implementation of rotate_secret and add happy test.

- Implement RotateSecret to support initial setup of secret rotation.
Moto's implementation of secrets is currently flat and needs to gain
some dimension before full rotation can be simulated.
- Add the happy path unit test.
This commit is contained in:
Neil Roberts 2018-08-15 11:04:44 -07:00
commit 43277a59b9
2 changed files with 52 additions and 0 deletions

View file

@ -180,6 +180,22 @@ def test_describe_secret_that_does_not_match():
with assert_raises(ClientError):
result = conn.get_secret_value(SecretId='i-dont-match')
@mock_secretsmanager
def test_rotate_secret():
secret_name = 'test-secret'
conn = boto3.client('secretsmanager', region_name='us-west-2')
conn.create_secret(Name=secret_name,
SecretString='foosecret')
rotated_secret = conn.rotate_secret(SecretId=secret_name)
assert rotated_secret
assert rotated_secret['ARN'] == (
'arn:aws:secretsmanager:us-west-2:1234567890:secret:test-secret-rIjad'
)
assert rotated_secret['Name'] == secret_name
assert rotated_secret['VersionId'] != ''
@mock_secretsmanager
def test_rotate_secret_that_does_not_exist():
conn = boto3.client('secretsmanager', 'us-west-2')