Fix:sqs get-queue-attributes response template (#3255)

* Fix:sqs get-queue-attributes response template

* Fix:removed debug statements

* Modified the template

* "fixed build issues"

* Linting

Co-authored-by: usmankb <usman@krazybee.com>
Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
usmangani1 2020-09-01 22:35:25 +05:30 committed by GitHub
commit 3ea46617d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 5 deletions

View file

@ -45,6 +45,25 @@ sqs_template_with_tags = """
}
}"""
TEST_POLICY = """
{
"Version":"2012-10-17",
"Statement":[
{
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": "sqs:SendMessage",
"Resource": "'$sqs_queue_arn'",
"Condition":{
"ArnEquals":{
"aws:SourceArn":"'$sns_topic_arn'"
}
}
}
]
}
"""
@mock_sqs
def test_create_fifo_queue_fail():
@ -1451,6 +1470,36 @@ def test_permissions():
)
@mock_sqs
def test_get_queue_attributes_template_response_validation():
client = boto3.client("sqs", region_name="us-east-1")
resp = client.create_queue(
QueueName="test-dlr-queue.fifo", Attributes={"FifoQueue": "true"}
)
queue_url = resp["QueueUrl"]
attrs = client.get_queue_attributes(QueueUrl=queue_url, AttributeNames=["All"])
assert attrs.get("Attributes").get("Policy") is None
attributes = {"Policy": TEST_POLICY}
client.set_queue_attributes(QueueUrl=queue_url, Attributes=attributes)
attrs = client.get_queue_attributes(QueueUrl=queue_url, AttributeNames=["Policy"])
assert attrs.get("Attributes").get("Policy") is not None
assert (
json.loads(attrs.get("Attributes").get("Policy")).get("Version") == "2012-10-17"
)
assert len(json.loads(attrs.get("Attributes").get("Policy")).get("Statement")) == 1
assert (
json.loads(attrs.get("Attributes").get("Policy"))
.get("Statement")[0]
.get("Action")
== "sqs:SendMessage"
)
@mock_sqs
def test_add_permission_errors():
client = boto3.client("sqs", region_name="us-east-1")