Updating tests

This commit is contained in:
zane 2018-06-09 23:42:33 -07:00
parent 8ee7a9495d
commit b1a8ae8299
3 changed files with 12 additions and 11 deletions

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
import datetime
import time
import json
import boto3
@ -13,26 +13,27 @@ class SecretsManager(BaseModel):
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', '')
self.version_stage = kwargs.get('version_stage', '')
class SecretsManagerBackend(BaseBackend):
def __init__(self, region_name=None):
def __init__(self, region_name=None, **kwargs):
super(SecretsManagerBackend, self).__init__()
self.region = region_name
self.secret_id = kwargs.get('secret_id', '')
self.createdate = int(time.time())
def get_secret_value(self, secret_id, version_id, string_id):
def get_secret_value(self, secret_id, version_id, version_stage):
response = json.dumps({
"ARN": self.secret_arn(),
"Name": self.secret_id,
"VersionId": "A435958A-D821-4193-B719-B7769357AER4",
"SecretBinary": b"testbytes",
"SecretString": "mysecretstring",
"VersionStages": [
"AWSCURRENT",
],
"CreatedDate": datetime.datetime.utcnow()
"CreatedDate": "2018-05-23 13:16:57.198000"
})
return response

View File

@ -8,9 +8,9 @@ from .models import secretsmanager_backends
class SecretsManagerResponse(BaseResponse):
def get_secret_value(self):
secret_id = self.get_param('SecretId')
version_id = self.get_param('VersionId')
version_stage = self.get_param('VersionStage')
secret_id = self._get_param('SecretId')
version_id = self._get_param('VersionId')
version_stage = self._get_param('VersionStage')
return secretsmanager_backends[self.region].get_secret_value(
secret_id=secret_id,
version_id=version_id,

View File

@ -14,7 +14,7 @@ Test the different server responses
@mock_secretsmanager
def test_get_secret_value():
backend = server.create_backend_app("secretsmanager-get-secret-value")
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
res = test_client.post('/',
@ -24,4 +24,4 @@ def test_get_secret_value():
)
json_data = json.loads(res.data.decode("utf-8"))
assert json_data['SecretId'] == "test"
assert json_data['SecretString'] == "mysecretstring"