Work around python2 unicode exception str() issues
This commit is contained in:
parent
d74f9e47c8
commit
9a54cea4f1
@ -47,7 +47,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
def get_secret_value(self, secret_id, version_id, version_stage):
|
def get_secret_value(self, secret_id, version_id, version_stage):
|
||||||
|
|
||||||
if not self._is_valid_identifier(secret_id):
|
if not self._is_valid_identifier(secret_id):
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
if not version_id and version_stage:
|
if not version_id and version_stage:
|
||||||
# set version_id to match version_stage
|
# set version_id to match version_stage
|
||||||
@ -57,7 +57,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
version_id = ver_id
|
version_id = ver_id
|
||||||
break
|
break
|
||||||
if not version_id:
|
if not version_id:
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
# TODO check this part
|
# TODO check this part
|
||||||
if 'deleted_date' in self.secrets[secret_id]:
|
if 'deleted_date' in self.secrets[secret_id]:
|
||||||
@ -87,8 +87,8 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
|
|
||||||
if 'secret_string' not in secret_version and 'secret_binary' not in secret_version:
|
if 'secret_string' not in secret_version and 'secret_binary' not in secret_version:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
"Secrets Manager can’t find the specified secret value for staging label: %s" %
|
u"Secrets Manager can’t find the specified secret value for staging label: %s" %
|
||||||
(version_stage or "AWSCURRENT")
|
(version_stage or u"AWSCURRENT")
|
||||||
)
|
)
|
||||||
|
|
||||||
response = json.dumps(response_data)
|
response = json.dumps(response_data)
|
||||||
@ -176,7 +176,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
|
|
||||||
def describe_secret(self, secret_id):
|
def describe_secret(self, secret_id):
|
||||||
if not self._is_valid_identifier(secret_id):
|
if not self._is_valid_identifier(secret_id):
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
secret = self.secrets[secret_id]
|
secret = self.secrets[secret_id]
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
rotation_days = 'AutomaticallyAfterDays'
|
rotation_days = 'AutomaticallyAfterDays'
|
||||||
|
|
||||||
if not self._is_valid_identifier(secret_id):
|
if not self._is_valid_identifier(secret_id):
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
if 'deleted_date' in self.secrets[secret_id]:
|
if 'deleted_date' in self.secrets[secret_id]:
|
||||||
raise InvalidRequestException(
|
raise InvalidRequestException(
|
||||||
@ -347,7 +347,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
def delete_secret(self, secret_id, recovery_window_in_days, force_delete_without_recovery):
|
def delete_secret(self, secret_id, recovery_window_in_days, force_delete_without_recovery):
|
||||||
|
|
||||||
if not self._is_valid_identifier(secret_id):
|
if not self._is_valid_identifier(secret_id):
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
if 'deleted_date' in self.secrets[secret_id]:
|
if 'deleted_date' in self.secrets[secret_id]:
|
||||||
raise InvalidRequestException(
|
raise InvalidRequestException(
|
||||||
@ -377,7 +377,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
secret = self.secrets.get(secret_id, None)
|
secret = self.secrets.get(secret_id, None)
|
||||||
|
|
||||||
if not secret:
|
if not secret:
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
arn = secret_arn(self.region, secret['secret_id'])
|
arn = secret_arn(self.region, secret['secret_id'])
|
||||||
name = secret['name']
|
name = secret['name']
|
||||||
@ -387,7 +387,7 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
def restore_secret(self, secret_id):
|
def restore_secret(self, secret_id):
|
||||||
|
|
||||||
if not self._is_valid_identifier(secret_id):
|
if not self._is_valid_identifier(secret_id):
|
||||||
raise ResourceNotFoundException("Secrets Manager can’t find the specified secret.")
|
raise ResourceNotFoundException(u"Secrets Manager can’t find the specified secret.")
|
||||||
|
|
||||||
self.secrets[secret_id].pop('deleted_date', None)
|
self.secrets[secret_id].pop('deleted_date', None)
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ def test_get_secret_that_does_not_exist():
|
|||||||
"X-Amz-Target": "secretsmanager.GetSecretValue"},
|
"X-Amz-Target": "secretsmanager.GetSecretValue"},
|
||||||
)
|
)
|
||||||
json_data = json.loads(get_secret.data.decode("utf-8"))
|
json_data = json.loads(get_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret."
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret."
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
@ -71,7 +71,7 @@ def test_get_secret_that_does_not_match():
|
|||||||
"X-Amz-Target": "secretsmanager.GetSecretValue"},
|
"X-Amz-Target": "secretsmanager.GetSecretValue"},
|
||||||
)
|
)
|
||||||
json_data = json.loads(get_secret.data.decode("utf-8"))
|
json_data = json.loads(get_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret."
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret."
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
@ -91,7 +91,7 @@ def test_get_secret_that_has_no_value():
|
|||||||
)
|
)
|
||||||
|
|
||||||
json_data = json.loads(get_secret.data.decode("utf-8"))
|
json_data = json.loads(get_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret value for staging label: AWSCURRENT"
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret value for staging label: AWSCURRENT"
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
@ -179,7 +179,7 @@ def test_describe_secret_that_does_not_exist():
|
|||||||
)
|
)
|
||||||
|
|
||||||
json_data = json.loads(describe_secret.data.decode("utf-8"))
|
json_data = json.loads(describe_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret."
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret."
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
@ -203,7 +203,7 @@ def test_describe_secret_that_does_not_match():
|
|||||||
)
|
)
|
||||||
|
|
||||||
json_data = json.loads(describe_secret.data.decode("utf-8"))
|
json_data = json.loads(describe_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret."
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret."
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
@ -304,7 +304,7 @@ def test_rotate_secret_that_does_not_exist():
|
|||||||
)
|
)
|
||||||
|
|
||||||
json_data = json.loads(rotate_secret.data.decode("utf-8"))
|
json_data = json.loads(rotate_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret."
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret."
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
@ -328,7 +328,7 @@ def test_rotate_secret_that_does_not_match():
|
|||||||
)
|
)
|
||||||
|
|
||||||
json_data = json.loads(rotate_secret.data.decode("utf-8"))
|
json_data = json.loads(rotate_secret.data.decode("utf-8"))
|
||||||
assert json_data['message'] == "Secrets Manager can’t find the specified secret."
|
assert json_data['message'] == u"Secrets Manager can’t find the specified secret."
|
||||||
assert json_data['__type'] == 'ResourceNotFoundException'
|
assert json_data['__type'] == 'ResourceNotFoundException'
|
||||||
|
|
||||||
@mock_secretsmanager
|
@mock_secretsmanager
|
||||||
|
Loading…
Reference in New Issue
Block a user