Merge pull request #1034 from whummer/fix/receive-queue-name-with-dot

Fix receiving of messages from queues with a dot character in their name
This commit is contained in:
Jack Danger 2017-08-05 00:39:22 -07:00 committed by GitHub
commit ac99ece5ca
2 changed files with 20 additions and 13 deletions

View File

@ -9,5 +9,5 @@ dispatch = SQSResponse().dispatch
url_paths = {
'{0}/$': dispatch,
'{0}/(?P<account_id>\d+)/(?P<queue_name>[a-zA-Z0-9\-_]+)': dispatch,
'{0}/(?P<account_id>\d+)/(?P<queue_name>[a-zA-Z0-9\-_\.]+)': dispatch,
}

View File

@ -19,22 +19,29 @@ def test_sqs_list_identities():
res = test_client.get('/?Action=ListQueues')
res.data.should.contain(b"ListQueuesResponse")
res = test_client.put('/?Action=CreateQueue&QueueName=testqueue')
res = test_client.put('/?Action=CreateQueue&QueueName=otherqueue')
# Make sure that we can receive messages from queues whose name contains dots (".")
# The AWS API mandates that the names of FIFO queues use the suffix ".fifo"
# See: https://github.com/spulec/moto/issues/866
for queue_name in ('testqueue', 'otherqueue.fifo'):
res = test_client.put('/?Action=CreateQueue&QueueName=%s' % queue_name)
res = test_client.put(
'/123/%s?MessageBody=test-message&Action=SendMessage' % queue_name)
res = test_client.get(
'/123/%s?Action=ReceiveMessage&MaxNumberOfMessages=1' % queue_name)
message = re.search("<Body>(.*?)</Body>",
res.data.decode('utf-8')).groups()[0]
message.should.equal('test-message')
res = test_client.get('/?Action=ListQueues&QueueNamePrefix=other')
res.data.should.contain(b'otherqueue.fifo')
res.data.should_not.contain(b'testqueue')
res = test_client.put(
'/123/testqueue?MessageBody=test-message&Action=SendMessage')
res = test_client.get(
'/123/testqueue?Action=ReceiveMessage&MaxNumberOfMessages=1')
message = re.search("<Body>(.*?)</Body>",
res.data.decode('utf-8')).groups()[0]
message.should.equal('test-message')
def test_messages_polling():
backend = server.create_backend_app("sqs")