Added references to moto.iam.models.ACCOUNT_ID instead of hardcoded id

This commit is contained in:
Fabio Dias 2019-12-15 19:22:26 -05:00
commit b83a750630
54 changed files with 326 additions and 295 deletions

View file

@ -12,6 +12,7 @@ from boto3 import Session
from moto.compat import OrderedDict
from moto.core import BaseBackend, BaseModel
from moto.iam.models import ACCOUNT_ID
from moto.core.utils import (
iso_8601_datetime_with_milliseconds,
camelcase_to_underscores,
@ -31,7 +32,7 @@ from .exceptions import (
)
from .utils import make_arn_for_topic, make_arn_for_subscription, is_e164
DEFAULT_ACCOUNT_ID = 123456789012
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
DEFAULT_PAGE_SIZE = 100
MAXIMUM_MESSAGE_LENGTH = 262144 # 256 KiB
@ -259,7 +260,7 @@ class Subscription(BaseModel):
"SignatureVersion": "1",
"Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
"SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
"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",
"UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:{}:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55".format(ACCOUNT_ID),
}
if message_attributes:
post_data["MessageAttributes"] = message_attributes
@ -275,8 +276,8 @@ class PlatformApplication(BaseModel):
@property
def arn(self):
return "arn:aws:sns:{region}:123456789012:app/{platform}/{name}".format(
region=self.region, platform=self.platform, name=self.name
return "arn:aws:sns:{region}:{AccountId}:app/{platform}/{name}".format(
region=self.region, platform=self.platform, name=self.name, AccountId=ACCOUNT_ID
)
@ -305,8 +306,9 @@ class PlatformEndpoint(BaseModel):
@property
def arn(self):
return "arn:aws:sns:{region}:123456789012:endpoint/{platform}/{name}/{id}".format(
return "arn:aws:sns:{region}:{AccountId}:endpoint/{platform}/{name}/{id}".format(
region=self.region,
AccountId=ACCOUNT_ID,
platform=self.application.platform,
name=self.application.name,
id=self.id,