diff --git a/moto/sqs/models.py b/moto/sqs/models.py index e2fa034b0..3e1399fdf 100644 --- a/moto/sqs/models.py +++ b/moto/sqs/models.py @@ -642,6 +642,8 @@ class SQSBackend(BaseBackend): def get_queue_attributes(self, queue_name, attribute_names): queue = self.get_queue(queue_name) + if not attribute_names: + return {} valid_names = ( ["All"] diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index 14f842d25..935ba011a 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -1253,6 +1253,21 @@ def test_fifo_send_receive_message_with_attribute_name(attribute_name, expected) expected["SequenceNumber"](message["Attributes"].get("SequenceNumber")) +@mock_sqs +def test_get_queue_attributes_no_param(): + """ + AWS does not return the Attributes-key when omitting the AttributeNames-parameter + """ + sqs = boto3.client("sqs", region_name="ap-northeast-3") + queue_url = sqs.create_queue(QueueName="test-queue")["QueueUrl"] + + queue_attrs = sqs.get_queue_attributes(QueueUrl=queue_url) + queue_attrs.shouldnt.have.key("Attributes") + + queue_attrs = sqs.get_queue_attributes(QueueUrl=queue_url, AttributeNames=["All"]) + queue_attrs.should.have.key("Attributes") + + @mock_sqs def test_max_number_of_messages_invalid_param(): sqs = boto3.resource("sqs", region_name="us-east-1")