Added references to moto.iam.models.ACCOUNT_ID instead of hardcoded id
This commit is contained in:
parent
6969c887e4
commit
b83a750630
@ -13,8 +13,9 @@ import cryptography.hazmat.primitives.asymmetric.rsa
|
|||||||
from cryptography.hazmat.primitives import serialization, hashes
|
from cryptography.hazmat.primitives import serialization, hashes
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
|
||||||
|
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_ACCOUNT_ID = 123456789012
|
|
||||||
GOOGLE_ROOT_CA = b"""-----BEGIN CERTIFICATE-----
|
GOOGLE_ROOT_CA = b"""-----BEGIN CERTIFICATE-----
|
||||||
MIIEKDCCAxCgAwIBAgIQAQAhJYiw+lmnd+8Fe2Yn3zANBgkqhkiG9w0BAQsFADBC
|
MIIEKDCCAxCgAwIBAgIQAQAhJYiw+lmnd+8Fe2Yn3zANBgkqhkiG9w0BAQsFADBC
|
||||||
MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMS
|
MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMS
|
||||||
|
@ -4,7 +4,7 @@ import time
|
|||||||
import boto3
|
import boto3
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
|
|
||||||
ACCOUNT_ID = 123456789012
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
class TaggableResourceMixin(object):
|
class TaggableResourceMixin(object):
|
||||||
|
@ -45,7 +45,7 @@ from moto.dynamodbstreams import dynamodbstreams_backends
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
ACCOUNT_ID = "123456789012"
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -28,11 +28,10 @@ from .utils import (
|
|||||||
from moto.ec2.exceptions import InvalidSubnetIdError
|
from moto.ec2.exceptions import InvalidSubnetIdError
|
||||||
from moto.ec2.models import INSTANCE_TYPES as EC2_INSTANCE_TYPES
|
from moto.ec2.models import INSTANCE_TYPES as EC2_INSTANCE_TYPES
|
||||||
from moto.iam.exceptions import IAMNotFoundException
|
from moto.iam.exceptions import IAMNotFoundException
|
||||||
|
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
|
||||||
|
|
||||||
_orig_adapter_send = requests.adapters.HTTPAdapter.send
|
_orig_adapter_send = requests.adapters.HTTPAdapter.send
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
DEFAULT_ACCOUNT_ID = 123456789012
|
|
||||||
COMPUTE_ENVIRONMENT_NAME_REGEX = re.compile(
|
COMPUTE_ENVIRONMENT_NAME_REGEX = re.compile(
|
||||||
r"^[A-Za-z0-9][A-Za-z0-9_-]{1,126}[A-Za-z0-9]$"
|
r"^[A-Za-z0-9][A-Za-z0-9_-]{1,126}[A-Za-z0-9]$"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +27,7 @@ from moto.route53 import models as route53_models
|
|||||||
from moto.s3 import models as s3_models
|
from moto.s3 import models as s3_models
|
||||||
from moto.sns import models as sns_models
|
from moto.sns import models as sns_models
|
||||||
from moto.sqs import models as sqs_models
|
from moto.sqs import models as sqs_models
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from .utils import random_suffix
|
from .utils import random_suffix
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
ExportNotFound,
|
ExportNotFound,
|
||||||
@ -431,7 +432,7 @@ class ResourceMap(collections.Mapping):
|
|||||||
|
|
||||||
# Create the default resources
|
# Create the default resources
|
||||||
self._parsed_resources = {
|
self._parsed_resources = {
|
||||||
"AWS::AccountId": "123456789012",
|
"AWS::AccountId": ACCOUNT_ID,
|
||||||
"AWS::Region": self._region_name,
|
"AWS::Region": self._region_name,
|
||||||
"AWS::StackId": stack_id,
|
"AWS::StackId": stack_id,
|
||||||
"AWS::StackName": stack_name,
|
"AWS::StackName": stack_name,
|
||||||
|
@ -7,6 +7,7 @@ from six.moves.urllib.parse import urlparse
|
|||||||
from moto.core.responses import BaseResponse
|
from moto.core.responses import BaseResponse
|
||||||
from moto.core.utils import amzn_request_id
|
from moto.core.utils import amzn_request_id
|
||||||
from moto.s3 import s3_backend
|
from moto.s3 import s3_backend
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from .models import cloudformation_backends
|
from .models import cloudformation_backends
|
||||||
from .exceptions import ValidationError
|
from .exceptions import ValidationError
|
||||||
|
|
||||||
@ -425,7 +426,7 @@ class CloudFormationResponse(BaseResponse):
|
|||||||
stackset = self.cloudformation_backend.get_stack_set(stackset_name)
|
stackset = self.cloudformation_backend.get_stack_set(stackset_name)
|
||||||
|
|
||||||
if not stackset.admin_role:
|
if not stackset.admin_role:
|
||||||
stackset.admin_role = "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole"
|
stackset.admin_role = "arn:aws:iam::{AccountId}:role/AWSCloudFormationStackSetAdministrationRole".format(AccountId=ACCOUNT_ID)
|
||||||
if not stackset.execution_role:
|
if not stackset.execution_role:
|
||||||
stackset.execution_role = "AWSCloudFormationStackSetExecutionRole"
|
stackset.execution_role = "AWSCloudFormationStackSetExecutionRole"
|
||||||
|
|
||||||
@ -1055,7 +1056,7 @@ DESCRIBE_STACKSET_OPERATION_RESPONSE_TEMPLATE = """<DescribeStackSetOperationRes
|
|||||||
<DescribeStackSetOperationResult>
|
<DescribeStackSetOperationResult>
|
||||||
<StackSetOperation>
|
<StackSetOperation>
|
||||||
<ExecutionRoleName>{{ stackset.execution_role }}</ExecutionRoleName>
|
<ExecutionRoleName>{{ stackset.execution_role }}</ExecutionRoleName>
|
||||||
<AdministrationRoleARN>arn:aws:iam::123456789012:role/{{ stackset.admin_role }}</AdministrationRoleARN>
|
<AdministrationRoleARN>arn:aws:iam::"""+ACCOUNT_ID+""":role/{{ stackset.admin_role }}</AdministrationRoleARN>
|
||||||
<StackSetId>{{ stackset.id }}</StackSetId>
|
<StackSetId>{{ stackset.id }}</StackSetId>
|
||||||
<CreationTimestamp>{{ operation.CreationTimestamp }}</CreationTimestamp>
|
<CreationTimestamp>{{ operation.CreationTimestamp }}</CreationTimestamp>
|
||||||
<OperationId>{{ operation.OperationId }}</OperationId>
|
<OperationId>{{ operation.OperationId }}</OperationId>
|
||||||
@ -1080,7 +1081,7 @@ LIST_STACK_SET_OPERATION_RESULTS_RESPONSE_TEMPLATE = """<ListStackSetOperationRe
|
|||||||
{% for account, region in instance.items() %}
|
{% for account, region in instance.items() %}
|
||||||
<member>
|
<member>
|
||||||
<AccountGateResult>
|
<AccountGateResult>
|
||||||
<StatusReason>Function not found: arn:aws:lambda:us-west-2:123456789012:function:AWSCloudFormationStackSetAccountGate</StatusReason>
|
<StatusReason>Function not found: arn:aws:lambda:us-west-2:"""+ACCOUNT_ID+""":function:AWSCloudFormationStackSetAccountGate</StatusReason>
|
||||||
<Status>SKIPPED</Status>
|
<Status>SKIPPED</Status>
|
||||||
</AccountGateResult>
|
</AccountGateResult>
|
||||||
<Region>{{ region }}</Region>
|
<Region>{{ region }}</Region>
|
||||||
|
@ -7,7 +7,7 @@ import os
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
from cfnlint import decode, core
|
from cfnlint import decode, core
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
def generate_stack_id(stack_name, region="us-east-1", account="123456789"):
|
def generate_stack_id(stack_name, region="us-east-1", account="123456789"):
|
||||||
random_id = uuid.uuid4()
|
random_id = uuid.uuid4()
|
||||||
@ -29,8 +29,8 @@ def generate_stackset_id(stackset_name):
|
|||||||
|
|
||||||
|
|
||||||
def generate_stackset_arn(stackset_id, region_name):
|
def generate_stackset_arn(stackset_id, region_name):
|
||||||
return "arn:aws:cloudformation:{}:123456789012:stackset/{}".format(
|
return "arn:aws:cloudformation:{}:{}:stackset/{}".format(
|
||||||
region_name, stackset_id
|
region_name, ACCOUNT_ID, stackset_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from dateutil.tz import tzutc
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from .utils import make_arn_for_dashboard
|
from .utils import make_arn_for_dashboard
|
||||||
|
|
||||||
DEFAULT_ACCOUNT_ID = 123456789012
|
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
|
||||||
|
|
||||||
_EMPTY_LIST = tuple()
|
_EMPTY_LIST = tuple()
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ from moto.config.exceptions import (
|
|||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
from moto.s3.config import s3_config_query
|
from moto.s3.config import s3_config_query
|
||||||
|
|
||||||
DEFAULT_ACCOUNT_ID = "123456789012"
|
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
|
||||||
POP_STRINGS = [
|
POP_STRINGS = [
|
||||||
"capitalizeStart",
|
"capitalizeStart",
|
||||||
"CapitalizeStart",
|
"CapitalizeStart",
|
||||||
|
@ -6,6 +6,7 @@ import json
|
|||||||
from moto.compat import OrderedDict
|
from moto.compat import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
from moto.core.utils import unix_time
|
from moto.core.utils import unix_time
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from .comparisons import get_comparison_func
|
from .comparisons import get_comparison_func
|
||||||
|
|
||||||
|
|
||||||
@ -277,8 +278,8 @@ class Table(BaseModel):
|
|||||||
if attribute_name == "StreamArn":
|
if attribute_name == "StreamArn":
|
||||||
region = "us-east-1"
|
region = "us-east-1"
|
||||||
time = "2000-01-01T00:00:00.000"
|
time = "2000-01-01T00:00:00.000"
|
||||||
return "arn:aws:dynamodb:{0}:123456789012:table/{1}/stream/{2}".format(
|
return "arn:aws:dynamodb:{0}:{1}:table/{2}/stream/{3}".format(
|
||||||
region, self.name, time
|
region, ACCOUNT_ID, self.name, time
|
||||||
)
|
)
|
||||||
raise UnformattedGetAttTemplateException()
|
raise UnformattedGetAttTemplateException()
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from moto.core.responses import BaseResponse
|
|||||||
from moto.core.utils import camelcase_to_underscores
|
from moto.core.utils import camelcase_to_underscores
|
||||||
from moto.ec2.utils import filters_from_querystring, dict_from_querystring
|
from moto.ec2.utils import filters_from_querystring, dict_from_querystring
|
||||||
from moto.elbv2 import elbv2_backends
|
from moto.elbv2 import elbv2_backends
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
class InstanceResponse(BaseResponse):
|
class InstanceResponse(BaseResponse):
|
||||||
def describe_instances(self):
|
def describe_instances(self):
|
||||||
@ -249,7 +249,7 @@ class InstanceResponse(BaseResponse):
|
|||||||
EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
||||||
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
||||||
<reservationId>{{ reservation.id }}</reservationId>
|
<reservationId>{{ reservation.id }}</reservationId>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<groupSet>
|
<groupSet>
|
||||||
<item>
|
<item>
|
||||||
<groupId>sg-245f6a01</groupId>
|
<groupId>sg-245f6a01</groupId>
|
||||||
@ -331,7 +331,7 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
|
|||||||
<vpcId>{{ nic.subnet.vpc_id }}</vpcId>
|
<vpcId>{{ nic.subnet.vpc_id }}</vpcId>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<description>Primary network interface</description>
|
<description>Primary network interface</description>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<status>in-use</status>
|
<status>in-use</status>
|
||||||
<macAddress>1b:2b:3c:4d:5e:6f</macAddress>
|
<macAddress>1b:2b:3c:4d:5e:6f</macAddress>
|
||||||
<privateIpAddress>{{ nic.private_ip_address }}</privateIpAddress>
|
<privateIpAddress>{{ nic.private_ip_address }}</privateIpAddress>
|
||||||
@ -354,7 +354,7 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
|
|||||||
{% if nic.public_ip %}
|
{% if nic.public_ip %}
|
||||||
<association>
|
<association>
|
||||||
<publicIp>{{ nic.public_ip }}</publicIp>
|
<publicIp>{{ nic.public_ip }}</publicIp>
|
||||||
<ipOwnerId>123456789012</ipOwnerId>
|
<ipOwnerId>"""+ACCOUNT_ID+"""</ipOwnerId>
|
||||||
</association>
|
</association>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<privateIpAddressesSet>
|
<privateIpAddressesSet>
|
||||||
@ -364,7 +364,7 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
|
|||||||
{% if nic.public_ip %}
|
{% if nic.public_ip %}
|
||||||
<association>
|
<association>
|
||||||
<publicIp>{{ nic.public_ip }}</publicIp>
|
<publicIp>{{ nic.public_ip }}</publicIp>
|
||||||
<ipOwnerId>123456789012</ipOwnerId>
|
<ipOwnerId>"""+ACCOUNT_ID+"""</ipOwnerId>
|
||||||
</association>
|
</association>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</item>
|
</item>
|
||||||
@ -383,7 +383,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns="http://ec2.amazona
|
|||||||
{% for reservation in reservations %}
|
{% for reservation in reservations %}
|
||||||
<item>
|
<item>
|
||||||
<reservationId>{{ reservation.id }}</reservationId>
|
<reservationId>{{ reservation.id }}</reservationId>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<groupSet>
|
<groupSet>
|
||||||
{% for group in reservation.dynamic_group_list %}
|
{% for group in reservation.dynamic_group_list %}
|
||||||
<item>
|
<item>
|
||||||
@ -476,7 +476,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns="http://ec2.amazona
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</blockDeviceMapping>
|
</blockDeviceMapping>
|
||||||
<virtualizationType>{{ instance.virtualization_type }}</virtualizationType>
|
<virtualizationType>{{ instance.virtualization_type }}</virtualizationType>
|
||||||
<clientToken>ABCDE1234567890123</clientToken>
|
<clientToken>ABCDE"""+ACCOUNT_ID+"""3</clientToken>
|
||||||
{% if instance.get_tags() %}
|
{% if instance.get_tags() %}
|
||||||
<tagSet>
|
<tagSet>
|
||||||
{% for tag in instance.get_tags() %}
|
{% for tag in instance.get_tags() %}
|
||||||
@ -499,7 +499,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns="http://ec2.amazona
|
|||||||
<vpcId>{{ nic.subnet.vpc_id }}</vpcId>
|
<vpcId>{{ nic.subnet.vpc_id }}</vpcId>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<description>Primary network interface</description>
|
<description>Primary network interface</description>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<status>in-use</status>
|
<status>in-use</status>
|
||||||
<macAddress>1b:2b:3c:4d:5e:6f</macAddress>
|
<macAddress>1b:2b:3c:4d:5e:6f</macAddress>
|
||||||
<privateIpAddress>{{ nic.private_ip_address }}</privateIpAddress>
|
<privateIpAddress>{{ nic.private_ip_address }}</privateIpAddress>
|
||||||
@ -526,7 +526,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns="http://ec2.amazona
|
|||||||
{% if nic.public_ip %}
|
{% if nic.public_ip %}
|
||||||
<association>
|
<association>
|
||||||
<publicIp>{{ nic.public_ip }}</publicIp>
|
<publicIp>{{ nic.public_ip }}</publicIp>
|
||||||
<ipOwnerId>123456789012</ipOwnerId>
|
<ipOwnerId>"""+ACCOUNT_ID+"""</ipOwnerId>
|
||||||
</association>
|
</association>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<privateIpAddressesSet>
|
<privateIpAddressesSet>
|
||||||
@ -536,7 +536,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns="http://ec2.amazona
|
|||||||
{% if nic.public_ip %}
|
{% if nic.public_ip %}
|
||||||
<association>
|
<association>
|
||||||
<publicIp>{{ nic.public_ip }}</publicIp>
|
<publicIp>{{ nic.public_ip }}</publicIp>
|
||||||
<ipOwnerId>123456789012</ipOwnerId>
|
<ipOwnerId>"""+ACCOUNT_ID+"""</ipOwnerId>
|
||||||
</association>
|
</association>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</item>
|
</item>
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from moto.core.responses import BaseResponse
|
from moto.core.responses import BaseResponse
|
||||||
from moto.ec2.utils import filters_from_querystring
|
from moto.ec2.utils import filters_from_querystring
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
def try_parse_int(value, default=None):
|
def try_parse_int(value, default=None):
|
||||||
@ -176,7 +177,7 @@ DESCRIBE_SECURITY_GROUPS_RESPONSE = """<DescribeSecurityGroupsResponse xmlns="ht
|
|||||||
<securityGroupInfo>
|
<securityGroupInfo>
|
||||||
{% for group in groups %}
|
{% for group in groups %}
|
||||||
<item>
|
<item>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<groupId>{{ group.id }}</groupId>
|
<groupId>{{ group.id }}</groupId>
|
||||||
<groupName>{{ group.name }}</groupName>
|
<groupName>{{ group.name }}</groupName>
|
||||||
<groupDescription>{{ group.description }}</groupDescription>
|
<groupDescription>{{ group.description }}</groupDescription>
|
||||||
@ -196,7 +197,7 @@ DESCRIBE_SECURITY_GROUPS_RESPONSE = """<DescribeSecurityGroupsResponse xmlns="ht
|
|||||||
<groups>
|
<groups>
|
||||||
{% for source_group in rule.source_groups %}
|
{% for source_group in rule.source_groups %}
|
||||||
<item>
|
<item>
|
||||||
<userId>123456789012</userId>
|
<userId>"""+ACCOUNT_ID+"""</userId>
|
||||||
<groupId>{{ source_group.id }}</groupId>
|
<groupId>{{ source_group.id }}</groupId>
|
||||||
<groupName>{{ source_group.name }}</groupName>
|
<groupName>{{ source_group.name }}</groupName>
|
||||||
</item>
|
</item>
|
||||||
@ -225,7 +226,7 @@ DESCRIBE_SECURITY_GROUPS_RESPONSE = """<DescribeSecurityGroupsResponse xmlns="ht
|
|||||||
<groups>
|
<groups>
|
||||||
{% for source_group in rule.source_groups %}
|
{% for source_group in rule.source_groups %}
|
||||||
<item>
|
<item>
|
||||||
<userId>123456789012</userId>
|
<userId>"""+ACCOUNT_ID+"""</userId>
|
||||||
<groupId>{{ source_group.id }}</groupId>
|
<groupId>{{ source_group.id }}</groupId>
|
||||||
<groupName>{{ source_group.name }}</groupName>
|
<groupName>{{ source_group.name }}</groupName>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from moto.core.responses import BaseResponse
|
from moto.core.responses import BaseResponse
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
class VPCPeeringConnections(BaseResponse):
|
class VPCPeeringConnections(BaseResponse):
|
||||||
def create_vpc_peering_connection(self):
|
def create_vpc_peering_connection(self):
|
||||||
@ -56,7 +56,7 @@ CREATE_VPC_PEERING_CONNECTION_RESPONSE = """
|
|||||||
</peeringOptions>
|
</peeringOptions>
|
||||||
</requesterVpcInfo>
|
</requesterVpcInfo>
|
||||||
<accepterVpcInfo>
|
<accepterVpcInfo>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<vpcId>{{ vpc_pcx.peer_vpc.id }}</vpcId>
|
<vpcId>{{ vpc_pcx.peer_vpc.id }}</vpcId>
|
||||||
</accepterVpcInfo>
|
</accepterVpcInfo>
|
||||||
<status>
|
<status>
|
||||||
@ -82,7 +82,7 @@ DESCRIBE_VPC_PEERING_CONNECTIONS_RESPONSE = """
|
|||||||
<cidrBlock>{{ vpc_pcx.vpc.cidr_block }}</cidrBlock>
|
<cidrBlock>{{ vpc_pcx.vpc.cidr_block }}</cidrBlock>
|
||||||
</requesterVpcInfo>
|
</requesterVpcInfo>
|
||||||
<accepterVpcInfo>
|
<accepterVpcInfo>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<vpcId>{{ vpc_pcx.peer_vpc.id }}</vpcId>
|
<vpcId>{{ vpc_pcx.peer_vpc.id }}</vpcId>
|
||||||
<cidrBlock>{{ vpc_pcx.peer_vpc.cidr_block }}</cidrBlock>
|
<cidrBlock>{{ vpc_pcx.peer_vpc.cidr_block }}</cidrBlock>
|
||||||
<peeringOptions>
|
<peeringOptions>
|
||||||
@ -120,7 +120,7 @@ ACCEPT_VPC_PEERING_CONNECTION_RESPONSE = """
|
|||||||
<cidrBlock>{{ vpc_pcx.vpc.cidr_block }}</cidrBlock>
|
<cidrBlock>{{ vpc_pcx.vpc.cidr_block }}</cidrBlock>
|
||||||
</requesterVpcInfo>
|
</requesterVpcInfo>
|
||||||
<accepterVpcInfo>
|
<accepterVpcInfo>
|
||||||
<ownerId>123456789012</ownerId>
|
<ownerId>"""+ACCOUNT_ID+"""</ownerId>
|
||||||
<vpcId>{{ vpc_pcx.peer_vpc.id }}</vpcId>
|
<vpcId>{{ vpc_pcx.peer_vpc.id }}</vpcId>
|
||||||
<cidrBlock>{{ vpc_pcx.peer_vpc.cidr_block }}</cidrBlock>
|
<cidrBlock>{{ vpc_pcx.peer_vpc.cidr_block }}</cidrBlock>
|
||||||
<peeringOptions>
|
<peeringOptions>
|
||||||
|
@ -45,7 +45,7 @@ from .utils import (
|
|||||||
random_policy_id,
|
random_policy_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
ACCOUNT_ID = 123456789012
|
ACCOUNT_ID = '123456789012' #make sure this is a str and not an int
|
||||||
|
|
||||||
|
|
||||||
class MFADevice(object):
|
class MFADevice(object):
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
from werkzeug.exceptions import BadRequest
|
from werkzeug.exceptions import BadRequest
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
class ResourceNotFoundError(BadRequest):
|
class ResourceNotFoundError(BadRequest):
|
||||||
@ -23,14 +24,14 @@ class ResourceInUseError(BadRequest):
|
|||||||
class StreamNotFoundError(ResourceNotFoundError):
|
class StreamNotFoundError(ResourceNotFoundError):
|
||||||
def __init__(self, stream_name):
|
def __init__(self, stream_name):
|
||||||
super(StreamNotFoundError, self).__init__(
|
super(StreamNotFoundError, self).__init__(
|
||||||
"Stream {0} under account 123456789012 not found.".format(stream_name)
|
"Stream {0} under account {1} not found.".format(stream_name, ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShardNotFoundError(ResourceNotFoundError):
|
class ShardNotFoundError(ResourceNotFoundError):
|
||||||
def __init__(self, shard_id):
|
def __init__(self, shard_id):
|
||||||
super(ShardNotFoundError, self).__init__(
|
super(ShardNotFoundError, self).__init__(
|
||||||
"Shard {0} under account 123456789012 not found.".format(shard_id)
|
"Shard {0} under account {1} not found.".format(shard_id, ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ from hashlib import md5
|
|||||||
from moto.compat import OrderedDict
|
from moto.compat import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
from moto.core.utils import unix_time
|
from moto.core.utils import unix_time
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
StreamNotFoundError,
|
StreamNotFoundError,
|
||||||
ShardNotFoundError,
|
ShardNotFoundError,
|
||||||
@ -133,7 +134,7 @@ class Stream(BaseModel):
|
|||||||
self.shard_count = shard_count
|
self.shard_count = shard_count
|
||||||
self.creation_datetime = datetime.datetime.now()
|
self.creation_datetime = datetime.datetime.now()
|
||||||
self.region = region
|
self.region = region
|
||||||
self.account_number = "123456789012"
|
self.account_number = ACCOUNT_ID
|
||||||
self.shards = {}
|
self.shards = {}
|
||||||
self.tags = {}
|
self.tags = {}
|
||||||
self.status = "ACTIVE"
|
self.status = "ACTIVE"
|
||||||
@ -259,8 +260,8 @@ class DeliveryStream(BaseModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def arn(self):
|
def arn(self):
|
||||||
return "arn:aws:firehose:us-east-1:123456789012:deliverystream/{0}".format(
|
return "arn:aws:firehose:us-east-1:{1}:deliverystream/{0}".format(
|
||||||
self.name
|
self.name, ACCOUNT_ID
|
||||||
)
|
)
|
||||||
|
|
||||||
def destinations_to_dict(self):
|
def destinations_to_dict(self):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
import uuid
|
import uuid
|
||||||
import datetime
|
import datetime
|
||||||
from random import choice
|
from random import choice
|
||||||
@ -367,7 +368,7 @@ class Stack(BaseModel):
|
|||||||
self.id = "{0}".format(uuid.uuid4())
|
self.id = "{0}".format(uuid.uuid4())
|
||||||
self.layers = []
|
self.layers = []
|
||||||
self.apps = []
|
self.apps = []
|
||||||
self.account_number = "123456789012"
|
self.account_number = ACCOUNT_ID
|
||||||
self.created_at = datetime.datetime.utcnow()
|
self.created_at = datetime.datetime.utcnow()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
MASTER_ACCOUNT_ID = "123456789012"
|
from moto.iam.models import ACCOUNT_ID as MASTER_ACCOUNT_ID
|
||||||
MASTER_ACCOUNT_EMAIL = "master@example.com"
|
MASTER_ACCOUNT_EMAIL = "master@example.com"
|
||||||
DEFAULT_POLICY_ID = "p-FullAWSAccess"
|
DEFAULT_POLICY_ID = "p-FullAWSAccess"
|
||||||
ORGANIZATION_ARN_FORMAT = "arn:aws:organizations::{0}:organization/{1}"
|
ORGANIZATION_ARN_FORMAT = "arn:aws:organizations::{0}:organization/{1}"
|
||||||
|
@ -8,7 +8,7 @@ from moto.core import BaseBackend, BaseModel
|
|||||||
from .resources import VOICE_DATA
|
from .resources import VOICE_DATA
|
||||||
from .utils import make_arn_for_lexicon
|
from .utils import make_arn_for_lexicon
|
||||||
|
|
||||||
DEFAULT_ACCOUNT_ID = 123456789012
|
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
class Lexicon(BaseModel):
|
class Lexicon(BaseModel):
|
||||||
|
@ -27,7 +27,7 @@ from .exceptions import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
ACCOUNT_ID = 123456789012
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
class TaggableResourceMixin(object):
|
class TaggableResourceMixin(object):
|
||||||
|
@ -6,6 +6,7 @@ import json
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from .exceptions import BadRequestException
|
from .exceptions import BadRequestException
|
||||||
|
|
||||||
|
|
||||||
@ -23,8 +24,8 @@ class FakeResourceGroup(BaseModel):
|
|||||||
if self._validate_tags(value=tags):
|
if self._validate_tags(value=tags):
|
||||||
self._tags = tags
|
self._tags = tags
|
||||||
self._raise_errors()
|
self._raise_errors()
|
||||||
self.arn = "arn:aws:resource-groups:us-west-1:123456789012:{name}".format(
|
self.arn = "arn:aws:resource-groups:us-west-1:{AccountId}:{name}".format(
|
||||||
name=name
|
name=name, AccountId=ACCOUNT_ID
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -13,6 +13,7 @@ import xmltodict
|
|||||||
from moto.packages.httpretty.core import HTTPrettyRequest
|
from moto.packages.httpretty.core import HTTPrettyRequest
|
||||||
from moto.core.responses import _TemplateEnvironmentMixin, ActionAuthenticatorMixin
|
from moto.core.responses import _TemplateEnvironmentMixin, ActionAuthenticatorMixin
|
||||||
from moto.core.utils import path_url
|
from moto.core.utils import path_url
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
from moto.s3bucket_path.utils import (
|
from moto.s3bucket_path.utils import (
|
||||||
bucket_name_from_url as bucketpath_bucket_name_from_url,
|
bucket_name_from_url as bucketpath_bucket_name_from_url,
|
||||||
@ -1898,7 +1899,7 @@ S3_ALL_MULTIPARTS = """<?xml version="1.0" encoding="UTF-8"?>
|
|||||||
<Key>{{ upload.key_name }}</Key>
|
<Key>{{ upload.key_name }}</Key>
|
||||||
<UploadId>{{ upload.id }}</UploadId>
|
<UploadId>{{ upload.id }}</UploadId>
|
||||||
<Initiator>
|
<Initiator>
|
||||||
<ID>arn:aws:iam::123456789012:user/user1-11111a31-17b5-4fb7-9df5-b111111f13de</ID>
|
<ID>arn:aws:iam::"""+ACCOUNT_ID+""":user/user1-11111a31-17b5-4fb7-9df5-b111111f13de</ID>
|
||||||
<DisplayName>user1-11111a31-17b5-4fb7-9df5-b111111f13de</DisplayName>
|
<DisplayName>user1-11111a31-17b5-4fb7-9df5-b111111f13de</DisplayName>
|
||||||
</Initiator>
|
</Initiator>
|
||||||
<Owner>
|
<Owner>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
"""
|
"""
|
||||||
SES Feedback messages
|
SES Feedback messages
|
||||||
Extracted from https://docs.aws.amazon.com/ses/latest/DeveloperGuide/notification-contents.html
|
Extracted from https://docs.aws.amazon.com/ses/latest/DeveloperGuide/notification-contents.html
|
||||||
@ -10,7 +11,7 @@ COMMON_MAIL = {
|
|||||||
"source": "sender@example.com",
|
"source": "sender@example.com",
|
||||||
"sourceArn": "arn:aws:ses:us-west-2:888888888888:identity/example.com",
|
"sourceArn": "arn:aws:ses:us-west-2:888888888888:identity/example.com",
|
||||||
"sourceIp": "127.0.3.0",
|
"sourceIp": "127.0.3.0",
|
||||||
"sendingAccountId": "123456789012",
|
"sendingAccountId": ACCOUNT_ID,
|
||||||
"destination": ["recipient@example.com"],
|
"destination": ["recipient@example.com"],
|
||||||
"headersTruncated": False,
|
"headersTruncated": False,
|
||||||
"headers": [
|
"headers": [
|
||||||
|
@ -12,6 +12,7 @@ from boto3 import Session
|
|||||||
|
|
||||||
from moto.compat import OrderedDict
|
from moto.compat import OrderedDict
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
iso_8601_datetime_with_milliseconds,
|
iso_8601_datetime_with_milliseconds,
|
||||||
camelcase_to_underscores,
|
camelcase_to_underscores,
|
||||||
@ -31,7 +32,7 @@ from .exceptions import (
|
|||||||
)
|
)
|
||||||
from .utils import make_arn_for_topic, make_arn_for_subscription, is_e164
|
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
|
DEFAULT_PAGE_SIZE = 100
|
||||||
MAXIMUM_MESSAGE_LENGTH = 262144 # 256 KiB
|
MAXIMUM_MESSAGE_LENGTH = 262144 # 256 KiB
|
||||||
|
|
||||||
@ -259,7 +260,7 @@ class Subscription(BaseModel):
|
|||||||
"SignatureVersion": "1",
|
"SignatureVersion": "1",
|
||||||
"Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
|
"Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
|
||||||
"SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
|
"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:
|
if message_attributes:
|
||||||
post_data["MessageAttributes"] = message_attributes
|
post_data["MessageAttributes"] = message_attributes
|
||||||
@ -275,8 +276,8 @@ class PlatformApplication(BaseModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def arn(self):
|
def arn(self):
|
||||||
return "arn:aws:sns:{region}:123456789012:app/{platform}/{name}".format(
|
return "arn:aws:sns:{region}:{AccountId}:app/{platform}/{name}".format(
|
||||||
region=self.region, platform=self.platform, name=self.name
|
region=self.region, platform=self.platform, name=self.name, AccountId=ACCOUNT_ID
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -305,8 +306,9 @@ class PlatformEndpoint(BaseModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def arn(self):
|
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,
|
region=self.region,
|
||||||
|
AccountId=ACCOUNT_ID,
|
||||||
platform=self.application.platform,
|
platform=self.application.platform,
|
||||||
name=self.application.name,
|
name=self.application.name,
|
||||||
id=self.id,
|
id=self.id,
|
||||||
|
@ -12,6 +12,7 @@ import boto.sqs
|
|||||||
|
|
||||||
from moto.core.exceptions import RESTError
|
from moto.core.exceptions import RESTError
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from moto.core.utils import (
|
from moto.core.utils import (
|
||||||
camelcase_to_underscores,
|
camelcase_to_underscores,
|
||||||
get_random_message_id,
|
get_random_message_id,
|
||||||
@ -32,7 +33,7 @@ from .exceptions import (
|
|||||||
InvalidAttributeName,
|
InvalidAttributeName,
|
||||||
)
|
)
|
||||||
|
|
||||||
DEFAULT_ACCOUNT_ID = 123456789012
|
from moto.iam.models import ACCOUNT_ID as DEFAULT_ACCOUNT_ID
|
||||||
DEFAULT_SENDER_ID = "AIDAIT2UOQQY3AUEKVGXU"
|
DEFAULT_SENDER_ID = "AIDAIT2UOQQY3AUEKVGXU"
|
||||||
|
|
||||||
MAXIMUM_MESSAGE_LENGTH = 262144 # 256 KiB
|
MAXIMUM_MESSAGE_LENGTH = 262144 # 256 KiB
|
||||||
@ -417,8 +418,8 @@ class Queue(BaseModel):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def url(self, request_url):
|
def url(self, request_url):
|
||||||
return "{0}://{1}/123456789012/{2}".format(
|
return "{0}://{1}/{2}/{3}".format(
|
||||||
request_url.scheme, request_url.netloc, self.name
|
request_url.scheme, request_url.netloc, ACCOUNT_ID, self.name
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -9,6 +9,7 @@ import uuid
|
|||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
|
||||||
from moto import mock_acm
|
from moto import mock_acm
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources")
|
RESOURCE_FOLDER = os.path.join(os.path.dirname(__file__), "resources")
|
||||||
@ -19,7 +20,7 @@ SERVER_CRT = _GET_RESOURCE("star_moto_com.pem")
|
|||||||
SERVER_COMMON_NAME = "*.moto.com"
|
SERVER_COMMON_NAME = "*.moto.com"
|
||||||
SERVER_CRT_BAD = _GET_RESOURCE("star_moto_com-bad.pem")
|
SERVER_CRT_BAD = _GET_RESOURCE("star_moto_com-bad.pem")
|
||||||
SERVER_KEY = _GET_RESOURCE("star_moto_com.key")
|
SERVER_KEY = _GET_RESOURCE("star_moto_com.key")
|
||||||
BAD_ARN = "arn:aws:acm:us-east-2:123456789012:certificate/_0000000-0000-0000-0000-000000000000"
|
BAD_ARN = "arn:aws:acm:us-east-2:{}:certificate/_0000000-0000-0000-0000-000000000000".format(ACCOUNT_ID)
|
||||||
|
|
||||||
|
|
||||||
def _import_cert(client):
|
def _import_cert(client):
|
||||||
|
@ -9,6 +9,7 @@ from botocore.exceptions import ClientError
|
|||||||
|
|
||||||
import responses
|
import responses
|
||||||
from moto import mock_apigateway, settings
|
from moto import mock_apigateway, settings
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
|
||||||
|
|
||||||
@ -881,7 +882,7 @@ def test_put_integration_validation():
|
|||||||
client.put_integration(
|
client.put_integration(
|
||||||
restApiId=api_id,
|
restApiId=api_id,
|
||||||
resourceId=root_id,
|
resourceId=root_id,
|
||||||
credentials="arn:aws:iam::123456789012:role/service-role/testfunction-role-oe783psq",
|
credentials="arn:aws:iam::{}:role/service-role/testfunction-role-oe783psq".format(ACCOUNT_ID),
|
||||||
httpMethod="GET",
|
httpMethod="GET",
|
||||||
type=type,
|
type=type,
|
||||||
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
||||||
@ -903,7 +904,7 @@ def test_put_integration_validation():
|
|||||||
client.put_integration(
|
client.put_integration(
|
||||||
restApiId=api_id,
|
restApiId=api_id,
|
||||||
resourceId=root_id,
|
resourceId=root_id,
|
||||||
credentials="arn:aws:iam::123456789012:role/service-role/testfunction-role-oe783psq",
|
credentials="arn:aws:iam::{}:role/service-role/testfunction-role-oe783psq".format(ACCOUNT_ID),
|
||||||
httpMethod="GET",
|
httpMethod="GET",
|
||||||
type=type,
|
type=type,
|
||||||
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
uri="arn:aws:apigateway:us-west-2:s3:path/b/k",
|
||||||
|
@ -8,6 +8,7 @@ import sure # noqa
|
|||||||
|
|
||||||
from moto import mock_autoscaling_deprecated
|
from moto import mock_autoscaling_deprecated
|
||||||
from moto import mock_autoscaling
|
from moto import mock_autoscaling
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from tests.helpers import requires_boto_gte
|
from tests.helpers import requires_boto_gte
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ def test_create_launch_configuration():
|
|||||||
security_groups=["default", "default2"],
|
security_groups=["default", "default2"],
|
||||||
user_data=b"This is some user_data",
|
user_data=b"This is some user_data",
|
||||||
instance_monitoring=True,
|
instance_monitoring=True,
|
||||||
instance_profile_name="arn:aws:iam::123456789012:instance-profile/testing",
|
instance_profile_name="arn:aws:iam::{}:instance-profile/testing".format(ACCOUNT_ID),
|
||||||
spot_price=0.1,
|
spot_price=0.1,
|
||||||
)
|
)
|
||||||
conn.create_launch_configuration(config)
|
conn.create_launch_configuration(config)
|
||||||
@ -36,7 +37,7 @@ def test_create_launch_configuration():
|
|||||||
launch_config.user_data.should.equal(b"This is some user_data")
|
launch_config.user_data.should.equal(b"This is some user_data")
|
||||||
launch_config.instance_monitoring.enabled.should.equal("true")
|
launch_config.instance_monitoring.enabled.should.equal("true")
|
||||||
launch_config.instance_profile_name.should.equal(
|
launch_config.instance_profile_name.should.equal(
|
||||||
"arn:aws:iam::123456789012:instance-profile/testing"
|
"arn:aws:iam::{}:instance-profile/testing".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
launch_config.spot_price.should.equal(0.1)
|
launch_config.spot_price.should.equal(0.1)
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ def test_create_launch_configuration_with_block_device_mappings():
|
|||||||
security_groups=["default", "default2"],
|
security_groups=["default", "default2"],
|
||||||
user_data=b"This is some user_data",
|
user_data=b"This is some user_data",
|
||||||
instance_monitoring=True,
|
instance_monitoring=True,
|
||||||
instance_profile_name="arn:aws:iam::123456789012:instance-profile/testing",
|
instance_profile_name="arn:aws:iam::{}:instance-profile/testing".format(ACCOUNT_ID),
|
||||||
spot_price=0.1,
|
spot_price=0.1,
|
||||||
block_device_mappings=[block_device_mapping],
|
block_device_mappings=[block_device_mapping],
|
||||||
)
|
)
|
||||||
@ -86,7 +87,7 @@ def test_create_launch_configuration_with_block_device_mappings():
|
|||||||
launch_config.user_data.should.equal(b"This is some user_data")
|
launch_config.user_data.should.equal(b"This is some user_data")
|
||||||
launch_config.instance_monitoring.enabled.should.equal("true")
|
launch_config.instance_monitoring.enabled.should.equal("true")
|
||||||
launch_config.instance_profile_name.should.equal(
|
launch_config.instance_profile_name.should.equal(
|
||||||
"arn:aws:iam::123456789012:instance-profile/testing"
|
"arn:aws:iam::{}:instance-profile/testing".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
launch_config.spot_price.should.equal(0.1)
|
launch_config.spot_price.should.equal(0.1)
|
||||||
len(launch_config.block_device_mappings).should.equal(3)
|
len(launch_config.block_device_mappings).should.equal(3)
|
||||||
|
@ -306,8 +306,8 @@ def test_create_function_from_aws_bucket():
|
|||||||
result.should.equal(
|
result.should.equal(
|
||||||
{
|
{
|
||||||
"FunctionName": "testFunction",
|
"FunctionName": "testFunction",
|
||||||
"FunctionArn": "arn:aws:lambda:{}:123456789012:function:testFunction".format(
|
"FunctionArn": "arn:aws:lambda:{}:{}:function:testFunction".format(
|
||||||
_lambda_region
|
_lambda_region, ACCOUNT_ID
|
||||||
),
|
),
|
||||||
"Runtime": "python2.7",
|
"Runtime": "python2.7",
|
||||||
"Role": result["Role"],
|
"Role": result["Role"],
|
||||||
@ -353,8 +353,8 @@ def test_create_function_from_zipfile():
|
|||||||
result.should.equal(
|
result.should.equal(
|
||||||
{
|
{
|
||||||
"FunctionName": "testFunction",
|
"FunctionName": "testFunction",
|
||||||
"FunctionArn": "arn:aws:lambda:{}:123456789012:function:testFunction".format(
|
"FunctionArn": "arn:aws:lambda:{}:{}:function:testFunction".format(
|
||||||
_lambda_region
|
_lambda_region, ACCOUNT_ID
|
||||||
),
|
),
|
||||||
"Runtime": "python2.7",
|
"Runtime": "python2.7",
|
||||||
"Role": result["Role"],
|
"Role": result["Role"],
|
||||||
@ -431,7 +431,7 @@ def test_get_function():
|
|||||||
result = conn.get_function(FunctionName="testFunction", Qualifier="$LATEST")
|
result = conn.get_function(FunctionName="testFunction", Qualifier="$LATEST")
|
||||||
result["Configuration"]["Version"].should.equal("$LATEST")
|
result["Configuration"]["Version"].should.equal("$LATEST")
|
||||||
result["Configuration"]["FunctionArn"].should.equal(
|
result["Configuration"]["FunctionArn"].should.equal(
|
||||||
"arn:aws:lambda:us-west-2:123456789012:function:testFunction:$LATEST"
|
"arn:aws:lambda:us-west-2:{}:function:testFunction:$LATEST".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test get function when can't find function name
|
# Test get function when can't find function name
|
||||||
@ -620,8 +620,8 @@ def test_list_create_list_get_delete_list():
|
|||||||
"CodeSha256": hashlib.sha256(zip_content).hexdigest(),
|
"CodeSha256": hashlib.sha256(zip_content).hexdigest(),
|
||||||
"CodeSize": len(zip_content),
|
"CodeSize": len(zip_content),
|
||||||
"Description": "test lambda function",
|
"Description": "test lambda function",
|
||||||
"FunctionArn": "arn:aws:lambda:{}:123456789012:function:testFunction".format(
|
"FunctionArn": "arn:aws:lambda:{}:{}:function:testFunction".format(
|
||||||
_lambda_region
|
_lambda_region, ACCOUNT_ID
|
||||||
),
|
),
|
||||||
"FunctionName": "testFunction",
|
"FunctionName": "testFunction",
|
||||||
"Handler": "lambda_function.lambda_handler",
|
"Handler": "lambda_function.lambda_handler",
|
||||||
@ -749,16 +749,16 @@ def test_tags_not_found():
|
|||||||
"""
|
"""
|
||||||
conn = boto3.client("lambda", "us-west-2")
|
conn = boto3.client("lambda", "us-west-2")
|
||||||
conn.list_tags.when.called_with(
|
conn.list_tags.when.called_with(
|
||||||
Resource="arn:aws:lambda:123456789012:function:not-found"
|
Resource="arn:aws:lambda:{}:function:not-found".format(ACCOUNT_ID)
|
||||||
).should.throw(botocore.client.ClientError)
|
).should.throw(botocore.client.ClientError)
|
||||||
|
|
||||||
conn.tag_resource.when.called_with(
|
conn.tag_resource.when.called_with(
|
||||||
Resource="arn:aws:lambda:123456789012:function:not-found",
|
Resource="arn:aws:lambda:{}:function:not-found".format(ACCOUNT_ID),
|
||||||
Tags=dict(spam="eggs"),
|
Tags=dict(spam="eggs"),
|
||||||
).should.throw(botocore.client.ClientError)
|
).should.throw(botocore.client.ClientError)
|
||||||
|
|
||||||
conn.untag_resource.when.called_with(
|
conn.untag_resource.when.called_with(
|
||||||
Resource="arn:aws:lambda:123456789012:function:not-found", TagKeys=["spam"]
|
Resource="arn:aws:lambda:{}:function:not-found".format(ACCOUNT_ID), TagKeys=["spam"]
|
||||||
).should.throw(botocore.client.ClientError)
|
).should.throw(botocore.client.ClientError)
|
||||||
|
|
||||||
|
|
||||||
@ -815,8 +815,8 @@ def test_get_function_created_with_zipfile():
|
|||||||
"CodeSha256": hashlib.sha256(zip_content).hexdigest(),
|
"CodeSha256": hashlib.sha256(zip_content).hexdigest(),
|
||||||
"CodeSize": len(zip_content),
|
"CodeSize": len(zip_content),
|
||||||
"Description": "test lambda function",
|
"Description": "test lambda function",
|
||||||
"FunctionArn": "arn:aws:lambda:{}:123456789012:function:testFunction".format(
|
"FunctionArn": "arn:aws:lambda:{}:{}:function:testFunction".format(
|
||||||
_lambda_region
|
_lambda_region, ACCOUNT_ID
|
||||||
),
|
),
|
||||||
"FunctionName": "testFunction",
|
"FunctionName": "testFunction",
|
||||||
"Handler": "lambda_function.handler",
|
"Handler": "lambda_function.handler",
|
||||||
@ -923,15 +923,15 @@ def test_list_versions_by_function():
|
|||||||
assert len(versions["Versions"]) == 3
|
assert len(versions["Versions"]) == 3
|
||||||
assert (
|
assert (
|
||||||
versions["Versions"][0]["FunctionArn"]
|
versions["Versions"][0]["FunctionArn"]
|
||||||
== "arn:aws:lambda:us-west-2:123456789012:function:testFunction:$LATEST"
|
== "arn:aws:lambda:us-west-2:{}:function:testFunction:$LATEST".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
versions["Versions"][1]["FunctionArn"]
|
versions["Versions"][1]["FunctionArn"]
|
||||||
== "arn:aws:lambda:us-west-2:123456789012:function:testFunction:1"
|
== "arn:aws:lambda:us-west-2:{}:function:testFunction:1".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
versions["Versions"][2]["FunctionArn"]
|
versions["Versions"][2]["FunctionArn"]
|
||||||
== "arn:aws:lambda:us-west-2:123456789012:function:testFunction:2"
|
== "arn:aws:lambda:us-west-2:{}:function:testFunction:2".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.create_function(
|
conn.create_function(
|
||||||
@ -949,7 +949,7 @@ def test_list_versions_by_function():
|
|||||||
assert len(versions["Versions"]) == 1
|
assert len(versions["Versions"]) == 1
|
||||||
assert (
|
assert (
|
||||||
versions["Versions"][0]["FunctionArn"]
|
versions["Versions"][0]["FunctionArn"]
|
||||||
== "arn:aws:lambda:us-west-2:123456789012:function:testFunction_2:$LATEST"
|
== "arn:aws:lambda:us-west-2:{}:function:testFunction_2:$LATEST".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1426,8 +1426,8 @@ def test_update_function_zip():
|
|||||||
"CodeSha256": hashlib.sha256(zip_content_two).hexdigest(),
|
"CodeSha256": hashlib.sha256(zip_content_two).hexdigest(),
|
||||||
"CodeSize": len(zip_content_two),
|
"CodeSize": len(zip_content_two),
|
||||||
"Description": "test lambda function",
|
"Description": "test lambda function",
|
||||||
"FunctionArn": "arn:aws:lambda:{}:123456789012:function:testFunctionZip:2".format(
|
"FunctionArn": "arn:aws:lambda:{}:{}:function:testFunctionZip:2".format(
|
||||||
_lambda_region
|
_lambda_region, ACCOUNT_ID
|
||||||
),
|
),
|
||||||
"FunctionName": "testFunctionZip",
|
"FunctionName": "testFunctionZip",
|
||||||
"Handler": "lambda_function.lambda_handler",
|
"Handler": "lambda_function.lambda_handler",
|
||||||
@ -1488,8 +1488,8 @@ def test_update_function_s3():
|
|||||||
"CodeSha256": hashlib.sha256(zip_content_two).hexdigest(),
|
"CodeSha256": hashlib.sha256(zip_content_two).hexdigest(),
|
||||||
"CodeSize": len(zip_content_two),
|
"CodeSize": len(zip_content_two),
|
||||||
"Description": "test lambda function",
|
"Description": "test lambda function",
|
||||||
"FunctionArn": "arn:aws:lambda:{}:123456789012:function:testFunctionS3:2".format(
|
"FunctionArn": "arn:aws:lambda:{}:{}:function:testFunctionS3:2".format(
|
||||||
_lambda_region
|
_lambda_region, ACCOUNT_ID
|
||||||
),
|
),
|
||||||
"FunctionName": "testFunctionS3",
|
"FunctionName": "testFunctionS3",
|
||||||
"Handler": "lambda_function.lambda_handler",
|
"Handler": "lambda_function.lambda_handler",
|
||||||
|
@ -14,6 +14,7 @@ import sure # noqa
|
|||||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||||
import tests.backport_assert_raises # noqa
|
import tests.backport_assert_raises # noqa
|
||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
from moto import (
|
from moto import (
|
||||||
mock_cloudformation_deprecated,
|
mock_cloudformation_deprecated,
|
||||||
@ -129,12 +130,12 @@ def test_create_stack_with_notification_arn():
|
|||||||
conn.create_stack(
|
conn.create_stack(
|
||||||
"test_stack_with_notifications",
|
"test_stack_with_notifications",
|
||||||
template_body=dummy_template_json,
|
template_body=dummy_template_json,
|
||||||
notification_arns="arn:aws:sns:us-east-1:123456789012:fake-queue",
|
notification_arns="arn:aws:sns:us-east-1:{}:fake-queue".format(ACCOUNT_ID),
|
||||||
)
|
)
|
||||||
|
|
||||||
stack = conn.describe_stacks()[0]
|
stack = conn.describe_stacks()[0]
|
||||||
[n.value for n in stack.notification_arns].should.contain(
|
[n.value for n in stack.notification_arns].should.contain(
|
||||||
"arn:aws:sns:us-east-1:123456789012:fake-queue"
|
"arn:aws:sns:us-east-1:{}:fake-queue".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import sure # noqa
|
|||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
|
||||||
from moto import mock_cloudformation, mock_s3, mock_sqs, mock_ec2
|
from moto import mock_cloudformation, mock_s3, mock_sqs, mock_ec2
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
dummy_template = {
|
dummy_template = {
|
||||||
"AWSTemplateFormatVersion": "2010-09-09",
|
"AWSTemplateFormatVersion": "2010-09-09",
|
||||||
@ -174,17 +175,17 @@ def test_boto3_describe_stack_instances():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
usw2_instance = cf_conn.describe_stack_instance(
|
usw2_instance = cf_conn.describe_stack_instance(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
StackInstanceAccount="123456789012",
|
StackInstanceAccount=ACCOUNT_ID,
|
||||||
StackInstanceRegion="us-west-2",
|
StackInstanceRegion="us-west-2",
|
||||||
)
|
)
|
||||||
use1_instance = cf_conn.describe_stack_instance(
|
use1_instance = cf_conn.describe_stack_instance(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
StackInstanceAccount="123456789012",
|
StackInstanceAccount=ACCOUNT_ID,
|
||||||
StackInstanceRegion="us-east-1",
|
StackInstanceRegion="us-east-1",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -192,13 +193,13 @@ def test_boto3_describe_stack_instances():
|
|||||||
"us-west-2"
|
"us-west-2"
|
||||||
)
|
)
|
||||||
usw2_instance["StackInstance"].should.have.key("Account").which.should.equal(
|
usw2_instance["StackInstance"].should.have.key("Account").which.should.equal(
|
||||||
"123456789012"
|
ACCOUNT_ID
|
||||||
)
|
)
|
||||||
use1_instance["StackInstance"].should.have.key("Region").which.should.equal(
|
use1_instance["StackInstance"].should.have.key("Region").which.should.equal(
|
||||||
"us-east-1"
|
"us-east-1"
|
||||||
)
|
)
|
||||||
use1_instance["StackInstance"].should.have.key("Account").which.should.equal(
|
use1_instance["StackInstance"].should.have.key("Account").which.should.equal(
|
||||||
"123456789012"
|
ACCOUNT_ID
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -236,7 +237,7 @@ def test_boto3_stop_stack_set_operation():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
operation_id = cf_conn.list_stack_set_operations(StackSetName="test_stack_set")[
|
operation_id = cf_conn.list_stack_set_operations(StackSetName="test_stack_set")[
|
||||||
@ -257,7 +258,7 @@ def test_boto3_describe_stack_set_operation():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
operation_id = cf_conn.list_stack_set_operations(StackSetName="test_stack_set")[
|
operation_id = cf_conn.list_stack_set_operations(StackSetName="test_stack_set")[
|
||||||
@ -282,7 +283,7 @@ def test_boto3_list_stack_set_operation_results():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
operation_id = cf_conn.list_stack_set_operations(StackSetName="test_stack_set")[
|
operation_id = cf_conn.list_stack_set_operations(StackSetName="test_stack_set")[
|
||||||
@ -298,7 +299,7 @@ def test_boto3_list_stack_set_operation_results():
|
|||||||
|
|
||||||
response["Summaries"].should.have.length_of(3)
|
response["Summaries"].should.have.length_of(3)
|
||||||
response["Summaries"][0].should.have.key("Account").which.should.equal(
|
response["Summaries"][0].should.have.key("Account").which.should.equal(
|
||||||
"123456789012"
|
ACCOUNT_ID
|
||||||
)
|
)
|
||||||
response["Summaries"][1].should.have.key("Status").which.should.equal("STOPPED")
|
response["Summaries"][1].should.have.key("Status").which.should.equal("STOPPED")
|
||||||
|
|
||||||
@ -321,28 +322,28 @@ def test_boto3_update_stack_instances():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
cf_conn.update_stack_instances(
|
cf_conn.update_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-west-1", "us-west-2"],
|
Regions=["us-west-1", "us-west-2"],
|
||||||
ParameterOverrides=param_overrides,
|
ParameterOverrides=param_overrides,
|
||||||
)
|
)
|
||||||
usw2_instance = cf_conn.describe_stack_instance(
|
usw2_instance = cf_conn.describe_stack_instance(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
StackInstanceAccount="123456789012",
|
StackInstanceAccount=ACCOUNT_ID,
|
||||||
StackInstanceRegion="us-west-2",
|
StackInstanceRegion="us-west-2",
|
||||||
)
|
)
|
||||||
usw1_instance = cf_conn.describe_stack_instance(
|
usw1_instance = cf_conn.describe_stack_instance(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
StackInstanceAccount="123456789012",
|
StackInstanceAccount=ACCOUNT_ID,
|
||||||
StackInstanceRegion="us-west-1",
|
StackInstanceRegion="us-west-1",
|
||||||
)
|
)
|
||||||
use1_instance = cf_conn.describe_stack_instance(
|
use1_instance = cf_conn.describe_stack_instance(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
StackInstanceAccount="123456789012",
|
StackInstanceAccount=ACCOUNT_ID,
|
||||||
StackInstanceRegion="us-east-1",
|
StackInstanceRegion="us-east-1",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -383,13 +384,13 @@ def test_boto3_delete_stack_instances():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
|
|
||||||
cf_conn.delete_stack_instances(
|
cf_conn.delete_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1"],
|
Regions=["us-east-1"],
|
||||||
RetainStacks=False,
|
RetainStacks=False,
|
||||||
)
|
)
|
||||||
@ -410,7 +411,7 @@ def test_boto3_create_stack_instances():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -419,7 +420,7 @@ def test_boto3_create_stack_instances():
|
|||||||
].should.have.length_of(2)
|
].should.have.length_of(2)
|
||||||
cf_conn.list_stack_instances(StackSetName="test_stack_set")["Summaries"][0][
|
cf_conn.list_stack_instances(StackSetName="test_stack_set")["Summaries"][0][
|
||||||
"Account"
|
"Account"
|
||||||
].should.equal("123456789012")
|
].should.equal(ACCOUNT_ID)
|
||||||
|
|
||||||
|
|
||||||
@mock_cloudformation
|
@mock_cloudformation
|
||||||
@ -440,13 +441,13 @@ def test_boto3_create_stack_instances_with_param_overrides():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-2"],
|
||||||
ParameterOverrides=param_overrides,
|
ParameterOverrides=param_overrides,
|
||||||
)
|
)
|
||||||
usw2_instance = cf_conn.describe_stack_instance(
|
usw2_instance = cf_conn.describe_stack_instance(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
StackInstanceAccount="123456789012",
|
StackInstanceAccount=ACCOUNT_ID,
|
||||||
StackInstanceRegion="us-west-2",
|
StackInstanceRegion="us-west-2",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -509,12 +510,12 @@ def test_boto3_list_stack_set_operations():
|
|||||||
)
|
)
|
||||||
cf_conn.create_stack_instances(
|
cf_conn.create_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
cf_conn.update_stack_instances(
|
cf_conn.update_stack_instances(
|
||||||
StackSetName="test_stack_set",
|
StackSetName="test_stack_set",
|
||||||
Accounts=["123456789012"],
|
Accounts=[ACCOUNT_ID],
|
||||||
Regions=["us-east-1", "us-west-2"],
|
Regions=["us-east-1", "us-west-2"],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -682,12 +683,12 @@ def test_create_stack_with_notification_arn():
|
|||||||
cf.create_stack(
|
cf.create_stack(
|
||||||
StackName="test_stack_with_notifications",
|
StackName="test_stack_with_notifications",
|
||||||
TemplateBody=dummy_template_json,
|
TemplateBody=dummy_template_json,
|
||||||
NotificationARNs=["arn:aws:sns:us-east-1:123456789012:fake-queue"],
|
NotificationARNs=["arn:aws:sns:us-east-1:{}:fake-queue".format(ACCOUNT_ID)],
|
||||||
)
|
)
|
||||||
|
|
||||||
stack = list(cf.stacks.all())[0]
|
stack = list(cf.stacks.all())[0]
|
||||||
stack.notification_arns.should.contain(
|
stack.notification_arns.should.contain(
|
||||||
"arn:aws:sns:us-east-1:123456789012:fake-queue"
|
"arn:aws:sns:us-east-1:{}:fake-queue".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -697,10 +698,10 @@ def test_create_stack_with_role_arn():
|
|||||||
cf.create_stack(
|
cf.create_stack(
|
||||||
StackName="test_stack_with_notifications",
|
StackName="test_stack_with_notifications",
|
||||||
TemplateBody=dummy_template_json,
|
TemplateBody=dummy_template_json,
|
||||||
RoleARN="arn:aws:iam::123456789012:role/moto",
|
RoleARN="arn:aws:iam::{}:role/moto".format(ACCOUNT_ID),
|
||||||
)
|
)
|
||||||
stack = list(cf.stacks.all())[0]
|
stack = list(cf.stacks.all())[0]
|
||||||
stack.role_arn.should.equal("arn:aws:iam::123456789012:role/moto")
|
stack.role_arn.should.equal("arn:aws:iam::{}:role/moto".format(ACCOUNT_ID))
|
||||||
|
|
||||||
|
|
||||||
@mock_cloudformation
|
@mock_cloudformation
|
||||||
@ -1019,7 +1020,7 @@ def test_describe_updated_stack():
|
|||||||
|
|
||||||
cf_conn.update_stack(
|
cf_conn.update_stack(
|
||||||
StackName="test_stack",
|
StackName="test_stack",
|
||||||
RoleARN="arn:aws:iam::123456789012:role/moto",
|
RoleARN="arn:aws:iam::{}:role/moto".format(ACCOUNT_ID),
|
||||||
TemplateBody=dummy_update_template_json,
|
TemplateBody=dummy_update_template_json,
|
||||||
Tags=[{"Key": "foo", "Value": "baz"}],
|
Tags=[{"Key": "foo", "Value": "baz"}],
|
||||||
)
|
)
|
||||||
@ -1030,7 +1031,7 @@ def test_describe_updated_stack():
|
|||||||
stack_by_id["StackId"].should.equal(stack["StackId"])
|
stack_by_id["StackId"].should.equal(stack["StackId"])
|
||||||
stack_by_id["StackName"].should.equal("test_stack")
|
stack_by_id["StackName"].should.equal("test_stack")
|
||||||
stack_by_id["StackStatus"].should.equal("UPDATE_COMPLETE")
|
stack_by_id["StackStatus"].should.equal("UPDATE_COMPLETE")
|
||||||
stack_by_id["RoleARN"].should.equal("arn:aws:iam::123456789012:role/moto")
|
stack_by_id["RoleARN"].should.equal("arn:aws:iam::{}:role/moto".format(ACCOUNT_ID))
|
||||||
stack_by_id["Tags"].should.equal([{"Key": "foo", "Value": "baz"}])
|
stack_by_id["Tags"].should.equal([{"Key": "foo", "Value": "baz"}])
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ from moto import (
|
|||||||
mock_sqs_deprecated,
|
mock_sqs_deprecated,
|
||||||
mock_elbv2,
|
mock_elbv2,
|
||||||
)
|
)
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from moto.dynamodb2.models import Table
|
from moto.dynamodb2.models import Table
|
||||||
|
|
||||||
from .fixtures import (
|
from .fixtures import (
|
||||||
@ -1912,7 +1913,7 @@ def test_stack_spot_fleet():
|
|||||||
"Type": "AWS::EC2::SpotFleet",
|
"Type": "AWS::EC2::SpotFleet",
|
||||||
"Properties": {
|
"Properties": {
|
||||||
"SpotFleetRequestConfigData": {
|
"SpotFleetRequestConfigData": {
|
||||||
"IamFleetRole": "arn:aws:iam::123456789012:role/fleet",
|
"IamFleetRole": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID),
|
||||||
"SpotPrice": "0.12",
|
"SpotPrice": "0.12",
|
||||||
"TargetCapacity": 6,
|
"TargetCapacity": 6,
|
||||||
"AllocationStrategy": "diversified",
|
"AllocationStrategy": "diversified",
|
||||||
@ -1933,7 +1934,7 @@ def test_stack_spot_fleet():
|
|||||||
"SecurityGroups": [{"GroupId": "sg-123"}],
|
"SecurityGroups": [{"GroupId": "sg-123"}],
|
||||||
"SubnetId": subnet_id,
|
"SubnetId": subnet_id,
|
||||||
"IamInstanceProfile": {
|
"IamInstanceProfile": {
|
||||||
"Arn": "arn:aws:iam::123456789012:role/fleet"
|
"Arn": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)
|
||||||
},
|
},
|
||||||
"WeightedCapacity": "4",
|
"WeightedCapacity": "4",
|
||||||
"SpotPrice": "10.00",
|
"SpotPrice": "10.00",
|
||||||
@ -1966,7 +1967,7 @@ def test_stack_spot_fleet():
|
|||||||
spot_fleet_config["SpotPrice"].should.equal("0.12")
|
spot_fleet_config["SpotPrice"].should.equal("0.12")
|
||||||
spot_fleet_config["TargetCapacity"].should.equal(6)
|
spot_fleet_config["TargetCapacity"].should.equal(6)
|
||||||
spot_fleet_config["IamFleetRole"].should.equal(
|
spot_fleet_config["IamFleetRole"].should.equal(
|
||||||
"arn:aws:iam::123456789012:role/fleet"
|
"arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
spot_fleet_config["AllocationStrategy"].should.equal("diversified")
|
spot_fleet_config["AllocationStrategy"].should.equal("diversified")
|
||||||
spot_fleet_config["FulfilledCapacity"].should.equal(6.0)
|
spot_fleet_config["FulfilledCapacity"].should.equal(6.0)
|
||||||
@ -1999,7 +2000,7 @@ def test_stack_spot_fleet_should_figure_out_default_price():
|
|||||||
"Type": "AWS::EC2::SpotFleet",
|
"Type": "AWS::EC2::SpotFleet",
|
||||||
"Properties": {
|
"Properties": {
|
||||||
"SpotFleetRequestConfigData": {
|
"SpotFleetRequestConfigData": {
|
||||||
"IamFleetRole": "arn:aws:iam::123456789012:role/fleet",
|
"IamFleetRole": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID),
|
||||||
"TargetCapacity": 6,
|
"TargetCapacity": 6,
|
||||||
"AllocationStrategy": "diversified",
|
"AllocationStrategy": "diversified",
|
||||||
"LaunchSpecifications": [
|
"LaunchSpecifications": [
|
||||||
@ -2018,7 +2019,7 @@ def test_stack_spot_fleet_should_figure_out_default_price():
|
|||||||
"SecurityGroups": [{"GroupId": "sg-123"}],
|
"SecurityGroups": [{"GroupId": "sg-123"}],
|
||||||
"SubnetId": subnet_id,
|
"SubnetId": subnet_id,
|
||||||
"IamInstanceProfile": {
|
"IamInstanceProfile": {
|
||||||
"Arn": "arn:aws:iam::123456789012:role/fleet"
|
"Arn": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)
|
||||||
},
|
},
|
||||||
"WeightedCapacity": "4",
|
"WeightedCapacity": "4",
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ from nose.tools import assert_raises
|
|||||||
|
|
||||||
from moto import mock_cognitoidentity
|
from moto import mock_cognitoidentity
|
||||||
from moto.cognitoidentity.utils import get_random_identity_id
|
from moto.cognitoidentity.utils import get_random_identity_id
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
@mock_cognitoidentity
|
@mock_cognitoidentity
|
||||||
def test_create_identity_pool():
|
def test_create_identity_pool():
|
||||||
@ -17,7 +17,7 @@ def test_create_identity_pool():
|
|||||||
AllowUnauthenticatedIdentities=False,
|
AllowUnauthenticatedIdentities=False,
|
||||||
SupportedLoginProviders={"graph.facebook.com": "123456789012345"},
|
SupportedLoginProviders={"graph.facebook.com": "123456789012345"},
|
||||||
DeveloperProviderName="devname",
|
DeveloperProviderName="devname",
|
||||||
OpenIdConnectProviderARNs=["arn:aws:rds:eu-west-2:123456789012:db:mysql-db"],
|
OpenIdConnectProviderARNs=["arn:aws:rds:eu-west-2:{}:db:mysql-db".format(ACCOUNT_ID)],
|
||||||
CognitoIdentityProviders=[
|
CognitoIdentityProviders=[
|
||||||
{
|
{
|
||||||
"ProviderName": "testprovider",
|
"ProviderName": "testprovider",
|
||||||
@ -25,7 +25,7 @@ def test_create_identity_pool():
|
|||||||
"ServerSideTokenCheck": True,
|
"ServerSideTokenCheck": True,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
SamlProviderARNs=["arn:aws:rds:eu-west-2:123456789012:db:mysql-db"],
|
SamlProviderARNs=["arn:aws:rds:eu-west-2:{}:db:mysql-db".format(ACCOUNT_ID)],
|
||||||
)
|
)
|
||||||
assert result["IdentityPoolId"] != ""
|
assert result["IdentityPoolId"] != ""
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ def test_describe_identity_pool():
|
|||||||
AllowUnauthenticatedIdentities=False,
|
AllowUnauthenticatedIdentities=False,
|
||||||
SupportedLoginProviders={"graph.facebook.com": "123456789012345"},
|
SupportedLoginProviders={"graph.facebook.com": "123456789012345"},
|
||||||
DeveloperProviderName="devname",
|
DeveloperProviderName="devname",
|
||||||
OpenIdConnectProviderARNs=["arn:aws:rds:eu-west-2:123456789012:db:mysql-db"],
|
OpenIdConnectProviderARNs=["arn:aws:rds:eu-west-2:{}:db:mysql-db".format(ACCOUNT_ID)],
|
||||||
CognitoIdentityProviders=[
|
CognitoIdentityProviders=[
|
||||||
{
|
{
|
||||||
"ProviderName": "testprovider",
|
"ProviderName": "testprovider",
|
||||||
@ -47,7 +47,7 @@ def test_describe_identity_pool():
|
|||||||
"ServerSideTokenCheck": True,
|
"ServerSideTokenCheck": True,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
SamlProviderARNs=["arn:aws:rds:eu-west-2:123456789012:db:mysql-db"],
|
SamlProviderARNs=["arn:aws:rds:eu-west-2:{}:db:mysql-db".format(ACCOUNT_ID)],
|
||||||
)
|
)
|
||||||
|
|
||||||
result = conn.describe_identity_pool(IdentityPoolId=res["IdentityPoolId"])
|
result = conn.describe_identity_pool(IdentityPoolId=res["IdentityPoolId"])
|
||||||
|
@ -14,6 +14,7 @@ from jose import jws
|
|||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
|
||||||
from moto import mock_cognitoidp
|
from moto import mock_cognitoidp
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_cognitoidp
|
@mock_cognitoidp
|
||||||
@ -132,7 +133,7 @@ def test_create_user_pool_domain_custom_domain_config():
|
|||||||
|
|
||||||
domain = str(uuid.uuid4())
|
domain = str(uuid.uuid4())
|
||||||
custom_domain_config = {
|
custom_domain_config = {
|
||||||
"CertificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/123456789012"
|
"CertificateArn": "arn:aws:acm:us-east-1:{}:certificate/123456789012".format(ACCOUNT_ID)
|
||||||
}
|
}
|
||||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||||
result = conn.create_user_pool_domain(
|
result = conn.create_user_pool_domain(
|
||||||
@ -177,7 +178,7 @@ def test_update_user_pool_domain():
|
|||||||
|
|
||||||
domain = str(uuid.uuid4())
|
domain = str(uuid.uuid4())
|
||||||
custom_domain_config = {
|
custom_domain_config = {
|
||||||
"CertificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/123456789012"
|
"CertificateArn": "arn:aws:acm:us-east-1:{}:certificate/123456789012".format(ACCOUNT_ID)
|
||||||
}
|
}
|
||||||
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
|
||||||
conn.create_user_pool_domain(UserPoolId=user_pool_id, Domain=domain)
|
conn.create_user_pool_domain(UserPoolId=user_pool_id, Domain=domain)
|
||||||
|
@ -7,7 +7,7 @@ from nose.tools import assert_raises
|
|||||||
|
|
||||||
from moto import mock_s3
|
from moto import mock_s3
|
||||||
from moto.config import mock_config
|
from moto.config import mock_config
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
@mock_config
|
@mock_config
|
||||||
def test_put_configuration_recorder():
|
def test_put_configuration_recorder():
|
||||||
@ -397,7 +397,7 @@ def test_put_configuration_aggregator():
|
|||||||
account_aggregation_source
|
account_aggregation_source
|
||||||
]
|
]
|
||||||
assert (
|
assert (
|
||||||
"arn:aws:config:us-west-2:123456789012:config-aggregator/config-aggregator-"
|
"arn:aws:config:us-west-2:{}:config-aggregator/config-aggregator-".format(ACCOUNT_ID)
|
||||||
in result["ConfigurationAggregator"]["ConfigurationAggregatorArn"]
|
in result["ConfigurationAggregator"]["ConfigurationAggregatorArn"]
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
@ -628,8 +628,7 @@ def test_put_aggregation_authorization():
|
|||||||
|
|
||||||
assert (
|
assert (
|
||||||
result["AggregationAuthorization"]["AggregationAuthorizationArn"]
|
result["AggregationAuthorization"]["AggregationAuthorizationArn"]
|
||||||
== "arn:aws:config:us-west-2:123456789012:"
|
== "arn:aws:config:us-west-2:{}:aggregation-authorization/012345678910/us-east-1".format(ACCOUNT_ID)
|
||||||
"aggregation-authorization/012345678910/us-east-1"
|
|
||||||
)
|
)
|
||||||
assert result["AggregationAuthorization"]["AuthorizedAccountId"] == "012345678910"
|
assert result["AggregationAuthorization"]["AuthorizedAccountId"] == "012345678910"
|
||||||
assert result["AggregationAuthorization"]["AuthorizedAwsRegion"] == "us-east-1"
|
assert result["AggregationAuthorization"]["AuthorizedAwsRegion"] == "us-east-1"
|
||||||
@ -643,8 +642,7 @@ def test_put_aggregation_authorization():
|
|||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result["AggregationAuthorization"]["AggregationAuthorizationArn"]
|
result["AggregationAuthorization"]["AggregationAuthorizationArn"]
|
||||||
== "arn:aws:config:us-west-2:123456789012:"
|
== "arn:aws:config:us-west-2:{}:aggregation-authorization/012345678910/us-east-1".format(ACCOUNT_ID)
|
||||||
"aggregation-authorization/012345678910/us-east-1"
|
|
||||||
)
|
)
|
||||||
assert result["AggregationAuthorization"]["AuthorizedAccountId"] == "012345678910"
|
assert result["AggregationAuthorization"]["AuthorizedAccountId"] == "012345678910"
|
||||||
assert result["AggregationAuthorization"]["AuthorizedAwsRegion"] == "us-east-1"
|
assert result["AggregationAuthorization"]["AuthorizedAwsRegion"] == "us-east-1"
|
||||||
@ -1416,7 +1414,7 @@ def test_list_aggregate_discovered_resource():
|
|||||||
assert len(result["ResourceIdentifiers"]) == 12
|
assert len(result["ResourceIdentifiers"]) == 12
|
||||||
for x in range(0, 10):
|
for x in range(0, 10):
|
||||||
assert result["ResourceIdentifiers"][x] == {
|
assert result["ResourceIdentifiers"][x] == {
|
||||||
"SourceAccountId": "123456789012",
|
"SourceAccountId": ACCOUNT_ID,
|
||||||
"ResourceType": "AWS::S3::Bucket",
|
"ResourceType": "AWS::S3::Bucket",
|
||||||
"ResourceId": "bucket{}".format(x),
|
"ResourceId": "bucket{}".format(x),
|
||||||
"ResourceName": "bucket{}".format(x),
|
"ResourceName": "bucket{}".format(x),
|
||||||
@ -1424,7 +1422,7 @@ def test_list_aggregate_discovered_resource():
|
|||||||
}
|
}
|
||||||
for x in range(11, 12):
|
for x in range(11, 12):
|
||||||
assert result["ResourceIdentifiers"][x] == {
|
assert result["ResourceIdentifiers"][x] == {
|
||||||
"SourceAccountId": "123456789012",
|
"SourceAccountId": ACCOUNT_ID,
|
||||||
"ResourceType": "AWS::S3::Bucket",
|
"ResourceType": "AWS::S3::Bucket",
|
||||||
"ResourceId": "eu-bucket{}".format(x),
|
"ResourceId": "eu-bucket{}".format(x),
|
||||||
"ResourceName": "eu-bucket{}".format(x),
|
"ResourceName": "eu-bucket{}".format(x),
|
||||||
|
@ -4,6 +4,7 @@ import boto3
|
|||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
from moto import mock_ec2
|
from moto import mock_ec2
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
def get_subnet_id(conn):
|
def get_subnet_id(conn):
|
||||||
@ -20,7 +21,7 @@ def spot_config(subnet_id, allocation_strategy="lowestPrice"):
|
|||||||
"ClientToken": "string",
|
"ClientToken": "string",
|
||||||
"SpotPrice": "0.12",
|
"SpotPrice": "0.12",
|
||||||
"TargetCapacity": 6,
|
"TargetCapacity": 6,
|
||||||
"IamFleetRole": "arn:aws:iam::123456789012:role/fleet",
|
"IamFleetRole": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID),
|
||||||
"LaunchSpecifications": [
|
"LaunchSpecifications": [
|
||||||
{
|
{
|
||||||
"ImageId": "ami-123",
|
"ImageId": "ami-123",
|
||||||
@ -45,7 +46,7 @@ def spot_config(subnet_id, allocation_strategy="lowestPrice"):
|
|||||||
],
|
],
|
||||||
"Monitoring": {"Enabled": True},
|
"Monitoring": {"Enabled": True},
|
||||||
"SubnetId": subnet_id,
|
"SubnetId": subnet_id,
|
||||||
"IamInstanceProfile": {"Arn": "arn:aws:iam::123456789012:role/fleet"},
|
"IamInstanceProfile": {"Arn": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)},
|
||||||
"EbsOptimized": False,
|
"EbsOptimized": False,
|
||||||
"WeightedCapacity": 2.0,
|
"WeightedCapacity": 2.0,
|
||||||
"SpotPrice": "0.13",
|
"SpotPrice": "0.13",
|
||||||
@ -58,7 +59,7 @@ def spot_config(subnet_id, allocation_strategy="lowestPrice"):
|
|||||||
"InstanceType": "t2.large",
|
"InstanceType": "t2.large",
|
||||||
"Monitoring": {"Enabled": True},
|
"Monitoring": {"Enabled": True},
|
||||||
"SubnetId": subnet_id,
|
"SubnetId": subnet_id,
|
||||||
"IamInstanceProfile": {"Arn": "arn:aws:iam::123456789012:role/fleet"},
|
"IamInstanceProfile": {"Arn": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)},
|
||||||
"EbsOptimized": False,
|
"EbsOptimized": False,
|
||||||
"WeightedCapacity": 4.0,
|
"WeightedCapacity": 4.0,
|
||||||
"SpotPrice": "10.00",
|
"SpotPrice": "10.00",
|
||||||
@ -90,7 +91,7 @@ def test_create_spot_fleet_with_lowest_price():
|
|||||||
spot_fleet_config["SpotPrice"].should.equal("0.12")
|
spot_fleet_config["SpotPrice"].should.equal("0.12")
|
||||||
spot_fleet_config["TargetCapacity"].should.equal(6)
|
spot_fleet_config["TargetCapacity"].should.equal(6)
|
||||||
spot_fleet_config["IamFleetRole"].should.equal(
|
spot_fleet_config["IamFleetRole"].should.equal(
|
||||||
"arn:aws:iam::123456789012:role/fleet"
|
"arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
spot_fleet_config["AllocationStrategy"].should.equal("lowestPrice")
|
spot_fleet_config["AllocationStrategy"].should.equal("lowestPrice")
|
||||||
spot_fleet_config["FulfilledCapacity"].should.equal(6.0)
|
spot_fleet_config["FulfilledCapacity"].should.equal(6.0)
|
||||||
@ -101,7 +102,7 @@ def test_create_spot_fleet_with_lowest_price():
|
|||||||
launch_spec["EbsOptimized"].should.equal(False)
|
launch_spec["EbsOptimized"].should.equal(False)
|
||||||
launch_spec["SecurityGroups"].should.equal([{"GroupId": "sg-123"}])
|
launch_spec["SecurityGroups"].should.equal([{"GroupId": "sg-123"}])
|
||||||
launch_spec["IamInstanceProfile"].should.equal(
|
launch_spec["IamInstanceProfile"].should.equal(
|
||||||
{"Arn": "arn:aws:iam::123456789012:role/fleet"}
|
{"Arn": "arn:aws:iam::{}:role/fleet".format(ACCOUNT_ID)}
|
||||||
)
|
)
|
||||||
launch_spec["ImageId"].should.equal("ami-123")
|
launch_spec["ImageId"].should.equal("ami-123")
|
||||||
launch_spec["InstanceType"].should.equal("t2.small")
|
launch_spec["InstanceType"].should.equal("t2.small")
|
||||||
|
@ -15,6 +15,7 @@ from nose.tools import assert_raises
|
|||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
from moto import mock_elb, mock_ec2, mock_elb_deprecated, mock_ec2_deprecated
|
from moto import mock_elb, mock_ec2, mock_elb_deprecated, mock_ec2_deprecated
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_elb_deprecated
|
@mock_elb_deprecated
|
||||||
@ -76,7 +77,7 @@ def test_create_load_balancer_with_certificate():
|
|||||||
|
|
||||||
zones = ["us-east-1a"]
|
zones = ["us-east-1a"]
|
||||||
ports = [
|
ports = [
|
||||||
(443, 8443, "https", "arn:aws:iam:123456789012:server-certificate/test-cert")
|
(443, 8443, "https", "arn:aws:iam:{}:server-certificate/test-cert".format(ACCOUNT_ID))
|
||||||
]
|
]
|
||||||
conn.create_load_balancer("my-lb", zones, ports)
|
conn.create_load_balancer("my-lb", zones, ports)
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ def test_create_load_balancer_with_certificate():
|
|||||||
listener.instance_port.should.equal(8443)
|
listener.instance_port.should.equal(8443)
|
||||||
listener.protocol.should.equal("HTTPS")
|
listener.protocol.should.equal("HTTPS")
|
||||||
listener.ssl_certificate_id.should.equal(
|
listener.ssl_certificate_id.should.equal(
|
||||||
"arn:aws:iam:123456789012:server-certificate/test-cert"
|
"arn:aws:iam:{}:server-certificate/test-cert".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import sure # noqa
|
|||||||
|
|
||||||
from moto import mock_elbv2, mock_ec2, mock_acm, mock_cloudformation
|
from moto import mock_elbv2, mock_ec2, mock_acm, mock_cloudformation
|
||||||
from moto.elbv2 import elbv2_backends
|
from moto.elbv2 import elbv2_backends
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@ -346,7 +347,7 @@ def test_create_target_group_and_listeners():
|
|||||||
Protocol="HTTPS",
|
Protocol="HTTPS",
|
||||||
Port=443,
|
Port=443,
|
||||||
Certificates=[
|
Certificates=[
|
||||||
{"CertificateArn": "arn:aws:iam:123456789012:server-certificate/test-cert"}
|
{"CertificateArn": "arn:aws:iam:{}:server-certificate/test-cert".format(ACCOUNT_ID)}
|
||||||
],
|
],
|
||||||
DefaultActions=[
|
DefaultActions=[
|
||||||
{"Type": "forward", "TargetGroupArn": target_group.get("TargetGroupArn")}
|
{"Type": "forward", "TargetGroupArn": target_group.get("TargetGroupArn")}
|
||||||
@ -356,7 +357,7 @@ def test_create_target_group_and_listeners():
|
|||||||
listener.get("Port").should.equal(443)
|
listener.get("Port").should.equal(443)
|
||||||
listener.get("Protocol").should.equal("HTTPS")
|
listener.get("Protocol").should.equal("HTTPS")
|
||||||
listener.get("Certificates").should.equal(
|
listener.get("Certificates").should.equal(
|
||||||
[{"CertificateArn": "arn:aws:iam:123456789012:server-certificate/test-cert"}]
|
[{"CertificateArn": "arn:aws:iam:{}:server-certificate/test-cert".format(ACCOUNT_ID)}]
|
||||||
)
|
)
|
||||||
listener.get("DefaultActions").should.equal(
|
listener.get("DefaultActions").should.equal(
|
||||||
[{"TargetGroupArn": target_group.get("TargetGroupArn"), "Type": "forward"}]
|
[{"TargetGroupArn": target_group.get("TargetGroupArn"), "Type": "forward"}]
|
||||||
@ -1902,7 +1903,7 @@ def test_cognito_action_listener_rule():
|
|||||||
action = {
|
action = {
|
||||||
"Type": "authenticate-cognito",
|
"Type": "authenticate-cognito",
|
||||||
"AuthenticateCognitoConfig": {
|
"AuthenticateCognitoConfig": {
|
||||||
"UserPoolArn": "arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_ABCD1234",
|
"UserPoolArn": "arn:aws:cognito-idp:us-east-1:{}:userpool/us-east-1_ABCD1234".format(ACCOUNT_ID),
|
||||||
"UserPoolClientId": "abcd1234abcd",
|
"UserPoolClientId": "abcd1234abcd",
|
||||||
"UserPoolDomain": "testpool",
|
"UserPoolDomain": "testpool",
|
||||||
},
|
},
|
||||||
@ -1977,7 +1978,7 @@ def test_cognito_action_listener_rule_cloudformation():
|
|||||||
{
|
{
|
||||||
"Type": "authenticate-cognito",
|
"Type": "authenticate-cognito",
|
||||||
"AuthenticateCognitoConfig": {
|
"AuthenticateCognitoConfig": {
|
||||||
"UserPoolArn": "arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_ABCD1234",
|
"UserPoolArn": "arn:aws:cognito-idp:us-east-1:{}:userpool/us-east-1_ABCD1234".format(ACCOUNT_ID),
|
||||||
"UserPoolClientId": "abcd1234abcd",
|
"UserPoolClientId": "abcd1234abcd",
|
||||||
"UserPoolDomain": "testpool",
|
"UserPoolDomain": "testpool",
|
||||||
},
|
},
|
||||||
@ -2006,7 +2007,7 @@ def test_cognito_action_listener_rule_cloudformation():
|
|||||||
{
|
{
|
||||||
"Type": "authenticate-cognito",
|
"Type": "authenticate-cognito",
|
||||||
"AuthenticateCognitoConfig": {
|
"AuthenticateCognitoConfig": {
|
||||||
"UserPoolArn": "arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_ABCD1234",
|
"UserPoolArn": "arn:aws:cognito-idp:us-east-1:{}:userpool/us-east-1_ABCD1234".format(ACCOUNT_ID),
|
||||||
"UserPoolClientId": "abcd1234abcd",
|
"UserPoolClientId": "abcd1234abcd",
|
||||||
"UserPoolDomain": "testpool",
|
"UserPoolDomain": "testpool",
|
||||||
},
|
},
|
||||||
|
@ -6,6 +6,7 @@ import sure # noqa
|
|||||||
from moto.events import mock_events
|
from moto.events import mock_events
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
RULES = [
|
RULES = [
|
||||||
{"Name": "test1", "ScheduleExpression": "rate(5 minutes)"},
|
{"Name": "test1", "ScheduleExpression": "rate(5 minutes)"},
|
||||||
@ -276,7 +277,7 @@ def test_create_event_bus():
|
|||||||
response = client.create_event_bus(Name="test-bus")
|
response = client.create_event_bus(Name="test-bus")
|
||||||
|
|
||||||
response["EventBusArn"].should.equal(
|
response["EventBusArn"].should.equal(
|
||||||
"arn:aws:events:us-east-1:123456789012:event-bus/test-bus"
|
"arn:aws:events:us-east-1:{}:event-bus/test-bus".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -314,7 +315,7 @@ def test_describe_event_bus():
|
|||||||
|
|
||||||
response["Name"].should.equal("default")
|
response["Name"].should.equal("default")
|
||||||
response["Arn"].should.equal(
|
response["Arn"].should.equal(
|
||||||
"arn:aws:events:us-east-1:123456789012:event-bus/default"
|
"arn:aws:events:us-east-1:{}:event-bus/default".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
response.should_not.have.key("Policy")
|
response.should_not.have.key("Policy")
|
||||||
|
|
||||||
@ -330,7 +331,7 @@ def test_describe_event_bus():
|
|||||||
|
|
||||||
response["Name"].should.equal("test-bus")
|
response["Name"].should.equal("test-bus")
|
||||||
response["Arn"].should.equal(
|
response["Arn"].should.equal(
|
||||||
"arn:aws:events:us-east-1:123456789012:event-bus/test-bus"
|
"arn:aws:events:us-east-1:{}:event-bus/test-bus".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
json.loads(response["Policy"]).should.equal(
|
json.loads(response["Policy"]).should.equal(
|
||||||
{
|
{
|
||||||
@ -341,7 +342,7 @@ def test_describe_event_bus():
|
|||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Principal": {"AWS": "arn:aws:iam::111111111111:root"},
|
"Principal": {"AWS": "arn:aws:iam::111111111111:root"},
|
||||||
"Action": "events:PutEvents",
|
"Action": "events:PutEvents",
|
||||||
"Resource": "arn:aws:events:us-east-1:123456789012:event-bus/test-bus",
|
"Resource": "arn:aws:events:us-east-1:{}:event-bus/test-bus".format(ACCOUNT_ID),
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -372,23 +373,23 @@ def test_list_event_buses():
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Name": "default",
|
"Name": "default",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/default",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/default".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "other-bus-1",
|
"Name": "other-bus-1",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/other-bus-1",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/other-bus-1".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "other-bus-2",
|
"Name": "other-bus-2",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/other-bus-2",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/other-bus-2".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "test-bus-1",
|
"Name": "test-bus-1",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/test-bus-1",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/test-bus-1".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "test-bus-2",
|
"Name": "test-bus-2",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/test-bus-2",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/test-bus-2".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -400,11 +401,11 @@ def test_list_event_buses():
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Name": "other-bus-1",
|
"Name": "other-bus-1",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/other-bus-1",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/other-bus-1".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "other-bus-2",
|
"Name": "other-bus-2",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/other-bus-2",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/other-bus-2".format(ACCOUNT_ID),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -426,7 +427,7 @@ def test_delete_event_bus():
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Name": "default",
|
"Name": "default",
|
||||||
"Arn": "arn:aws:events:us-east-1:123456789012:event-bus/default",
|
"Arn": "arn:aws:events:us-east-1:{}:event-bus/default".format(ACCOUNT_ID),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -13,6 +13,7 @@ from dateutil.tz import tzutc
|
|||||||
|
|
||||||
from moto import mock_iam, mock_iam_deprecated
|
from moto import mock_iam, mock_iam_deprecated
|
||||||
from moto.iam.models import aws_managed_policies
|
from moto.iam.models import aws_managed_policies
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
from nose.tools import assert_raises, assert_equals
|
from nose.tools import assert_raises, assert_equals
|
||||||
from nose.tools import raises
|
from nose.tools import raises
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ def test_get_all_server_certs():
|
|||||||
certs.should.have.length_of(1)
|
certs.should.have.length_of(1)
|
||||||
cert1 = certs[0]
|
cert1 = certs[0]
|
||||||
cert1.server_certificate_name.should.equal("certname")
|
cert1.server_certificate_name.should.equal("certname")
|
||||||
cert1.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
|
cert1.arn.should.equal("arn:aws:iam::{}:server-certificate/certname".format(ACCOUNT_ID))
|
||||||
|
|
||||||
|
|
||||||
@mock_iam_deprecated()
|
@mock_iam_deprecated()
|
||||||
@ -101,7 +102,7 @@ def test_get_server_cert():
|
|||||||
conn.upload_server_cert("certname", "certbody", "privatekey")
|
conn.upload_server_cert("certname", "certbody", "privatekey")
|
||||||
cert = conn.get_server_certificate("certname")
|
cert = conn.get_server_certificate("certname")
|
||||||
cert.server_certificate_name.should.equal("certname")
|
cert.server_certificate_name.should.equal("certname")
|
||||||
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
|
cert.arn.should.equal("arn:aws:iam::{}:server-certificate/certname".format(ACCOUNT_ID))
|
||||||
|
|
||||||
|
|
||||||
@mock_iam_deprecated()
|
@mock_iam_deprecated()
|
||||||
@ -111,7 +112,7 @@ def test_upload_server_cert():
|
|||||||
conn.upload_server_cert("certname", "certbody", "privatekey")
|
conn.upload_server_cert("certname", "certbody", "privatekey")
|
||||||
cert = conn.get_server_certificate("certname")
|
cert = conn.get_server_certificate("certname")
|
||||||
cert.server_certificate_name.should.equal("certname")
|
cert.server_certificate_name.should.equal("certname")
|
||||||
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
|
cert.arn.should.equal("arn:aws:iam::{}:server-certificate/certname".format(ACCOUNT_ID))
|
||||||
|
|
||||||
|
|
||||||
@mock_iam_deprecated()
|
@mock_iam_deprecated()
|
||||||
@ -405,7 +406,7 @@ def test_create_policy():
|
|||||||
PolicyName="TestCreatePolicy", PolicyDocument=MOCK_POLICY
|
PolicyName="TestCreatePolicy", PolicyDocument=MOCK_POLICY
|
||||||
)
|
)
|
||||||
response["Policy"]["Arn"].should.equal(
|
response["Policy"]["Arn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:policy/TestCreatePolicy"
|
"arn:aws:iam::{}:policy/TestCreatePolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -442,12 +443,12 @@ def test_create_policy_versions():
|
|||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
with assert_raises(ClientError):
|
with assert_raises(ClientError):
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestCreatePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestCreatePolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument='{"some":"policy"}',
|
PolicyDocument='{"some":"policy"}',
|
||||||
)
|
)
|
||||||
conn.create_policy(PolicyName="TestCreatePolicyVersion", PolicyDocument=MOCK_POLICY)
|
conn.create_policy(PolicyName="TestCreatePolicyVersion", PolicyDocument=MOCK_POLICY)
|
||||||
version = conn.create_policy_version(
|
version = conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestCreatePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestCreatePolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY,
|
PolicyDocument=MOCK_POLICY,
|
||||||
SetAsDefault=True,
|
SetAsDefault=True,
|
||||||
)
|
)
|
||||||
@ -455,11 +456,11 @@ def test_create_policy_versions():
|
|||||||
version.get("PolicyVersion").get("VersionId").should.equal("v2")
|
version.get("PolicyVersion").get("VersionId").should.equal("v2")
|
||||||
version.get("PolicyVersion").get("IsDefaultVersion").should.be.ok
|
version.get("PolicyVersion").get("IsDefaultVersion").should.be.ok
|
||||||
conn.delete_policy_version(
|
conn.delete_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestCreatePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestCreatePolicyVersion".format(ACCOUNT_ID),
|
||||||
VersionId="v1",
|
VersionId="v1",
|
||||||
)
|
)
|
||||||
version = conn.create_policy_version(
|
version = conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestCreatePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestCreatePolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY,
|
PolicyDocument=MOCK_POLICY,
|
||||||
)
|
)
|
||||||
version.get("PolicyVersion").get("VersionId").should.equal("v3")
|
version.get("PolicyVersion").get("VersionId").should.equal("v3")
|
||||||
@ -474,12 +475,12 @@ def test_create_many_policy_versions():
|
|||||||
)
|
)
|
||||||
for _ in range(0, 4):
|
for _ in range(0, 4):
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestCreateManyPolicyVersions",
|
PolicyArn="arn:aws:iam::{}:policy/TestCreateManyPolicyVersions".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY,
|
PolicyDocument=MOCK_POLICY,
|
||||||
)
|
)
|
||||||
with assert_raises(ClientError):
|
with assert_raises(ClientError):
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestCreateManyPolicyVersions",
|
PolicyArn="arn:aws:iam::{}:policy/TestCreateManyPolicyVersions".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY,
|
PolicyDocument=MOCK_POLICY,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -491,17 +492,17 @@ def test_set_default_policy_version():
|
|||||||
PolicyName="TestSetDefaultPolicyVersion", PolicyDocument=MOCK_POLICY
|
PolicyName="TestSetDefaultPolicyVersion", PolicyDocument=MOCK_POLICY
|
||||||
)
|
)
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestSetDefaultPolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestSetDefaultPolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY_2,
|
PolicyDocument=MOCK_POLICY_2,
|
||||||
SetAsDefault=True,
|
SetAsDefault=True,
|
||||||
)
|
)
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestSetDefaultPolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestSetDefaultPolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY_3,
|
PolicyDocument=MOCK_POLICY_3,
|
||||||
SetAsDefault=True,
|
SetAsDefault=True,
|
||||||
)
|
)
|
||||||
versions = conn.list_policy_versions(
|
versions = conn.list_policy_versions(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestSetDefaultPolicyVersion"
|
PolicyArn="arn:aws:iam::{}:policy/TestSetDefaultPolicyVersion".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
versions.get("Versions")[0].get("Document").should.equal(json.loads(MOCK_POLICY))
|
versions.get("Versions")[0].get("Document").should.equal(json.loads(MOCK_POLICY))
|
||||||
versions.get("Versions")[0].get("IsDefaultVersion").shouldnt.be.ok
|
versions.get("Versions")[0].get("IsDefaultVersion").shouldnt.be.ok
|
||||||
@ -517,9 +518,9 @@ def test_get_policy():
|
|||||||
response = conn.create_policy(
|
response = conn.create_policy(
|
||||||
PolicyName="TestGetPolicy", PolicyDocument=MOCK_POLICY
|
PolicyName="TestGetPolicy", PolicyDocument=MOCK_POLICY
|
||||||
)
|
)
|
||||||
policy = conn.get_policy(PolicyArn="arn:aws:iam::123456789012:policy/TestGetPolicy")
|
policy = conn.get_policy(PolicyArn="arn:aws:iam::{}:policy/TestGetPolicy".format(ACCOUNT_ID))
|
||||||
policy["Policy"]["Arn"].should.equal(
|
policy["Policy"]["Arn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:policy/TestGetPolicy"
|
"arn:aws:iam::{}:policy/TestGetPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -542,16 +543,16 @@ def test_get_policy_version():
|
|||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
conn.create_policy(PolicyName="TestGetPolicyVersion", PolicyDocument=MOCK_POLICY)
|
conn.create_policy(PolicyName="TestGetPolicyVersion", PolicyDocument=MOCK_POLICY)
|
||||||
version = conn.create_policy_version(
|
version = conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestGetPolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestGetPolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY,
|
PolicyDocument=MOCK_POLICY,
|
||||||
)
|
)
|
||||||
with assert_raises(ClientError):
|
with assert_raises(ClientError):
|
||||||
conn.get_policy_version(
|
conn.get_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestGetPolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestGetPolicyVersion".format(ACCOUNT_ID),
|
||||||
VersionId="v2-does-not-exist",
|
VersionId="v2-does-not-exist",
|
||||||
)
|
)
|
||||||
retrieved = conn.get_policy_version(
|
retrieved = conn.get_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestGetPolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestGetPolicyVersion".format(ACCOUNT_ID),
|
||||||
VersionId=version.get("PolicyVersion").get("VersionId"),
|
VersionId=version.get("PolicyVersion").get("VersionId"),
|
||||||
)
|
)
|
||||||
retrieved.get("PolicyVersion").get("Document").should.equal(json.loads(MOCK_POLICY))
|
retrieved.get("PolicyVersion").get("Document").should.equal(json.loads(MOCK_POLICY))
|
||||||
@ -601,25 +602,25 @@ def test_list_policy_versions():
|
|||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
with assert_raises(ClientError):
|
with assert_raises(ClientError):
|
||||||
versions = conn.list_policy_versions(
|
versions = conn.list_policy_versions(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestListPolicyVersions"
|
PolicyArn="arn:aws:iam::{}:policy/TestListPolicyVersions".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
conn.create_policy(PolicyName="TestListPolicyVersions", PolicyDocument=MOCK_POLICY)
|
conn.create_policy(PolicyName="TestListPolicyVersions", PolicyDocument=MOCK_POLICY)
|
||||||
versions = conn.list_policy_versions(
|
versions = conn.list_policy_versions(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestListPolicyVersions"
|
PolicyArn="arn:aws:iam::{}:policy/TestListPolicyVersions".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
versions.get("Versions")[0].get("VersionId").should.equal("v1")
|
versions.get("Versions")[0].get("VersionId").should.equal("v1")
|
||||||
versions.get("Versions")[0].get("IsDefaultVersion").should.be.ok
|
versions.get("Versions")[0].get("IsDefaultVersion").should.be.ok
|
||||||
|
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestListPolicyVersions",
|
PolicyArn="arn:aws:iam::{}:policy/TestListPolicyVersions".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY_2,
|
PolicyDocument=MOCK_POLICY_2,
|
||||||
)
|
)
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestListPolicyVersions",
|
PolicyArn="arn:aws:iam::{}:policy/TestListPolicyVersions".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY_3,
|
PolicyDocument=MOCK_POLICY_3,
|
||||||
)
|
)
|
||||||
versions = conn.list_policy_versions(
|
versions = conn.list_policy_versions(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestListPolicyVersions"
|
PolicyArn="arn:aws:iam::{}:policy/TestListPolicyVersions".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
versions.get("Versions")[1].get("Document").should.equal(json.loads(MOCK_POLICY_2))
|
versions.get("Versions")[1].get("Document").should.equal(json.loads(MOCK_POLICY_2))
|
||||||
versions.get("Versions")[1].get("IsDefaultVersion").shouldnt.be.ok
|
versions.get("Versions")[1].get("IsDefaultVersion").shouldnt.be.ok
|
||||||
@ -632,20 +633,20 @@ def test_delete_policy_version():
|
|||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
conn.create_policy(PolicyName="TestDeletePolicyVersion", PolicyDocument=MOCK_POLICY)
|
conn.create_policy(PolicyName="TestDeletePolicyVersion", PolicyDocument=MOCK_POLICY)
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestDeletePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestDeletePolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY,
|
PolicyDocument=MOCK_POLICY,
|
||||||
)
|
)
|
||||||
with assert_raises(ClientError):
|
with assert_raises(ClientError):
|
||||||
conn.delete_policy_version(
|
conn.delete_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestDeletePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestDeletePolicyVersion".format(ACCOUNT_ID),
|
||||||
VersionId="v2-nope-this-does-not-exist",
|
VersionId="v2-nope-this-does-not-exist",
|
||||||
)
|
)
|
||||||
conn.delete_policy_version(
|
conn.delete_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestDeletePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestDeletePolicyVersion".format(ACCOUNT_ID),
|
||||||
VersionId="v2",
|
VersionId="v2",
|
||||||
)
|
)
|
||||||
versions = conn.list_policy_versions(
|
versions = conn.list_policy_versions(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestDeletePolicyVersion"
|
PolicyArn="arn:aws:iam::{}:policy/TestDeletePolicyVersion".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
len(versions.get("Versions")).should.equal(1)
|
len(versions.get("Versions")).should.equal(1)
|
||||||
|
|
||||||
@ -655,12 +656,12 @@ def test_delete_default_policy_version():
|
|||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
conn.create_policy(PolicyName="TestDeletePolicyVersion", PolicyDocument=MOCK_POLICY)
|
conn.create_policy(PolicyName="TestDeletePolicyVersion", PolicyDocument=MOCK_POLICY)
|
||||||
conn.create_policy_version(
|
conn.create_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestDeletePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestDeletePolicyVersion".format(ACCOUNT_ID),
|
||||||
PolicyDocument=MOCK_POLICY_2,
|
PolicyDocument=MOCK_POLICY_2,
|
||||||
)
|
)
|
||||||
with assert_raises(ClientError):
|
with assert_raises(ClientError):
|
||||||
conn.delete_policy_version(
|
conn.delete_policy_version(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/TestDeletePolicyVersion",
|
PolicyArn="arn:aws:iam::{}:policy/TestDeletePolicyVersion".format(ACCOUNT_ID),
|
||||||
VersionId="v1",
|
VersionId="v1",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -713,7 +714,7 @@ def test_list_users():
|
|||||||
user = response["Users"][0]
|
user = response["Users"][0]
|
||||||
user["UserName"].should.equal("my-user")
|
user["UserName"].should.equal("my-user")
|
||||||
user["Path"].should.equal("/")
|
user["Path"].should.equal("/")
|
||||||
user["Arn"].should.equal("arn:aws:iam::123456789012:user/my-user")
|
user["Arn"].should.equal("arn:aws:iam::{}:user/my-user".format(ACCOUNT_ID))
|
||||||
|
|
||||||
|
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
@ -839,7 +840,7 @@ def test_create_virtual_mfa_device():
|
|||||||
response = client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
|
response = client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
|
||||||
device = response["VirtualMFADevice"]
|
device = response["VirtualMFADevice"]
|
||||||
|
|
||||||
device["SerialNumber"].should.equal("arn:aws:iam::123456789012:mfa/test-device")
|
device["SerialNumber"].should.equal("arn:aws:iam::{}:mfa/test-device".format(ACCOUNT_ID))
|
||||||
device["Base32StringSeed"].decode("ascii").should.match("[A-Z234567]")
|
device["Base32StringSeed"].decode("ascii").should.match("[A-Z234567]")
|
||||||
device["QRCodePNG"].should_not.be.empty
|
device["QRCodePNG"].should_not.be.empty
|
||||||
|
|
||||||
@ -848,7 +849,7 @@ def test_create_virtual_mfa_device():
|
|||||||
)
|
)
|
||||||
device = response["VirtualMFADevice"]
|
device = response["VirtualMFADevice"]
|
||||||
|
|
||||||
device["SerialNumber"].should.equal("arn:aws:iam::123456789012:mfa/test-device-2")
|
device["SerialNumber"].should.equal("arn:aws:iam::{}:mfa/test-device-2".format(ACCOUNT_ID))
|
||||||
device["Base32StringSeed"].decode("ascii").should.match("[A-Z234567]")
|
device["Base32StringSeed"].decode("ascii").should.match("[A-Z234567]")
|
||||||
device["QRCodePNG"].should_not.be.empty
|
device["QRCodePNG"].should_not.be.empty
|
||||||
|
|
||||||
@ -858,7 +859,7 @@ def test_create_virtual_mfa_device():
|
|||||||
device = response["VirtualMFADevice"]
|
device = response["VirtualMFADevice"]
|
||||||
|
|
||||||
device["SerialNumber"].should.equal(
|
device["SerialNumber"].should.equal(
|
||||||
"arn:aws:iam::123456789012:mfa/test/test-device"
|
"arn:aws:iam::{}:mfa/test/test-device".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
device["Base32StringSeed"].decode("ascii").should.match("[A-Z234567]")
|
device["Base32StringSeed"].decode("ascii").should.match("[A-Z234567]")
|
||||||
device["QRCodePNG"].should_not.be.empty
|
device["QRCodePNG"].should_not.be.empty
|
||||||
@ -920,7 +921,7 @@ def test_delete_virtual_mfa_device():
|
|||||||
def test_delete_virtual_mfa_device_errors():
|
def test_delete_virtual_mfa_device_errors():
|
||||||
client = boto3.client("iam", region_name="us-east-1")
|
client = boto3.client("iam", region_name="us-east-1")
|
||||||
|
|
||||||
serial_number = "arn:aws:iam::123456789012:mfa/not-existing"
|
serial_number = "arn:aws:iam::{}:mfa/not-existing".format(ACCOUNT_ID)
|
||||||
client.delete_virtual_mfa_device.when.called_with(
|
client.delete_virtual_mfa_device.when.called_with(
|
||||||
SerialNumber=serial_number
|
SerialNumber=serial_number
|
||||||
).should.throw(
|
).should.throw(
|
||||||
@ -1009,7 +1010,7 @@ def test_enable_virtual_mfa_device():
|
|||||||
device["User"]["Path"].should.equal("/")
|
device["User"]["Path"].should.equal("/")
|
||||||
device["User"]["UserName"].should.equal("test-user")
|
device["User"]["UserName"].should.equal("test-user")
|
||||||
device["User"]["UserId"].should_not.be.empty
|
device["User"]["UserId"].should_not.be.empty
|
||||||
device["User"]["Arn"].should.equal("arn:aws:iam::123456789012:user/test-user")
|
device["User"]["Arn"].should.equal("arn:aws:iam::{}:user/test-user".format(ACCOUNT_ID))
|
||||||
device["User"]["CreateDate"].should.be.a(datetime)
|
device["User"]["CreateDate"].should.be.a(datetime)
|
||||||
device["EnableDate"].should.be.a(datetime)
|
device["EnableDate"].should.be.a(datetime)
|
||||||
response["IsTruncated"].should_not.be.ok
|
response["IsTruncated"].should_not.be.ok
|
||||||
@ -1444,7 +1445,7 @@ def test_get_account_authorization_details():
|
|||||||
)
|
)
|
||||||
|
|
||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
boundary = "arn:aws:iam::123456789012:policy/boundary"
|
boundary = "arn:aws:iam::{}:policy/boundary".format(ACCOUNT_ID)
|
||||||
conn.create_role(
|
conn.create_role(
|
||||||
RoleName="my-role",
|
RoleName="my-role",
|
||||||
AssumeRolePolicyDocument="some policy",
|
AssumeRolePolicyDocument="some policy",
|
||||||
@ -1470,10 +1471,10 @@ def test_get_account_authorization_details():
|
|||||||
)
|
)
|
||||||
|
|
||||||
conn.attach_user_policy(
|
conn.attach_user_policy(
|
||||||
UserName="testUser", PolicyArn="arn:aws:iam::123456789012:policy/testPolicy"
|
UserName="testUser", PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
conn.attach_group_policy(
|
conn.attach_group_policy(
|
||||||
GroupName="testGroup", PolicyArn="arn:aws:iam::123456789012:policy/testPolicy"
|
GroupName="testGroup", PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.add_user_to_group(UserName="testUser", GroupName="testGroup")
|
conn.add_user_to_group(UserName="testUser", GroupName="testGroup")
|
||||||
@ -1492,7 +1493,7 @@ def test_get_account_authorization_details():
|
|||||||
RoleName="my-role", PolicyName="test-policy", PolicyDocument=test_policy
|
RoleName="my-role", PolicyName="test-policy", PolicyDocument=test_policy
|
||||||
)
|
)
|
||||||
conn.attach_role_policy(
|
conn.attach_role_policy(
|
||||||
RoleName="my-role", PolicyArn="arn:aws:iam::123456789012:policy/testPolicy"
|
RoleName="my-role", PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = conn.get_account_authorization_details(Filter=["Role"])
|
result = conn.get_account_authorization_details(Filter=["Role"])
|
||||||
@ -1509,7 +1510,7 @@ def test_get_account_authorization_details():
|
|||||||
"PermissionsBoundary"
|
"PermissionsBoundary"
|
||||||
] == {
|
] == {
|
||||||
"PermissionsBoundaryType": "PermissionsBoundaryPolicy",
|
"PermissionsBoundaryType": "PermissionsBoundaryPolicy",
|
||||||
"PermissionsBoundaryArn": "arn:aws:iam::123456789012:policy/boundary",
|
"PermissionsBoundaryArn": "arn:aws:iam::{}:policy/boundary".format(ACCOUNT_ID),
|
||||||
}
|
}
|
||||||
assert len(result["RoleDetailList"][0]["Tags"]) == 2
|
assert len(result["RoleDetailList"][0]["Tags"]) == 2
|
||||||
assert len(result["RoleDetailList"][0]["RolePolicyList"]) == 1
|
assert len(result["RoleDetailList"][0]["RolePolicyList"]) == 1
|
||||||
@ -1520,7 +1521,7 @@ def test_get_account_authorization_details():
|
|||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result["RoleDetailList"][0]["AttachedManagedPolicies"][0]["PolicyArn"]
|
result["RoleDetailList"][0]["AttachedManagedPolicies"][0]["PolicyArn"]
|
||||||
== "arn:aws:iam::123456789012:policy/testPolicy"
|
== "arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = conn.get_account_authorization_details(Filter=["User"])
|
result = conn.get_account_authorization_details(Filter=["User"])
|
||||||
@ -1536,7 +1537,7 @@ def test_get_account_authorization_details():
|
|||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result["UserDetailList"][0]["AttachedManagedPolicies"][0]["PolicyArn"]
|
result["UserDetailList"][0]["AttachedManagedPolicies"][0]["PolicyArn"]
|
||||||
== "arn:aws:iam::123456789012:policy/testPolicy"
|
== "arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = conn.get_account_authorization_details(Filter=["Group"])
|
result = conn.get_account_authorization_details(Filter=["Group"])
|
||||||
@ -1552,7 +1553,7 @@ def test_get_account_authorization_details():
|
|||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
result["GroupDetailList"][0]["AttachedManagedPolicies"][0]["PolicyArn"]
|
result["GroupDetailList"][0]["AttachedManagedPolicies"][0]["PolicyArn"]
|
||||||
== "arn:aws:iam::123456789012:policy/testPolicy"
|
== "arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = conn.get_account_authorization_details(Filter=["LocalManagedPolicy"])
|
result = conn.get_account_authorization_details(Filter=["LocalManagedPolicy"])
|
||||||
@ -1650,7 +1651,7 @@ def test_create_saml_provider():
|
|||||||
Name="TestSAMLProvider", SAMLMetadataDocument="a" * 1024
|
Name="TestSAMLProvider", SAMLMetadataDocument="a" * 1024
|
||||||
)
|
)
|
||||||
response["SAMLProviderArn"].should.equal(
|
response["SAMLProviderArn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:saml-provider/TestSAMLProvider"
|
"arn:aws:iam::{}:saml-provider/TestSAMLProvider".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1672,7 +1673,7 @@ def test_list_saml_providers():
|
|||||||
conn.create_saml_provider(Name="TestSAMLProvider", SAMLMetadataDocument="a" * 1024)
|
conn.create_saml_provider(Name="TestSAMLProvider", SAMLMetadataDocument="a" * 1024)
|
||||||
response = conn.list_saml_providers()
|
response = conn.list_saml_providers()
|
||||||
response["SAMLProviderList"][0]["Arn"].should.equal(
|
response["SAMLProviderList"][0]["Arn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:saml-provider/TestSAMLProvider"
|
"arn:aws:iam::{}:saml-provider/TestSAMLProvider".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -2114,10 +2115,10 @@ def test_list_entities_for_policy():
|
|||||||
)
|
)
|
||||||
|
|
||||||
conn.attach_user_policy(
|
conn.attach_user_policy(
|
||||||
UserName="testUser", PolicyArn="arn:aws:iam::123456789012:policy/testPolicy"
|
UserName="testUser", PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
conn.attach_group_policy(
|
conn.attach_group_policy(
|
||||||
GroupName="testGroup", PolicyArn="arn:aws:iam::123456789012:policy/testPolicy"
|
GroupName="testGroup", PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.add_user_to_group(UserName="testUser", GroupName="testGroup")
|
conn.add_user_to_group(UserName="testUser", GroupName="testGroup")
|
||||||
@ -2136,26 +2137,26 @@ def test_list_entities_for_policy():
|
|||||||
RoleName="my-role", PolicyName="test-policy", PolicyDocument=test_policy
|
RoleName="my-role", PolicyName="test-policy", PolicyDocument=test_policy
|
||||||
)
|
)
|
||||||
conn.attach_role_policy(
|
conn.attach_role_policy(
|
||||||
RoleName="my-role", PolicyArn="arn:aws:iam::123456789012:policy/testPolicy"
|
RoleName="my-role", PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
response = conn.list_entities_for_policy(
|
response = conn.list_entities_for_policy(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/testPolicy", EntityFilter="Role"
|
PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID), EntityFilter="Role"
|
||||||
)
|
)
|
||||||
assert response["PolicyRoles"] == [{"RoleName": "my-role"}]
|
assert response["PolicyRoles"] == [{"RoleName": "my-role"}]
|
||||||
|
|
||||||
response = conn.list_entities_for_policy(
|
response = conn.list_entities_for_policy(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/testPolicy", EntityFilter="User"
|
PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID), EntityFilter="User"
|
||||||
)
|
)
|
||||||
assert response["PolicyUsers"] == [{"UserName": "testUser"}]
|
assert response["PolicyUsers"] == [{"UserName": "testUser"}]
|
||||||
|
|
||||||
response = conn.list_entities_for_policy(
|
response = conn.list_entities_for_policy(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/testPolicy", EntityFilter="Group"
|
PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID), EntityFilter="Group"
|
||||||
)
|
)
|
||||||
assert response["PolicyGroups"] == [{"GroupName": "testGroup"}]
|
assert response["PolicyGroups"] == [{"GroupName": "testGroup"}]
|
||||||
|
|
||||||
response = conn.list_entities_for_policy(
|
response = conn.list_entities_for_policy(
|
||||||
PolicyArn="arn:aws:iam::123456789012:policy/testPolicy",
|
PolicyArn="arn:aws:iam::{}:policy/testPolicy".format(ACCOUNT_ID),
|
||||||
EntityFilter="LocalManagedPolicy",
|
EntityFilter="LocalManagedPolicy",
|
||||||
)
|
)
|
||||||
assert response["PolicyGroups"] == [{"GroupName": "testGroup"}]
|
assert response["PolicyGroups"] == [{"GroupName": "testGroup"}]
|
||||||
@ -2169,7 +2170,7 @@ def test_create_role_no_path():
|
|||||||
resp = conn.create_role(
|
resp = conn.create_role(
|
||||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Description="test"
|
RoleName="my-role", AssumeRolePolicyDocument="some policy", Description="test"
|
||||||
)
|
)
|
||||||
resp.get("Role").get("Arn").should.equal("arn:aws:iam::123456789012:role/my-role")
|
resp.get("Role").get("Arn").should.equal("arn:aws:iam::{}:role/my-role".format(ACCOUNT_ID))
|
||||||
resp.get("Role").should_not.have.key("PermissionsBoundary")
|
resp.get("Role").should_not.have.key("PermissionsBoundary")
|
||||||
resp.get("Role").get("Description").should.equal("test")
|
resp.get("Role").get("Description").should.equal("test")
|
||||||
|
|
||||||
@ -2177,7 +2178,7 @@ def test_create_role_no_path():
|
|||||||
@mock_iam()
|
@mock_iam()
|
||||||
def test_create_role_with_permissions_boundary():
|
def test_create_role_with_permissions_boundary():
|
||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
boundary = "arn:aws:iam::123456789012:policy/boundary"
|
boundary = "arn:aws:iam::{}:policy/boundary".format(ACCOUNT_ID)
|
||||||
resp = conn.create_role(
|
resp = conn.create_role(
|
||||||
RoleName="my-role",
|
RoleName="my-role",
|
||||||
AssumeRolePolicyDocument="some policy",
|
AssumeRolePolicyDocument="some policy",
|
||||||
@ -2249,7 +2250,7 @@ def test_create_open_id_connect_provider():
|
|||||||
)
|
)
|
||||||
|
|
||||||
response["OpenIDConnectProviderArn"].should.equal(
|
response["OpenIDConnectProviderArn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:oidc-provider/example.com"
|
"arn:aws:iam::{}:oidc-provider/example.com".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
response = client.create_open_id_connect_provider(
|
response = client.create_open_id_connect_provider(
|
||||||
@ -2257,7 +2258,7 @@ def test_create_open_id_connect_provider():
|
|||||||
)
|
)
|
||||||
|
|
||||||
response["OpenIDConnectProviderArn"].should.equal(
|
response["OpenIDConnectProviderArn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:oidc-provider/example.org"
|
"arn:aws:iam::{}:oidc-provider/example.org".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
response = client.create_open_id_connect_provider(
|
response = client.create_open_id_connect_provider(
|
||||||
@ -2265,7 +2266,7 @@ def test_create_open_id_connect_provider():
|
|||||||
)
|
)
|
||||||
|
|
||||||
response["OpenIDConnectProviderArn"].should.equal(
|
response["OpenIDConnectProviderArn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:oidc-provider/example.org/oidc"
|
"arn:aws:iam::{}:oidc-provider/example.org/oidc".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
response = client.create_open_id_connect_provider(
|
response = client.create_open_id_connect_provider(
|
||||||
@ -2273,7 +2274,7 @@ def test_create_open_id_connect_provider():
|
|||||||
)
|
)
|
||||||
|
|
||||||
response["OpenIDConnectProviderArn"].should.equal(
|
response["OpenIDConnectProviderArn"].should.equal(
|
||||||
"arn:aws:iam::123456789012:oidc-provider/example.org/oidc-query"
|
"arn:aws:iam::{}:oidc-provider/example.org/oidc-query".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -2487,7 +2488,7 @@ def test_get_account_password_policy_errors():
|
|||||||
|
|
||||||
client.get_account_password_policy.when.called_with().should.throw(
|
client.get_account_password_policy.when.called_with().should.throw(
|
||||||
ClientError,
|
ClientError,
|
||||||
"The Password Policy with domain name 123456789012 cannot be found.",
|
"The Password Policy with domain name {} cannot be found.".format(ACCOUNT_ID),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -2504,7 +2505,7 @@ def test_delete_account_password_policy():
|
|||||||
|
|
||||||
client.get_account_password_policy.when.called_with().should.throw(
|
client.get_account_password_policy.when.called_with().should.throw(
|
||||||
ClientError,
|
ClientError,
|
||||||
"The Password Policy with domain name 123456789012 cannot be found.",
|
"The Password Policy with domain name {} cannot be found.".format(ACCOUNT_ID),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ from nose.tools import assert_raises
|
|||||||
from boto.exception import BotoServerError
|
from boto.exception import BotoServerError
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from moto import mock_iam, mock_iam_deprecated
|
from moto import mock_iam, mock_iam_deprecated
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
MOCK_POLICY = """
|
MOCK_POLICY = """
|
||||||
{
|
{
|
||||||
@ -51,7 +52,7 @@ def test_get_group_current():
|
|||||||
assert result["Group"]["GroupName"] == "my-group"
|
assert result["Group"]["GroupName"] == "my-group"
|
||||||
assert isinstance(result["Group"]["CreateDate"], datetime)
|
assert isinstance(result["Group"]["CreateDate"], datetime)
|
||||||
assert result["Group"]["GroupId"]
|
assert result["Group"]["GroupId"]
|
||||||
assert result["Group"]["Arn"] == "arn:aws:iam::123456789012:group/my-group"
|
assert result["Group"]["Arn"] == "arn:aws:iam::{}:group/my-group".format(ACCOUNT_ID)
|
||||||
assert not result["Users"]
|
assert not result["Users"]
|
||||||
|
|
||||||
# Make a group with a different path:
|
# Make a group with a different path:
|
||||||
@ -59,7 +60,7 @@ def test_get_group_current():
|
|||||||
assert other_group["Group"]["Path"] == "some/location"
|
assert other_group["Group"]["Path"] == "some/location"
|
||||||
assert (
|
assert (
|
||||||
other_group["Group"]["Arn"]
|
other_group["Group"]["Arn"]
|
||||||
== "arn:aws:iam::123456789012:group/some/location/my-other-group"
|
== "arn:aws:iam::{}:group/some/location/my-other-group".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import boto3
|
|||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
from moto import mock_kinesis
|
from moto import mock_kinesis
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
def create_s3_delivery_stream(client, stream_name):
|
def create_s3_delivery_stream(client, stream_name):
|
||||||
@ -14,7 +15,7 @@ def create_s3_delivery_stream(client, stream_name):
|
|||||||
DeliveryStreamName=stream_name,
|
DeliveryStreamName=stream_name,
|
||||||
DeliveryStreamType="DirectPut",
|
DeliveryStreamType="DirectPut",
|
||||||
ExtendedS3DestinationConfiguration={
|
ExtendedS3DestinationConfiguration={
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"BucketARN": "arn:aws:s3:::kinesis-test",
|
"BucketARN": "arn:aws:s3:::kinesis-test",
|
||||||
"Prefix": "myFolder/",
|
"Prefix": "myFolder/",
|
||||||
"CompressionFormat": "UNCOMPRESSED",
|
"CompressionFormat": "UNCOMPRESSED",
|
||||||
@ -26,7 +27,7 @@ def create_s3_delivery_stream(client, stream_name):
|
|||||||
},
|
},
|
||||||
"SchemaConfiguration": {
|
"SchemaConfiguration": {
|
||||||
"DatabaseName": stream_name,
|
"DatabaseName": stream_name,
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"TableName": "outputTable",
|
"TableName": "outputTable",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -38,7 +39,7 @@ def create_redshift_delivery_stream(client, stream_name):
|
|||||||
return client.create_delivery_stream(
|
return client.create_delivery_stream(
|
||||||
DeliveryStreamName=stream_name,
|
DeliveryStreamName=stream_name,
|
||||||
RedshiftDestinationConfiguration={
|
RedshiftDestinationConfiguration={
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"ClusterJDBCURL": "jdbc:redshift://host.amazonaws.com:5439/database",
|
"ClusterJDBCURL": "jdbc:redshift://host.amazonaws.com:5439/database",
|
||||||
"CopyCommand": {
|
"CopyCommand": {
|
||||||
"DataTableName": "outputTable",
|
"DataTableName": "outputTable",
|
||||||
@ -47,7 +48,7 @@ def create_redshift_delivery_stream(client, stream_name):
|
|||||||
"Username": "username",
|
"Username": "username",
|
||||||
"Password": "password",
|
"Password": "password",
|
||||||
"S3Configuration": {
|
"S3Configuration": {
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"BucketARN": "arn:aws:s3:::kinesis-test",
|
"BucketARN": "arn:aws:s3:::kinesis-test",
|
||||||
"Prefix": "myFolder/",
|
"Prefix": "myFolder/",
|
||||||
"BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},
|
"BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},
|
||||||
@ -81,7 +82,7 @@ def test_create_redshift_delivery_stream():
|
|||||||
{
|
{
|
||||||
"DestinationId": "string",
|
"DestinationId": "string",
|
||||||
"RedshiftDestinationDescription": {
|
"RedshiftDestinationDescription": {
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"ClusterJDBCURL": "jdbc:redshift://host.amazonaws.com:5439/database",
|
"ClusterJDBCURL": "jdbc:redshift://host.amazonaws.com:5439/database",
|
||||||
"CopyCommand": {
|
"CopyCommand": {
|
||||||
"DataTableName": "outputTable",
|
"DataTableName": "outputTable",
|
||||||
@ -89,7 +90,7 @@ def test_create_redshift_delivery_stream():
|
|||||||
},
|
},
|
||||||
"Username": "username",
|
"Username": "username",
|
||||||
"S3DestinationDescription": {
|
"S3DestinationDescription": {
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"BucketARN": "arn:aws:s3:::kinesis-test",
|
"BucketARN": "arn:aws:s3:::kinesis-test",
|
||||||
"Prefix": "myFolder/",
|
"Prefix": "myFolder/",
|
||||||
"BufferingHints": {
|
"BufferingHints": {
|
||||||
@ -130,7 +131,7 @@ def test_create_s3_delivery_stream():
|
|||||||
{
|
{
|
||||||
"DestinationId": "string",
|
"DestinationId": "string",
|
||||||
"ExtendedS3DestinationDescription": {
|
"ExtendedS3DestinationDescription": {
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"BucketARN": "arn:aws:s3:::kinesis-test",
|
"BucketARN": "arn:aws:s3:::kinesis-test",
|
||||||
"Prefix": "myFolder/",
|
"Prefix": "myFolder/",
|
||||||
"CompressionFormat": "UNCOMPRESSED",
|
"CompressionFormat": "UNCOMPRESSED",
|
||||||
@ -146,7 +147,7 @@ def test_create_s3_delivery_stream():
|
|||||||
},
|
},
|
||||||
"SchemaConfiguration": {
|
"SchemaConfiguration": {
|
||||||
"DatabaseName": "stream1",
|
"DatabaseName": "stream1",
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"TableName": "outputTable",
|
"TableName": "outputTable",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -165,7 +166,7 @@ def test_create_stream_without_redshift():
|
|||||||
response = client.create_delivery_stream(
|
response = client.create_delivery_stream(
|
||||||
DeliveryStreamName="stream1",
|
DeliveryStreamName="stream1",
|
||||||
S3DestinationConfiguration={
|
S3DestinationConfiguration={
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"BucketARN": "arn:aws:s3:::kinesis-test",
|
"BucketARN": "arn:aws:s3:::kinesis-test",
|
||||||
"Prefix": "myFolder/",
|
"Prefix": "myFolder/",
|
||||||
"BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},
|
"BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},
|
||||||
@ -191,8 +192,8 @@ def test_create_stream_without_redshift():
|
|||||||
{
|
{
|
||||||
"DestinationId": "string",
|
"DestinationId": "string",
|
||||||
"S3DestinationDescription": {
|
"S3DestinationDescription": {
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"RoleARN": "arn:aws:iam::123456789012:role/firehose_delivery_role",
|
"RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),
|
||||||
"BucketARN": "arn:aws:s3:::kinesis-test",
|
"BucketARN": "arn:aws:s3:::kinesis-test",
|
||||||
"Prefix": "myFolder/",
|
"Prefix": "myFolder/",
|
||||||
"BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},
|
"BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},
|
||||||
|
@ -8,6 +8,7 @@ import boto3
|
|||||||
from boto.kinesis.exceptions import ResourceNotFoundException, InvalidArgumentException
|
from boto.kinesis.exceptions import ResourceNotFoundException, InvalidArgumentException
|
||||||
|
|
||||||
from moto import mock_kinesis, mock_kinesis_deprecated
|
from moto import mock_kinesis, mock_kinesis_deprecated
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_kinesis_deprecated
|
@mock_kinesis_deprecated
|
||||||
@ -21,7 +22,7 @@ def test_create_cluster():
|
|||||||
stream = stream_response["StreamDescription"]
|
stream = stream_response["StreamDescription"]
|
||||||
stream["StreamName"].should.equal("my_stream")
|
stream["StreamName"].should.equal("my_stream")
|
||||||
stream["HasMoreShards"].should.equal(False)
|
stream["HasMoreShards"].should.equal(False)
|
||||||
stream["StreamARN"].should.equal("arn:aws:kinesis:us-west-2:123456789012:my_stream")
|
stream["StreamARN"].should.equal("arn:aws:kinesis:us-west-2:{}:my_stream".format(ACCOUNT_ID))
|
||||||
stream["StreamStatus"].should.equal("ACTIVE")
|
stream["StreamStatus"].should.equal("ACTIVE")
|
||||||
|
|
||||||
shards = stream["Shards"]
|
shards = stream["Shards"]
|
||||||
@ -87,7 +88,7 @@ def test_describe_stream_summary():
|
|||||||
stream["StreamName"].should.equal(stream_name)
|
stream["StreamName"].should.equal(stream_name)
|
||||||
stream["OpenShardCount"].should.equal(shard_count)
|
stream["OpenShardCount"].should.equal(shard_count)
|
||||||
stream["StreamARN"].should.equal(
|
stream["StreamARN"].should.equal(
|
||||||
"arn:aws:kinesis:us-west-2:123456789012:{}".format(stream_name)
|
"arn:aws:kinesis:us-west-2:{}:{}".format(ACCOUNT_ID, stream_name)
|
||||||
)
|
)
|
||||||
stream["StreamStatus"].should.equal("ACTIVE")
|
stream["StreamStatus"].should.equal("ACTIVE")
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from moto import mock_ec2
|
|||||||
from moto import mock_ec2_deprecated
|
from moto import mock_ec2_deprecated
|
||||||
from moto import mock_redshift
|
from moto import mock_redshift
|
||||||
from moto import mock_redshift_deprecated
|
from moto import mock_redshift_deprecated
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
@mock_redshift
|
@mock_redshift
|
||||||
def test_create_cluster_boto3():
|
def test_create_cluster_boto3():
|
||||||
@ -998,12 +998,12 @@ def test_create_cluster_status_update():
|
|||||||
def test_describe_tags_with_resource_type():
|
def test_describe_tags_with_resource_type():
|
||||||
client = boto3.client("redshift", region_name="us-east-1")
|
client = boto3.client("redshift", region_name="us-east-1")
|
||||||
cluster_identifier = "my_cluster"
|
cluster_identifier = "my_cluster"
|
||||||
cluster_arn = "arn:aws:redshift:us-east-1:123456789012:" "cluster:{}".format(
|
cluster_arn = "arn:aws:redshift:us-east-1:{}:" "cluster:{}".format(
|
||||||
cluster_identifier
|
ACCOUNT_ID, cluster_identifier
|
||||||
)
|
)
|
||||||
snapshot_identifier = "my_snapshot"
|
snapshot_identifier = "my_snapshot"
|
||||||
snapshot_arn = "arn:aws:redshift:us-east-1:123456789012:" "snapshot:{}/{}".format(
|
snapshot_arn = "arn:aws:redshift:us-east-1:{}:" "snapshot:{}/{}".format(
|
||||||
cluster_identifier, snapshot_identifier
|
ACCOUNT_ID, cluster_identifier, snapshot_identifier
|
||||||
)
|
)
|
||||||
tag_key = "test-tag-key"
|
tag_key = "test-tag-key"
|
||||||
tag_value = "test-tag-value"
|
tag_value = "test-tag-value"
|
||||||
@ -1044,7 +1044,7 @@ def test_describe_tags_with_resource_type():
|
|||||||
@mock_redshift
|
@mock_redshift
|
||||||
def test_describe_tags_cannot_specify_resource_type_and_resource_name():
|
def test_describe_tags_cannot_specify_resource_type_and_resource_name():
|
||||||
client = boto3.client("redshift", region_name="us-east-1")
|
client = boto3.client("redshift", region_name="us-east-1")
|
||||||
resource_name = "arn:aws:redshift:us-east-1:123456789012:cluster:cluster-id"
|
resource_name = "arn:aws:redshift:us-east-1:{}:cluster:cluster-id".format(ACCOUNT_ID)
|
||||||
resource_type = "cluster"
|
resource_type = "cluster"
|
||||||
client.describe_tags.when.called_with(
|
client.describe_tags.when.called_with(
|
||||||
ResourceName=resource_name, ResourceType=resource_type
|
ResourceName=resource_name, ResourceType=resource_type
|
||||||
@ -1055,12 +1055,12 @@ def test_describe_tags_cannot_specify_resource_type_and_resource_name():
|
|||||||
def test_describe_tags_with_resource_name():
|
def test_describe_tags_with_resource_name():
|
||||||
client = boto3.client("redshift", region_name="us-east-1")
|
client = boto3.client("redshift", region_name="us-east-1")
|
||||||
cluster_identifier = "cluster-id"
|
cluster_identifier = "cluster-id"
|
||||||
cluster_arn = "arn:aws:redshift:us-east-1:123456789012:" "cluster:{}".format(
|
cluster_arn = "arn:aws:redshift:us-east-1:{}:" "cluster:{}".format(
|
||||||
cluster_identifier
|
ACCOUNT_ID, cluster_identifier
|
||||||
)
|
)
|
||||||
snapshot_identifier = "snapshot-id"
|
snapshot_identifier = "snapshot-id"
|
||||||
snapshot_arn = "arn:aws:redshift:us-east-1:123456789012:" "snapshot:{}/{}".format(
|
snapshot_arn = "arn:aws:redshift:us-east-1:{}:" "snapshot:{}/{}".format(
|
||||||
cluster_identifier, snapshot_identifier
|
ACCOUNT_ID, cluster_identifier, snapshot_identifier
|
||||||
)
|
)
|
||||||
tag_key = "test-tag-key"
|
tag_key = "test-tag-key"
|
||||||
tag_value = "test-tag-value"
|
tag_value = "test-tag-value"
|
||||||
@ -1102,8 +1102,8 @@ def test_describe_tags_with_resource_name():
|
|||||||
def test_create_tags():
|
def test_create_tags():
|
||||||
client = boto3.client("redshift", region_name="us-east-1")
|
client = boto3.client("redshift", region_name="us-east-1")
|
||||||
cluster_identifier = "cluster-id"
|
cluster_identifier = "cluster-id"
|
||||||
cluster_arn = "arn:aws:redshift:us-east-1:123456789012:" "cluster:{}".format(
|
cluster_arn = "arn:aws:redshift:us-east-1:{}:" "cluster:{}".format(
|
||||||
cluster_identifier
|
ACCOUNT_ID, cluster_identifier
|
||||||
)
|
)
|
||||||
tag_key = "test-tag-key"
|
tag_key = "test-tag-key"
|
||||||
tag_value = "test-tag-value"
|
tag_value = "test-tag-value"
|
||||||
@ -1133,8 +1133,8 @@ def test_create_tags():
|
|||||||
def test_delete_tags():
|
def test_delete_tags():
|
||||||
client = boto3.client("redshift", region_name="us-east-1")
|
client = boto3.client("redshift", region_name="us-east-1")
|
||||||
cluster_identifier = "cluster-id"
|
cluster_identifier = "cluster-id"
|
||||||
cluster_arn = "arn:aws:redshift:us-east-1:123456789012:" "cluster:{}".format(
|
cluster_arn = "arn:aws:redshift:us-east-1:{}:" "cluster:{}".format(
|
||||||
cluster_identifier
|
ACCOUNT_ID, cluster_identifier
|
||||||
)
|
)
|
||||||
tag_key = "test-tag-key"
|
tag_key = "test-tag-key"
|
||||||
tag_value = "test-tag-value"
|
tag_value = "test-tag-value"
|
||||||
|
@ -10,6 +10,7 @@ import sure # noqa
|
|||||||
from nose import tools
|
from nose import tools
|
||||||
from moto import mock_ses, mock_sns, mock_sqs
|
from moto import mock_ses, mock_sns, mock_sqs
|
||||||
from moto.ses.models import SESFeedback
|
from moto.ses.models import SESFeedback
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_ses
|
@mock_ses
|
||||||
@ -35,7 +36,7 @@ def __setup_feedback_env__(
|
|||||||
sns_conn.subscribe(
|
sns_conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
Protocol="sqs",
|
||||||
Endpoint="arn:aws:sqs:%s:123456789012:%s" % (region, queue),
|
Endpoint="arn:aws:sqs:%s:%s:%s" % (region, ACCOUNT_ID, queue),
|
||||||
)
|
)
|
||||||
# Verify SES domain
|
# Verify SES domain
|
||||||
ses_conn.verify_domain_identity(Domain=domain)
|
ses_conn.verify_domain_identity(Domain=domain)
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import boto
|
import boto
|
||||||
from boto.exception import BotoServerError
|
from boto.exception import BotoServerError
|
||||||
from moto import mock_sns_deprecated
|
from moto import mock_sns_deprecated
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ def test_create_platform_application():
|
|||||||
"CreatePlatformApplicationResult"
|
"CreatePlatformApplicationResult"
|
||||||
]["PlatformApplicationArn"]
|
]["PlatformApplicationArn"]
|
||||||
application_arn.should.equal(
|
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"
|
"CreatePlatformEndpointResult"
|
||||||
]["EndpointArn"]
|
]["EndpointArn"]
|
||||||
endpoint_arn.should.contain(
|
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 botocore.exceptions import ClientError
|
||||||
from moto import mock_sns
|
from moto import mock_sns
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_sns
|
@mock_sns
|
||||||
@ -19,7 +20,7 @@ def test_create_platform_application():
|
|||||||
)
|
)
|
||||||
application_arn = response["PlatformApplicationArn"]
|
application_arn = response["PlatformApplicationArn"]
|
||||||
application_arn.should.equal(
|
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 = endpoint["EndpointArn"]
|
||||||
endpoint_arn.should.contain(
|
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
|
import sure # noqa
|
||||||
|
|
||||||
from moto import mock_sns_deprecated, mock_sqs_deprecated
|
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:'+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}'
|
||||||
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}'
|
|
||||||
|
|
||||||
|
|
||||||
@mock_sqs_deprecated
|
@mock_sqs_deprecated
|
||||||
@ -25,7 +25,7 @@ def test_publish_to_sqs():
|
|||||||
sqs_conn = boto.connect_sqs()
|
sqs_conn = boto.connect_sqs()
|
||||||
sqs_conn.create_queue("test-queue")
|
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"
|
message_to_publish = "my message"
|
||||||
subject_to_publish = "test subject"
|
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 = boto.sqs.connect_to_region("us-west-2")
|
||||||
sqs_conn.create_queue("test-queue")
|
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"
|
message_to_publish = "my message"
|
||||||
subject_to_publish = "test subject"
|
subject_to_publish = "test subject"
|
||||||
|
@ -12,9 +12,9 @@ import responses
|
|||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
from moto import mock_sns, mock_sqs
|
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:'+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}'
|
||||||
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}'
|
|
||||||
|
|
||||||
|
|
||||||
@mock_sqs
|
@mock_sqs
|
||||||
@ -31,7 +31,7 @@ def test_publish_to_sqs():
|
|||||||
conn.subscribe(
|
conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
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"
|
message = "my message"
|
||||||
with freeze_time("2015-01-01 12:00:00"):
|
with freeze_time("2015-01-01 12:00:00"):
|
||||||
@ -88,7 +88,7 @@ def test_publish_to_sqs_bad():
|
|||||||
conn.subscribe(
|
conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
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"
|
message = "my message"
|
||||||
try:
|
try:
|
||||||
@ -149,7 +149,7 @@ def test_publish_to_sqs_msg_attr_byte_value():
|
|||||||
conn.subscribe(
|
conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
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"
|
message = "my message"
|
||||||
conn.publish(
|
conn.publish(
|
||||||
@ -243,7 +243,7 @@ def test_publish_to_sqs_dump_json():
|
|||||||
conn.subscribe(
|
conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
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(
|
message = json.dumps(
|
||||||
@ -289,7 +289,7 @@ def test_publish_to_sqs_in_different_region():
|
|||||||
conn.subscribe(
|
conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
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"
|
message = "my message"
|
||||||
@ -348,7 +348,7 @@ def test_publish_subject():
|
|||||||
conn.subscribe(
|
conn.subscribe(
|
||||||
TopicArn=topic_arn,
|
TopicArn=topic_arn,
|
||||||
Protocol="sqs",
|
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"
|
message = "my message"
|
||||||
subject1 = "test subject"
|
subject1 = "test subject"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
@ -16,11 +17,11 @@ def test_sns_server_get():
|
|||||||
topic_data = test_client.action_data("CreateTopic", Name="testtopic")
|
topic_data = test_client.action_data("CreateTopic", Name="testtopic")
|
||||||
topic_data.should.contain("CreateTopicResult")
|
topic_data.should.contain("CreateTopicResult")
|
||||||
topic_data.should.contain(
|
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 = test_client.action_data("ListTopics")
|
||||||
topics_data.should.contain("ListTopicsResult")
|
topics_data.should.contain("ListTopicsResult")
|
||||||
topic_data.should.contain(
|
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 boto.exception import BotoServerError
|
||||||
from moto import mock_sns_deprecated
|
from moto import mock_sns_deprecated
|
||||||
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
|
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
|
|
||||||
@mock_sns_deprecated
|
@mock_sns_deprecated
|
||||||
@ -19,7 +20,7 @@ def test_create_and_delete_topic():
|
|||||||
topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
|
topics = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
|
||||||
topics.should.have.length_of(1)
|
topics.should.have.length_of(1)
|
||||||
topics[0]["TopicArn"].should.equal(
|
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
|
# Delete the topic
|
||||||
@ -58,7 +59,7 @@ def test_topic_corresponds_to_region():
|
|||||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0][
|
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0][
|
||||||
"TopicArn"
|
"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
|
@mock_sns_deprecated
|
||||||
@ -75,9 +76,9 @@ def test_topic_attributes():
|
|||||||
"GetTopicAttributesResult"
|
"GetTopicAttributesResult"
|
||||||
]["Attributes"]
|
]["Attributes"]
|
||||||
attributes["TopicArn"].should.equal(
|
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(
|
json.loads(attributes["Policy"]).should.equal(
|
||||||
{
|
{
|
||||||
"Version": "2008-10-17",
|
"Version": "2008-10-17",
|
||||||
@ -98,8 +99,8 @@ def test_topic_attributes():
|
|||||||
"SNS:Publish",
|
"SNS:Publish",
|
||||||
"SNS:Receive",
|
"SNS:Receive",
|
||||||
],
|
],
|
||||||
"Resource": "arn:aws:sns:us-east-1:123456789012:some-topic",
|
"Resource": "arn:aws:sns:us-east-1:{}:some-topic".format(ACCOUNT_ID),
|
||||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import sure # noqa
|
|||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from moto import mock_sns
|
from moto import mock_sns
|
||||||
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
|
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
@mock_sns
|
@mock_sns
|
||||||
def test_create_and_delete_topic():
|
def test_create_and_delete_topic():
|
||||||
@ -20,8 +20,8 @@ def test_create_and_delete_topic():
|
|||||||
topics = topics_json["Topics"]
|
topics = topics_json["Topics"]
|
||||||
topics.should.have.length_of(1)
|
topics.should.have.length_of(1)
|
||||||
topics[0]["TopicArn"].should.equal(
|
topics[0]["TopicArn"].should.equal(
|
||||||
"arn:aws:sns:{0}:123456789012:{1}".format(
|
"arn:aws:sns:{0}:{1}:{2}".format(
|
||||||
conn._client_config.region_name, topic_name
|
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")
|
conn.create_topic(Name="some-topic")
|
||||||
topics_json = conn.list_topics()
|
topics_json = conn.list_topics()
|
||||||
topic_arn = topics_json["Topics"][0]["TopicArn"]
|
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
|
@mock_sns
|
||||||
@ -145,11 +145,11 @@ def test_topic_attributes():
|
|||||||
|
|
||||||
attributes = conn.get_topic_attributes(TopicArn=topic_arn)["Attributes"]
|
attributes = conn.get_topic_attributes(TopicArn=topic_arn)["Attributes"]
|
||||||
attributes["TopicArn"].should.equal(
|
attributes["TopicArn"].should.equal(
|
||||||
"arn:aws:sns:{0}:123456789012:some-topic".format(
|
"arn:aws:sns:{0}:{1}:some-topic".format(
|
||||||
conn._client_config.region_name
|
conn._client_config.region_name, ACCOUNT_ID
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
attributes["Owner"].should.equal("123456789012")
|
attributes["Owner"].should.equal(ACCOUNT_ID)
|
||||||
json.loads(attributes["Policy"]).should.equal(
|
json.loads(attributes["Policy"]).should.equal(
|
||||||
{
|
{
|
||||||
"Version": "2008-10-17",
|
"Version": "2008-10-17",
|
||||||
@ -170,8 +170,8 @@ def test_topic_attributes():
|
|||||||
"SNS:Publish",
|
"SNS:Publish",
|
||||||
"SNS:Receive",
|
"SNS:Receive",
|
||||||
],
|
],
|
||||||
"Resource": "arn:aws:sns:us-east-1:123456789012:some-topic",
|
"Resource": "arn:aws:sns:us-east-1:{}:some-topic".format(ACCOUNT_ID),
|
||||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -271,15 +271,15 @@ def test_add_remove_permissions():
|
|||||||
"SNS:Publish",
|
"SNS:Publish",
|
||||||
"SNS:Receive",
|
"SNS:Receive",
|
||||||
],
|
],
|
||||||
"Resource": "arn:aws:sns:us-east-1:123456789012:test-permissions",
|
"Resource": "arn:aws:sns:us-east-1:{}:test-permissions".format(ACCOUNT_ID),
|
||||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Sid": "test",
|
"Sid": "test",
|
||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Principal": {"AWS": "arn:aws:iam::999999999999:root"},
|
"Principal": {"AWS": "arn:aws:iam::999999999999:root"},
|
||||||
"Action": "SNS:Publish",
|
"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:Publish",
|
||||||
"SNS:Receive",
|
"SNS:Receive",
|
||||||
],
|
],
|
||||||
"Resource": "arn:aws:sns:us-east-1:123456789012:test-permissions",
|
"Resource": "arn:aws:sns:us-east-1:{}:test-permissions".format(ACCOUNT_ID),
|
||||||
"Condition": {"StringEquals": {"AWS:SourceOwner": "123456789012"}},
|
"Condition": {"StringEquals": {"AWS:SourceOwner": ACCOUNT_ID}},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -334,7 +334,7 @@ def test_add_remove_permissions():
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Action": ["SNS:Publish", "SNS:Subscribe"],
|
"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),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from moto import mock_sqs, mock_sqs_deprecated, settings
|
|||||||
from nose import SkipTest
|
from nose import SkipTest
|
||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
from tests.helpers import requires_boto_gte
|
from tests.helpers import requires_boto_gte
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
@mock_sqs
|
@mock_sqs
|
||||||
def test_create_fifo_queue_fail():
|
def test_create_fifo_queue_fail():
|
||||||
@ -283,7 +283,7 @@ def test_create_queues_in_multiple_region():
|
|||||||
base_url = "https://us-west-1.queue.amazonaws.com"
|
base_url = "https://us-west-1.queue.amazonaws.com"
|
||||||
|
|
||||||
west1_conn.list_queues()["QueueUrls"][0].should.equal(
|
west1_conn.list_queues()["QueueUrls"][0].should.equal(
|
||||||
"{base_url}/123456789012/blah".format(base_url=base_url)
|
"{base_url}/{AccountId}/blah".format(base_url=base_url,AccountId=ACCCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ def test_get_queue_with_prefix():
|
|||||||
base_url = "https://us-west-1.queue.amazonaws.com"
|
base_url = "https://us-west-1.queue.amazonaws.com"
|
||||||
|
|
||||||
queue[0].should.equal(
|
queue[0].should.equal(
|
||||||
"{base_url}/123456789012/test-queue".format(base_url=base_url)
|
"{base_url}/{AccountId}/test-queue".format(base_url=base_url, AccountId=ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ def test_get_queue_attributes():
|
|||||||
response["Attributes"]["MaximumMessageSize"].should.equal("65536")
|
response["Attributes"]["MaximumMessageSize"].should.equal("65536")
|
||||||
response["Attributes"]["MessageRetentionPeriod"].should.equal("345600")
|
response["Attributes"]["MessageRetentionPeriod"].should.equal("345600")
|
||||||
response["Attributes"]["QueueArn"].should.equal(
|
response["Attributes"]["QueueArn"].should.equal(
|
||||||
"arn:aws:sqs:us-east-1:123456789012:test-queue"
|
"arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID)
|
||||||
)
|
)
|
||||||
response["Attributes"]["ReceiveMessageWaitTimeSeconds"].should.equal("0")
|
response["Attributes"]["ReceiveMessageWaitTimeSeconds"].should.equal("0")
|
||||||
response["Attributes"]["VisibilityTimeout"].should.equal("30")
|
response["Attributes"]["VisibilityTimeout"].should.equal("30")
|
||||||
@ -361,7 +361,7 @@ def test_get_queue_attributes():
|
|||||||
{
|
{
|
||||||
"ApproximateNumberOfMessages": "0",
|
"ApproximateNumberOfMessages": "0",
|
||||||
"MaximumMessageSize": "65536",
|
"MaximumMessageSize": "65536",
|
||||||
"QueueArn": "arn:aws:sqs:us-east-1:123456789012:test-queue",
|
"QueueArn": "arn:aws:sqs:us-east-1:{}:test-queue".format(ACCOUNT_ID),
|
||||||
"VisibilityTimeout": "30",
|
"VisibilityTimeout": "30",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -851,7 +851,7 @@ def test_queue_attributes():
|
|||||||
attributes = queue.get_attributes()
|
attributes = queue.get_attributes()
|
||||||
|
|
||||||
attributes["QueueArn"].should.look_like(
|
attributes["QueueArn"].should.look_like(
|
||||||
"arn:aws:sqs:us-east-1:123456789012:%s" % queue_name
|
"arn:aws:sqs:us-east-1:{AccountId}:{name}".format(AccountId=ACCOUNT_ID,name=queue_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
attributes["VisibilityTimeout"].should.look_like(str(visibility_timeout))
|
attributes["VisibilityTimeout"].should.look_like(str(visibility_timeout))
|
||||||
@ -1402,7 +1402,7 @@ def test_redrive_policy_available():
|
|||||||
def test_redrive_policy_non_existent_queue():
|
def test_redrive_policy_non_existent_queue():
|
||||||
sqs = boto3.client("sqs", region_name="us-east-1")
|
sqs = boto3.client("sqs", region_name="us-east-1")
|
||||||
redrive_policy = {
|
redrive_policy = {
|
||||||
"deadLetterTargetArn": "arn:aws:sqs:us-east-1:123456789012:no-queue",
|
"deadLetterTargetArn": "arn:aws:sqs:us-east-1:{}:no-queue".format(ACCOUNT_ID),
|
||||||
"maxReceiveCount": 1,
|
"maxReceiveCount": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from botocore.exceptions import ClientError
|
|||||||
from nose.tools import assert_raises
|
from nose.tools import assert_raises
|
||||||
|
|
||||||
from moto import mock_sts, mock_stepfunctions
|
from moto import mock_sts, mock_stepfunctions
|
||||||
|
from moto.iam.models import ACCOUNT_ID
|
||||||
|
|
||||||
region = "us-east-1"
|
region = "us-east-1"
|
||||||
simple_definition = (
|
simple_definition = (
|
||||||
@ -34,7 +34,7 @@ def test_state_machine_creation_succeeds():
|
|||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
response["creationDate"].should.be.a(datetime)
|
response["creationDate"].should.be.a(datetime)
|
||||||
response["stateMachineArn"].should.equal(
|
response["stateMachineArn"].should.equal(
|
||||||
"arn:aws:states:" + region + ":123456789012:stateMachine:" + name
|
"arn:aws:states:" + region + ":"+ACCOUNT_ID+":stateMachine:" + name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ def test_state_machine_can_deleted_nonexisting_machine():
|
|||||||
client = boto3.client("stepfunctions", region_name=region)
|
client = boto3.client("stepfunctions", region_name=region)
|
||||||
#
|
#
|
||||||
unknown_state_machine = (
|
unknown_state_machine = (
|
||||||
"arn:aws:states:" + region + ":123456789012:stateMachine:unknown"
|
"arn:aws:states:" + region + ":"+ACCOUNT_ID+":stateMachine:unknown"
|
||||||
)
|
)
|
||||||
response = client.delete_state_machine(stateMachineArn=unknown_state_machine)
|
response = client.delete_state_machine(stateMachineArn=unknown_state_machine)
|
||||||
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user