This commit is contained in:
zane 2018-06-09 22:08:10 -07:00
parent c4abd98ed3
commit 8ee7a9495d
4 changed files with 15 additions and 17 deletions

View File

@ -9,8 +9,8 @@ else
endif
init:
@python setup.py develop
@pip install -r requirements.txt
@python3 setup.py develop
@pip3 install -r requirements.txt
lint:
flake8 moto
@ -18,7 +18,7 @@ lint:
test: lint
rm -f .coverage
rm -rf cover
@nosetests -sv --with-coverage --cover-html ./tests/ $(TEST_EXCLUDE)
nosetests -sv --with-coverage --cover-html ./tests/ $(TEST_EXCLUDE)
test_server:
@TEST_SERVER_MODE=true nosetests -sv --with-coverage --cover-html ./tests/

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .models import secretsmanager_backends
from ..core.models import base_decorator, deprecated_base_decorator
from ..core.models import base_decorator
secretsmanager_backend = secretsmanager_backends['us-east-1']
mock_secretsmanager = base_decorator(secretsmanager_backends)

View File

@ -3,31 +3,28 @@ from __future__ import unicode_literals
import datetime
import json
import boto.secretsmanager
import boto3
from moto.core import BaseBackend, BaseModel
class SecretsManager(BaseModel):
def __init__(self, region, **kwargs):
def __init__(self, region_name, **kwargs):
self.secret_id = kwargs.get('secret_id', '')
self.version_id = kwargs.get('version_id', '')
self.string_id = kwargs.get('string_id', '')
class SecretsManagerBackend(BaseBackend):
def __init__(self, region):
def __init__(self, region_name=None):
super(SecretsManagerBackend, self).__init__()
self.region = region
self.region = region_name
def get_secret_value(self, secret_id, version_id, string_id):
secret_response = SecretsManager(self.region, secret_id=secret_id,
version_id=version_id,
string_id=string_id)
response = json.dumps({
"ARN": secret_arn,
"ARN": self.secret_arn(),
"Name": self.secret_id,
"VersionId": "A435958A-D821-4193-B719-B7769357AER4",
"SecretBinary": b"testbytes",
@ -44,6 +41,7 @@ class SecretsManagerBackend(BaseBackend):
return "arn:aws:secretsmanager:{0}:1234567890:secret:{1}-rIjad".format(
self.region, self.secret_id)
secretsmanager_backends = {}
for regin in boto.secretsmanager.regions():
secretsmanager_backends[region.name] = SecretsManagerBackend(region.name)
available_regions = boto3.session.Session().get_available_regions("secretsmanager")
print(available_regions)
secretsmanager_backends = {region: SecretsManagerBackend(region_name=region) for region in available_regions}

View File

@ -7,7 +7,7 @@ import sure # noqa
@mock_secretsmanager
def test_get_secret_value():
conn = boto3.client('secretsmanager', 'us-west-2')
conn = boto3.client('secretsmanager', region_name='us-west-2')
result = conn.get_secret_value(SecretId='java-util-test-password')
assert result['SecretString'] == 'mysecretstring'