diff options
author | n0061q <95093640+n0061q@users.noreply.github.com> | 2021-12-03 10:46:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-03 09:46:41 +0100 |
commit | 081e9e6cfff944acd14f9bd1f810d227a069a01c (patch) | |
tree | 0d6debabe1a31fffe4321bcf554e27f591522ac0 /t/unit | |
parent | a2d7cfd8aeab64c87eb0301b0f570eff9bffddc4 (diff) | |
download | kombu-081e9e6cfff944acd14f9bd1f810d227a069a01c.tar.gz |
SQS transport: detect FIFO queue properly by checking queue URL (#1450)
* SQS: detect FIFO queue properly
* SQS: validate predefined queues
Co-authored-by: Yaroslav Litus <Yaroslav.Litus@F-Secure.com>
Diffstat (limited to 't/unit')
-rw-r--r-- | t/unit/transport/test_SQS.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/t/unit/transport/test_SQS.py b/t/unit/transport/test_SQS.py index 944728f1..6056dd3d 100644 --- a/t/unit/transport/test_SQS.py +++ b/t/unit/transport/test_SQS.py @@ -38,6 +38,11 @@ example_predefined_queues = { 'access_key_id': 'c', 'secret_access_key': 'd', }, + 'queue-3.fifo': { + 'url': 'https://sqs.us-east-1.amazonaws.com/xxx/queue-3.fifo', + 'access_key_id': 'e', + 'secret_access_key': 'f', + } } @@ -151,6 +156,7 @@ class test_Channel: predefined_queues_sqs_conn_mocks = { 'queue-1': SQSClientMock(QueueName='queue-1'), 'queue-2': SQSClientMock(QueueName='queue-2'), + 'queue-3.fifo': SQSClientMock(QueueName='queue-3.fifo') } def mock_sqs(): @@ -738,6 +744,53 @@ class test_Channel: QueueUrl='https://sqs.us-east-1.amazonaws.com/xxx/queue-1', ReceiptHandle='test_message_id', VisibilityTimeout=20) + def test_predefined_queues_put_to_fifo_queue(self): + connection = Connection(transport=SQS.Transport, transport_options={ + 'predefined_queues': example_predefined_queues, + }) + channel = connection.channel() + + queue_name = 'queue-3.fifo' + + exchange = Exchange('test_SQS', type='direct') + p = messaging.Producer(channel, exchange, routing_key=queue_name) + + queue = Queue(queue_name, exchange, queue_name) + queue(channel).declare() + + channel.sqs = Mock() + sqs_queue_mock = Mock() + channel.sqs.return_value = sqs_queue_mock + p.publish('message') + + sqs_queue_mock.send_message.assert_called_once() + assert 'MessageGroupId' in sqs_queue_mock.send_message.call_args[1] + assert 'MessageDeduplicationId' in \ + sqs_queue_mock.send_message.call_args[1] + + @pytest.mark.parametrize('predefined_queues', ( + { + 'invalid-fifo-queue-name': { + 'url': 'https://sqs.us-east-1.amazonaws.com/xxx/queue.fifo', + 'access_key_id': 'a', + 'secret_access_key': 'b' + } + }, + { + 'standard-queue.fifo': { + 'url': 'https://sqs.us-east-1.amazonaws.com/xxx/queue', + 'access_key_id': 'a', + 'secret_access_key': 'b' + } + } + )) + def test_predefined_queues_invalid_configuration(self, predefined_queues): + connection = Connection(transport=SQS.Transport, transport_options={ + 'predefined_queues': predefined_queues, + }) + with pytest.raises(SQS.InvalidQueueException): + connection.channel() + def test_sts_new_session(self): # Arrange connection = Connection(transport=SQS.Transport, transport_options={ |