Added references to moto.iam.models.ACCOUNT_ID instead of hardcoded id
This commit is contained in:
parent
6969c887e4
commit
b83a750630
54 changed files with 326 additions and 295 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
import boto
|
||||
from boto.exception import BotoServerError
|
||||
from moto import mock_sns_deprecated
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
import sure # noqa
|
||||
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ def test_create_platform_application():
|
|||
"CreatePlatformApplicationResult"
|
||||
]["PlatformApplicationArn"]
|
||||
application_arn.should.equal(
|
||||
"arn:aws:sns:us-east-1:123456789012:app/APNS/my-application"
|
||||
"arn:aws:sns:us-east-1:{}:app/APNS/my-application".format(ACCOUNT_ID)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -137,7 +138,7 @@ def test_create_platform_endpoint():
|
|||
"CreatePlatformEndpointResult"
|
||||
]["EndpointArn"]
|
||||
endpoint_arn.should.contain(
|
||||
"arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/"
|
||||
"arn:aws:sns:us-east-1:{}:endpoint/APNS/my-application/".format(ACCOUNT_ID)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import boto3
|
|||
from botocore.exceptions import ClientError
|
||||
from moto import mock_sns
|
||||
import sure # noqa
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -19,7 +20,7 @@ def test_create_platform_application():
|
|||
)
|
||||
application_arn = response["PlatformApplicationArn"]
|
||||
application_arn.should.equal(
|
||||
"arn:aws:sns:us-east-1:123456789012:app/APNS/my-application"
|
||||
"arn:aws:sns:us-east-1:{}:app/APNS/my-application".format(ACCOUNT_ID)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -131,7 +132,7 @@ def test_create_platform_endpoint():
|
|||
|
||||
endpoint_arn = endpoint["EndpointArn"]
|
||||
endpoint_arn.should.contain(
|
||||
"arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/"
|
||||
"arn:aws:sns:us-east-1:{}:endpoint/APNS/my-application/".format(ACCOUNT_ID)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ from freezegun import freeze_time
|
|||
import sure # noqa
|
||||
|
||||
from moto import mock_sns_deprecated, mock_sqs_deprecated
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
|
||||
|
||||
MESSAGE_FROM_SQS_TEMPLATE = '{\n "Message": "%s",\n "MessageId": "%s",\n "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",\n "SignatureVersion": "1",\n "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",\n "Subject": "%s",\n "Timestamp": "2015-01-01T12:00:00.000Z",\n "TopicArn": "arn:aws:sns:%s:123456789012:some-topic",\n "Type": "Notification",\n "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"\n}'
|
||||
MESSAGE_FROM_SQS_TEMPLATE = '{\n "Message": "%s",\n "MessageId": "%s",\n "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",\n "SignatureVersion": "1",\n "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",\n "Subject": "%s",\n "Timestamp": "2015-01-01T12:00:00.000Z",\n "TopicArn": "arn:aws:sns:%s:'+ACCOUNT_ID+':some-topic",\n "Type": "Notification",\n "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:'+ACCOUNT_ID+':some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"\n}'
|
||||
|
||||
|
||||
@mock_sqs_deprecated
|
||||
|
|
@ -25,7 +25,7 @@ def test_publish_to_sqs():
|
|||
sqs_conn = boto.connect_sqs()
|
||||
sqs_conn.create_queue("test-queue")
|
||||
|
||||
conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-east-1:123456789012:test-queue")
|
||||
conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID))
|
||||
|
||||
message_to_publish = "my message"
|
||||
subject_to_publish = "test subject"
|
||||
|
|
@ -66,7 +66,7 @@ def test_publish_to_sqs_in_different_region():
|
|||
sqs_conn = boto.sqs.connect_to_region("us-west-2")
|
||||
sqs_conn.create_queue("test-queue")
|
||||
|
||||
conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-west-2:123456789012:test-queue")
|
||||
conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-west-2:{}:test-queue".format(ACCOUNT_ID))
|
||||
|
||||
message_to_publish = "my message"
|
||||
subject_to_publish = "test subject"
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ import responses
|
|||
from botocore.exceptions import ClientError
|
||||
from nose.tools import assert_raises
|
||||
from moto import mock_sns, mock_sqs
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
|
||||
|
||||
MESSAGE_FROM_SQS_TEMPLATE = '{\n "Message": "%s",\n "MessageId": "%s",\n "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",\n "SignatureVersion": "1",\n "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",\n "Subject": "my subject",\n "Timestamp": "2015-01-01T12:00:00.000Z",\n "TopicArn": "arn:aws:sns:%s:123456789012:some-topic",\n "Type": "Notification",\n "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"\n}'
|
||||
MESSAGE_FROM_SQS_TEMPLATE = '{\n "Message": "%s",\n "MessageId": "%s",\n "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",\n "SignatureVersion": "1",\n "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",\n "Subject": "my subject",\n "Timestamp": "2015-01-01T12:00:00.000Z",\n "TopicArn": "arn:aws:sns:%s:'+ACCOUNT_ID+':some-topic",\n "Type": "Notification",\n "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:'+ACCOUNT_ID+':some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"\n}'
|
||||
|
||||
|
||||
@mock_sqs
|
||||
|
|
@ -31,7 +31,7 @@ def test_publish_to_sqs():
|
|||
conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:us-east-1:123456789012:test-queue",
|
||||
Endpoint="arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID),
|
||||
)
|
||||
message = "my message"
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
|
|
@ -88,7 +88,7 @@ def test_publish_to_sqs_bad():
|
|||
conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:us-east-1:123456789012:test-queue",
|
||||
Endpoint="arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID),
|
||||
)
|
||||
message = "my message"
|
||||
try:
|
||||
|
|
@ -149,7 +149,7 @@ def test_publish_to_sqs_msg_attr_byte_value():
|
|||
conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:us-east-1:123456789012:test-queue",
|
||||
Endpoint="arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID),
|
||||
)
|
||||
message = "my message"
|
||||
conn.publish(
|
||||
|
|
@ -243,7 +243,7 @@ def test_publish_to_sqs_dump_json():
|
|||
conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:us-east-1:123456789012:test-queue",
|
||||
Endpoint="arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID),
|
||||
)
|
||||
|
||||
message = json.dumps(
|
||||
|
|
@ -289,7 +289,7 @@ def test_publish_to_sqs_in_different_region():
|
|||
conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:us-west-2:123456789012:test-queue",
|
||||
Endpoint="arn:aws:sqs:us-west-2:{}:test-queue".format(ACCOUNT_ID),
|
||||
)
|
||||
|
||||
message = "my message"
|
||||
|
|
@ -348,7 +348,7 @@ def test_publish_subject():
|
|||
conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:us-east-1:123456789012:test-queue",
|
||||
Endpoint="arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID),
|
||||
)
|
||||
message = "my message"
|
||||
subject1 = "test subject"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
|
||||
import sure # noqa
|
||||
|
||||
|
|
@ -16,11 +17,11 @@ def test_sns_server_get():
|
|||
topic_data = test_client.action_data("CreateTopic", Name="testtopic")
|
||||
topic_data.should.contain("CreateTopicResult")
|
||||
topic_data.should.contain(
|
||||
"<TopicArn>arn:aws:sns:us-east-1:123456789012:testtopic</TopicArn>"
|
||||
"<TopicArn>arn:aws:sns:us-east-1:{}:testtopic</TopicArn>".format(ACCOUNT_ID)
|
||||
)
|
||||
|
||||
topics_data = test_client.action_data("ListTopics")
|
||||
topics_data.should.contain("ListTopicsResult")
|
||||
topic_data.should.contain(
|
||||
"<TopicArn>arn:aws:sns:us-east-1:123456789012:testtopic</TopicArn>"
|
||||
"<TopicArn>arn:aws:sns:us-east-1:{}:testtopic</TopicArn>".format(ACCOUNT_ID)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import sure # noqa
|
|||
from boto.exception import BotoServerError
|
||||
from moto import mock_sns_deprecated
|
||||
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -19,7 +20,7 @@ def test_create_and_delete_topic():
|
|||
topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
|
||||
topics.should.have.length_of(1)
|
||||
topics[0]["TopicArn"].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:some-topic".format(conn.region.name)
|
||||
"arn:aws:sns:{0}:{1}:some-topic".format(conn.region.name, ACCOUNT_ID)
|
||||
)
|
||||
|
||||
# Delete the topic
|
||||
|
|
@ -58,7 +59,7 @@ def test_topic_corresponds_to_region():
|
|||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0][
|
||||
"TopicArn"
|
||||
]
|
||||
topic_arn.should.equal("arn:aws:sns:{0}:123456789012:some-topic".format(region))
|
||||
topic_arn.should.equal("arn:aws:sns:{0}:{1}:some-topic".format(region, ACCOUNT_ID))
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -75,9 +76,9 @@ def test_topic_attributes():
|
|||
"GetTopicAttributesResult"
|
||||
]["Attributes"]
|
||||
attributes["TopicArn"].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:some-topic".format(conn.region.name)
|
||||
"arn:aws:sns:{0}:{1}:some-topic".format(conn.region.name, ACCOUNT_ID)
|
||||
)
|
||||
attributes["Owner"].should.equal(123456789012)
|
||||
attributes["Owner"].should.equal(ACCOUNT_ID)
|
||||
json.loads(attributes["Policy"]).should.equal(
|
||||
{
|
||||
"Version": "2008-10-17",
|
||||
|
|
@ -98,8 +99,8 @@ def test_topic_attributes():
|
|||
"SNS:Publish",
|
||||
"SNS:Receive",
|
||||
],
|
||||
"Resource": "arn:aws:sns:us-east-1:123456789012:some-topic",
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
||||
"Resource": "arn:aws:sns:us-east-1:{}:some-topic".format(ACCOUNT_ID),
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import sure # noqa
|
|||
from botocore.exceptions import ClientError
|
||||
from moto import mock_sns
|
||||
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
|
||||
|
||||
from moto.iam.models import ACCOUNT_ID
|
||||
|
||||
@mock_sns
|
||||
def test_create_and_delete_topic():
|
||||
|
|
@ -20,8 +20,8 @@ def test_create_and_delete_topic():
|
|||
topics = topics_json["Topics"]
|
||||
topics.should.have.length_of(1)
|
||||
topics[0]["TopicArn"].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:{1}".format(
|
||||
conn._client_config.region_name, topic_name
|
||||
"arn:aws:sns:{0}:{1}:{2}".format(
|
||||
conn._client_config.region_name, ACCOUNT_ID, topic_name
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ def test_topic_corresponds_to_region():
|
|||
conn.create_topic(Name="some-topic")
|
||||
topics_json = conn.list_topics()
|
||||
topic_arn = topics_json["Topics"][0]["TopicArn"]
|
||||
topic_arn.should.equal("arn:aws:sns:{0}:123456789012:some-topic".format(region))
|
||||
topic_arn.should.equal("arn:aws:sns:{0}:{1}:some-topic".format(region, ACCOUNT_ID))
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -145,11 +145,11 @@ def test_topic_attributes():
|
|||
|
||||
attributes = conn.get_topic_attributes(TopicArn=topic_arn)["Attributes"]
|
||||
attributes["TopicArn"].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:some-topic".format(
|
||||
conn._client_config.region_name
|
||||
"arn:aws:sns:{0}:{1}:some-topic".format(
|
||||
conn._client_config.region_name, ACCOUNT_ID
|
||||
)
|
||||
)
|
||||
attributes["Owner"].should.equal("123456789012")
|
||||
attributes["Owner"].should.equal(ACCOUNT_ID)
|
||||
json.loads(attributes["Policy"]).should.equal(
|
||||
{
|
||||
"Version": "2008-10-17",
|
||||
|
|
@ -170,8 +170,8 @@ def test_topic_attributes():
|
|||
"SNS:Publish",
|
||||
"SNS:Receive",
|
||||
],
|
||||
"Resource": "arn:aws:sns:us-east-1:123456789012:some-topic",
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
||||
"Resource": "arn:aws:sns:us-east-1:{}:some-topic".format(ACCOUNT_ID),
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
@ -271,15 +271,15 @@ def test_add_remove_permissions():
|
|||
"SNS:Publish",
|
||||
"SNS:Receive",
|
||||
],
|
||||
"Resource": "arn:aws:sns:us-east-1:123456789012:test-permissions",
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
||||
"Resource": "arn:aws:sns:us-east-1:{}:test-permissions".format(ACCOUNT_ID),
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||
},
|
||||
{
|
||||
"Sid": "test",
|
||||
"Effect": "Allow",
|
||||
"Principal": {"AWS": "arn:aws:iam::999999999999:root"},
|
||||
"Action": "SNS:Publish",
|
||||
"Resource": "arn:aws:sns:us-east-1:123456789012:test-permissions",
|
||||
"Resource": "arn:aws:sns:us-east-1:{}:test-permissions".format(ACCOUNT_ID),
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -308,8 +308,8 @@ def test_add_remove_permissions():
|
|||
"SNS:Publish",
|
||||
"SNS:Receive",
|
||||
],
|
||||
"Resource": "arn:aws:sns:us-east-1:123456789012:test-permissions",
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
||||
"Resource": "arn:aws:sns:us-east-1:{}:test-permissions".format(ACCOUNT_ID),
|
||||
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ def test_add_remove_permissions():
|
|||
]
|
||||
},
|
||||
"Action": ["SNS:Publish", "SNS:Subscribe"],
|
||||
"Resource": "arn:aws:sns:us-east-1:123456789012:test-permissions",
|
||||
"Resource": "arn:aws:sns:us-east-1:{}:test-permissions".format(ACCOUNT_ID),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue