Validate message group ID for standard queues (#4635)
This commit is contained in:
parent
ce0d21e9c6
commit
26a732a0e9
@ -738,6 +738,12 @@ class SQSBackend(BaseBackend):
|
|||||||
if queue.fifo_queue:
|
if queue.fifo_queue:
|
||||||
raise MissingParameter("MessageGroupId")
|
raise MissingParameter("MessageGroupId")
|
||||||
else:
|
else:
|
||||||
|
if not queue.fifo_queue:
|
||||||
|
msg = (
|
||||||
|
"Value {} for parameter MessageGroupId is invalid. "
|
||||||
|
"Reason: The request include parameter that is not valid for this queue type."
|
||||||
|
).format(group_id)
|
||||||
|
raise InvalidParameterValue(msg)
|
||||||
message.group_id = group_id
|
message.group_id = group_id
|
||||||
|
|
||||||
if message_attributes:
|
if message_attributes:
|
||||||
|
@ -557,6 +557,24 @@ def test_send_message_with_message_group_id():
|
|||||||
message_attributes["MessageDeduplicationId"].should.equal("dedupe_id_1")
|
message_attributes["MessageDeduplicationId"].should.equal("dedupe_id_1")
|
||||||
|
|
||||||
|
|
||||||
|
@mock_sqs
|
||||||
|
def test_send_message_with_message_group_id_standard_queue():
|
||||||
|
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||||
|
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
|
||||||
|
|
||||||
|
with pytest.raises(ClientError) as ex:
|
||||||
|
queue.send_message(
|
||||||
|
MessageBody="mydata", MessageGroupId="group_id_1",
|
||||||
|
)
|
||||||
|
|
||||||
|
err = ex.value.response["Error"]
|
||||||
|
err["Code"].should.equal("InvalidParameterValue")
|
||||||
|
err["Message"].should.equal(
|
||||||
|
"Value group_id_1 for parameter MessageGroupId is invalid. "
|
||||||
|
"Reason: The request include parameter that is not valid for this queue type."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_sqs
|
@mock_sqs
|
||||||
def test_send_message_with_unicode_characters():
|
def test_send_message_with_unicode_characters():
|
||||||
body_one = "Héllo!😀"
|
body_one = "Héllo!😀"
|
||||||
@ -2097,7 +2115,9 @@ def test_delete_message_errors():
|
|||||||
@mock_sqs
|
@mock_sqs
|
||||||
def test_send_message_batch():
|
def test_send_message_batch():
|
||||||
client = boto3.client("sqs", region_name="us-east-1")
|
client = boto3.client("sqs", region_name="us-east-1")
|
||||||
response = client.create_queue(QueueName=str(uuid4())[0:6])
|
response = client.create_queue(
|
||||||
|
QueueName=f"{str(uuid4())[0:6]}.fifo", Attributes={"FifoQueue": "true"},
|
||||||
|
)
|
||||||
queue_url = response["QueueUrl"]
|
queue_url = response["QueueUrl"]
|
||||||
|
|
||||||
response = client.send_message_batch(
|
response = client.send_message_batch(
|
||||||
|
Loading…
Reference in New Issue
Block a user