Implement support for SSM parameter store
This commit adds initial support for the Simple System Manager client. It currently only mocks the following api endpoints: - delete_parameter() - put_parameter() - get_parameters()
This commit is contained in:
parent
df84675ae6
commit
783a1d73b4
8 changed files with 255 additions and 0 deletions
114
tests/test_ssm/test_ssm_boto3.py
Normal file
114
tests/test_ssm/test_ssm_boto3.py
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_ssm
|
||||
|
||||
|
||||
@mock_ssm
|
||||
def test_delete_parameter():
|
||||
client = boto3.client('ssm', region_name='us-east-1')
|
||||
|
||||
client.put_parameter(
|
||||
Name='test',
|
||||
Description='A test parameter',
|
||||
Value='value',
|
||||
Type='String')
|
||||
|
||||
response = client.get_parameters(Names=['test'])
|
||||
len(response['Parameters']).should.equal(1)
|
||||
|
||||
client.delete_parameter(Name='test')
|
||||
|
||||
response = client.get_parameters(Names=['test'])
|
||||
len(response['Parameters']).should.equal(0)
|
||||
|
||||
|
||||
@mock_ssm
|
||||
def test_put_parameter():
|
||||
client = boto3.client('ssm', region_name='us-east-1')
|
||||
|
||||
client.put_parameter(
|
||||
Name='test',
|
||||
Description='A test parameter',
|
||||
Value='value',
|
||||
Type='String')
|
||||
|
||||
response = client.get_parameters(
|
||||
Names=[
|
||||
'test'
|
||||
],
|
||||
WithDecryption=False)
|
||||
|
||||
len(response['Parameters']).should.equal(1)
|
||||
response['Parameters'][0]['Name'].should.equal('test')
|
||||
response['Parameters'][0]['Value'].should.equal('value')
|
||||
response['Parameters'][0]['Type'].should.equal('String')
|
||||
|
||||
|
||||
@mock_ssm
|
||||
def test_put_parameter_secure_default_kms():
|
||||
client = boto3.client('ssm', region_name='us-east-1')
|
||||
|
||||
client.put_parameter(
|
||||
Name='test',
|
||||
Description='A test parameter',
|
||||
Value='value',
|
||||
Type='SecureString')
|
||||
|
||||
response = client.get_parameters(
|
||||
Names=[
|
||||
'test'
|
||||
],
|
||||
WithDecryption=False)
|
||||
|
||||
len(response['Parameters']).should.equal(1)
|
||||
response['Parameters'][0]['Name'].should.equal('test')
|
||||
response['Parameters'][0]['Value'].should.equal('kms:default:value')
|
||||
response['Parameters'][0]['Type'].should.equal('SecureString')
|
||||
|
||||
response = client.get_parameters(
|
||||
Names=[
|
||||
'test'
|
||||
],
|
||||
WithDecryption=True)
|
||||
|
||||
len(response['Parameters']).should.equal(1)
|
||||
response['Parameters'][0]['Name'].should.equal('test')
|
||||
response['Parameters'][0]['Value'].should.equal('value')
|
||||
response['Parameters'][0]['Type'].should.equal('SecureString')
|
||||
|
||||
|
||||
@mock_ssm
|
||||
def test_put_parameter_secure_custom_kms():
|
||||
client = boto3.client('ssm', region_name='us-east-1')
|
||||
|
||||
client.put_parameter(
|
||||
Name='test',
|
||||
Description='A test parameter',
|
||||
Value='value',
|
||||
Type='SecureString',
|
||||
KeyId='foo')
|
||||
|
||||
response = client.get_parameters(
|
||||
Names=[
|
||||
'test'
|
||||
],
|
||||
WithDecryption=False)
|
||||
|
||||
len(response['Parameters']).should.equal(1)
|
||||
response['Parameters'][0]['Name'].should.equal('test')
|
||||
response['Parameters'][0]['Value'].should.equal('kms:foo:value')
|
||||
response['Parameters'][0]['Type'].should.equal('SecureString')
|
||||
|
||||
response = client.get_parameters(
|
||||
Names=[
|
||||
'test'
|
||||
],
|
||||
WithDecryption=True)
|
||||
|
||||
len(response['Parameters']).should.equal(1)
|
||||
response['Parameters'][0]['Name'].should.equal('test')
|
||||
response['Parameters'][0]['Value'].should.equal('value')
|
||||
response['Parameters'][0]['Type'].should.equal('SecureString')
|
||||
Loading…
Add table
Add a link
Reference in a new issue