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):
|
||||
|
||||
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:
|
||||
# set version_id to match version_stage
|
||||
@ -57,7 +57,7 @@ class SecretsManagerBackend(BaseBackend):
|
||||
version_id = ver_id
|
||||
break
|
||||
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
|
||||
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:
|
||||
raise ResourceNotFoundException(
|
||||
"Secrets Manager can’t find the specified secret value for staging label: %s" %
|
||||
(version_stage or "AWSCURRENT")
|
||||
u"Secrets Manager can’t find the specified secret value for staging label: %s" %
|
||||
(version_stage or u"AWSCURRENT")
|
||||
)
|
||||
|
||||
response = json.dumps(response_data)
|
||||
@ -176,7 +176,7 @@ class SecretsManagerBackend(BaseBackend):
|
||||
|
||||
def describe_secret(self, 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]
|
||||
|
||||
@ -205,7 +205,7 @@ class SecretsManagerBackend(BaseBackend):
|
||||
rotation_days = 'AutomaticallyAfterDays'
|
||||
|
||||
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]:
|
||||
raise InvalidRequestException(
|
||||
@ -347,7 +347,7 @@ class SecretsManagerBackend(BaseBackend):
|
||||
def delete_secret(self, secret_id, recovery_window_in_days, force_delete_without_recovery):
|
||||
|
||||
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]:
|
||||
raise InvalidRequestException(
|
||||
@ -377,7 +377,7 @@ class SecretsManagerBackend(BaseBackend):
|
||||
secret = self.secrets.get(secret_id, None)
|
||||
|
||||
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'])
|
||||
name = secret['name']
|
||||
@ -387,7 +387,7 @@ class SecretsManagerBackend(BaseBackend):
|
||||
def restore_secret(self, 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)
|
||||
|
||||
|
@ -50,7 +50,7 @@ def test_get_secret_that_does_not_exist():
|
||||
"X-Amz-Target": "secretsmanager.GetSecretValue"},
|
||||
)
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
@ -71,7 +71,7 @@ def test_get_secret_that_does_not_match():
|
||||
"X-Amz-Target": "secretsmanager.GetSecretValue"},
|
||||
)
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
@ -91,7 +91,7 @@ def test_get_secret_that_has_no_value():
|
||||
)
|
||||
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
@ -179,7 +179,7 @@ def test_describe_secret_that_does_not_exist():
|
||||
)
|
||||
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
@ -203,7 +203,7 @@ def test_describe_secret_that_does_not_match():
|
||||
)
|
||||
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
@ -304,7 +304,7 @@ def test_rotate_secret_that_does_not_exist():
|
||||
)
|
||||
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
@ -328,7 +328,7 @@ def test_rotate_secret_that_does_not_match():
|
||||
)
|
||||
|
||||
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'
|
||||
|
||||
@mock_secretsmanager
|
||||
|
Loading…
Reference in New Issue
Block a user