From 5cd4d5e02f41dcfe9fa20e7b7faa943f94d5fccf Mon Sep 17 00:00:00 2001 From: Darien Hager Date: Thu, 19 Apr 2018 23:25:10 -0700 Subject: [PATCH] Change SQS model to support non-JSON redrive policies. Does not affect other limitations in SQS APIs. --- moto/sqs/models.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/moto/sqs/models.py b/moto/sqs/models.py index 044759e4..48e7409e 100644 --- a/moto/sqs/models.py +++ b/moto/sqs/models.py @@ -232,11 +232,18 @@ class Queue(BaseModel): self.last_modified_timestamp = now - def _setup_dlq(self, policy_json): - try: - self.redrive_policy = json.loads(policy_json) - except ValueError: - raise RESTError('InvalidParameterValue', 'Redrive policy does not contain valid json') + def _setup_dlq(self, policy): + + if isinstance(policy, six.text_type): + try: + self.redrive_policy = json.loads(policy) + except ValueError: + raise RESTError('InvalidParameterValue', 'Redrive policy is not a dict or valid json') + elif isinstance(policy, dict): + self.redrive_policy = policy + else: + raise RESTError('InvalidParameterValue', 'Redrive policy is not a dict or valid json') + if 'deadLetterTargetArn' not in self.redrive_policy: raise RESTError('InvalidParameterValue', 'Redrive policy does not contain deadLetterTargetArn')