Fix:SQS:Added Non existent queue name in ERROR RESPONSE (#3261)

* Fix:SQS:Added Non existent queue name in ERROR RESPONSE

* Linting

Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
usmangani1 2020-08-27 22:01:20 +05:30 committed by GitHub
parent 1c939a5f06
commit 0a89f9d1df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -70,7 +70,10 @@ class SQSResponse(BaseResponse):
def call_action(self): def call_action(self):
status_code, headers, body = super(SQSResponse, self).call_action() status_code, headers, body = super(SQSResponse, self).call_action()
if status_code == 404: if status_code == 404:
return 404, headers, ERROR_INEXISTENT_QUEUE queue_name = self.querystring.get("QueueName", [""])[0]
template = self.response_template(ERROR_INEXISTENT_QUEUE)
response = template.render(queue_name=queue_name)
return 404, headers, response
return status_code, headers, body return status_code, headers, body
def _error(self, code, message, status=400): def _error(self, code, message, status=400):
@ -718,7 +721,11 @@ ERROR_INEXISTENT_QUEUE = """<ErrorResponse xmlns="http://queue.amazonaws.com/doc
<Error> <Error>
<Type>Sender</Type> <Type>Sender</Type>
<Code>AWS.SimpleQueueService.NonExistentQueue</Code> <Code>AWS.SimpleQueueService.NonExistentQueue</Code>
<Message>The specified queue does not exist for this wsdl version.</Message> {% if queue_name %}
<Message>The specified queue {{queue_name}} does not exist for this wsdl version.</Message>
{% else %}
<Message>The specified queue does not exist for this wsdl version.</Message>
{% endif %}
<Detail/> <Detail/>
</Error> </Error>
<RequestId>b8bc806b-fa6b-53b5-8be8-cfa2f9836bc3</RequestId> <RequestId>b8bc806b-fa6b-53b5-8be8-cfa2f9836bc3</RequestId>

View File

@ -198,7 +198,8 @@ def test_get_queue_url_errors():
client = boto3.client("sqs", region_name="us-east-1") client = boto3.client("sqs", region_name="us-east-1")
client.get_queue_url.when.called_with(QueueName="non-existing-queue").should.throw( client.get_queue_url.when.called_with(QueueName="non-existing-queue").should.throw(
ClientError, "The specified queue does not exist for this wsdl version." ClientError,
"The specified queue non-existing-queue does not exist for this wsdl version.",
) )
@ -206,10 +207,13 @@ def test_get_queue_url_errors():
def test_get_nonexistent_queue(): def test_get_nonexistent_queue():
sqs = boto3.resource("sqs", region_name="us-east-1") sqs = boto3.resource("sqs", region_name="us-east-1")
with assert_raises(ClientError) as err: with assert_raises(ClientError) as err:
sqs.get_queue_by_name(QueueName="nonexisting-queue") sqs.get_queue_by_name(QueueName="non-existing-queue")
ex = err.exception ex = err.exception
ex.operation_name.should.equal("GetQueueUrl") ex.operation_name.should.equal("GetQueueUrl")
ex.response["Error"]["Code"].should.equal("AWS.SimpleQueueService.NonExistentQueue") ex.response["Error"]["Code"].should.equal("AWS.SimpleQueueService.NonExistentQueue")
ex.response["Error"]["Message"].should.equal(
"The specified queue non-existing-queue does not exist for this wsdl version."
)
with assert_raises(ClientError) as err: with assert_raises(ClientError) as err:
sqs.Queue("http://whatever-incorrect-queue-address").load() sqs.Queue("http://whatever-incorrect-queue-address").load()