예제 #1
0
def test_get_enabled_regions_from_arg():
    botocore_session = MagicMock()
    subject = CloudWandererBoto3Session(botocore_session=botocore_session,
                                        enabled_regions=["eu-west-1"])

    assert subject.get_enabled_regions() == ["eu-west-1"]

    botocore_session.create_client.assert_not_called()
예제 #2
0
def test_get_account_id_from_arg():
    botocore_session = MagicMock()
    subject = CloudWandererBoto3Session(botocore_session=botocore_session,
                                        account_id="0123456789012")

    assert subject.get_account_id() == "0123456789012"

    botocore_session.create_client.assert_not_called()
예제 #3
0
def get_resources_to_test():
    session = CloudWandererBoto3Session()
    for service_name in session.get_available_resources():
        service = service_cache(service_name)
        for resource_type in service.resource_types:
            resource = resource_type_cache(service_name, resource_type)
            yield f"{service.service_name}_{resource_type}", resource
            for dependent_resource_type in resource.dependent_resource_types:
                dependent_resource = service.resource(dependent_resource_type,
                                                      empty_resource=True)
                yield f"{service.service_name}_{dependent_resource_type}", dependent_resource
예제 #4
0
def test_get_enabled_regions():
    botocore_session = MagicMock()
    subject = CloudWandererBoto3Session(
        botocore_session=botocore_session,
        getter_client_config=CloudWandererBoto3ClientConfig(
            ec2={"endpoint_url": "ec2.eu-west-1.amazonaws.com"}),
    )

    subject.get_enabled_regions()

    botocore_session.create_client.assert_called_with(
        "ec2",
        region_name=None,
        api_version=None,
        use_ssl=True,
        verify=None,
        endpoint_url="ec2.eu-west-1.amazonaws.com",
        aws_access_key_id=None,
        aws_secret_access_key=None,
        aws_session_token=None,
        config=None,
    )
예제 #5
0
def cloudwanderer_boto3_session(botocore_session):
    session = CloudWandererBoto3Session(botocore_session=botocore_session)
    return session
예제 #6
0
def service_resource_ec2_vpc():
    session = CloudWandererBoto3Session()
    service = session.resource("ec2")
    return service.resource("vpc", empty_resource=True)
예제 #7
0
def service_resource_iam():
    session = CloudWandererBoto3Session()
    return session.resource("iam")
예제 #8
0
def service_resource_ec2_route(service_resource_ec2_route_table):
    session = CloudWandererBoto3Session()
    service = session.resource("ec2")
    return service.resource("route", empty_resource=True)
예제 #9
0
def service_resource_iam_role_policy():
    session = CloudWandererBoto3Session()
    service = session.resource("iam")
    return service.resource("role_policy", empty_resource=True)
예제 #10
0
def service_resource_s3_bucket():
    session = CloudWandererBoto3Session()
    service = session.resource("s3")
    return service.resource("bucket", empty_resource=True)
예제 #11
0
def cloudwanderer_boto3_session(botocore_session):
    session = CloudWandererBoto3Session(botocore_session=botocore_session)
    session.get_account_id = MagicMock(return_value="111111111111")
    return session
예제 #12
0
def cloudwanderer_boto3_session():
    return CloudWandererBoto3Session(aws_access_key_id="aaaa",
                                     aws_secret_access_key="aaaaaa")
예제 #13
0
def session_cache():
    return CloudWandererBoto3Session()