Esempio n. 1
0
def initialize_environment_smoke_test(discover_source_buckets_smoke_test):
    mock_sqs().start()
    queue_arn_parts = config.DeploymentDetails.sqs_arn.split(sep=':')
    queue_name = queue_arn_parts[len(queue_arn_parts) - 1]
    sqs_client = awshelper.get_client(awshelper.ServiceName.sqs)
    sqs_client.create_queue(QueueName=queue_name)
    s3_client = awshelper.get_client(awshelper.ServiceName.s3)
    s3_client.create_bucket(
        Bucket=TestValues.regional_inventory_destination_bucket_name,
        CreateBucketConfiguration={
            'LocationConstraint': 'us-west-2'})

    body = bytes('hello world', 'utf-8')

    s3_client.put_object(
        Bucket=TestValues.regional_inventory_destination_bucket_name,
        Key=TestValues.sample_inventory_object_key,
        Body=body)

    s3_client.put_object(
        Bucket=TestValues.regional_inventory_destination_bucket_name,
        Key=TestValues.sample_inventory_manifest_key,
        Body=body)
    yield discover_source_buckets_smoke_test
    mock_sqs().stop()
Esempio n. 2
0
def test_create_destination_buckets(discover_source_buckets_smoke_test):
    input_parameters = discover_source_buckets_smoke_test.input_parameters
    s3.create_inventory_destination_buckets(input_parameters)

    stack_name = s3.get_stack_name(input_parameters.run_id)
    cloudformation_client = awshelper.get_client(
        awshelper.ServiceName.cloudformation, 'us-west-2')
    details = cloudformation_client.describe_stacks(StackName=stack_name, )
    current_status = details['Stacks'][0]['StackStatus'].lower()
    assert utility.compare_strings(current_status, 'create_complete') is True
Esempio n. 3
0
def ses_email_verification_request_helper(input_parameters,
                                          verify_sender_email_address,
                                          expected_count):
    input_parameters.verify_sender_email_address = verify_sender_email_address
    ses.send_email_verification_requests(input_parameters)
    ses_client = awshelper.get_client(awshelper.ServiceName.ses)
    response = ses_client.list_identities(IdentityType='EmailAddress')
    for recipient in input_parameters.recipient_email_addresses:
        assert recipient in response['Identities']
    if verify_sender_email_address:
        assert input_parameters.sender_email_address in response['Identities']
def test_detect_bucket_updates(initialize_environment_smoke_test):
    mock_db_update()
    input_parameters = initialize_environment_smoke_test.input_parameters
    s3_client = awshelper.get_client(awshelper.ServiceName.s3)
    s3_client.delete_object(Bucket=conftest.TestValues.test_bucket_1_name,
                            Key='sampleobject')
    s3_client.delete_bucket(Bucket=conftest.TestValues.test_bucket_1_name)
    s3.update_source_bucket_inventory_status(
        input_parameters, conftest.TestValues.test_account_id)
    assert conftest.find_ddb_bucket(
        conftest.TestValues.test_bucket_1_name,
        ddb.BucketInventoryStatus.bucket_not_available)
    assert conftest.find_ddb_bucket(conftest.TestValues.test_bucket_2_name,
                                    ddb.BucketInventoryStatus.bucket_is_empty)
def test_delete_smoke_test_resources_success(initialize_environment_smoke_test):
    input_parameters = initialize_environment_smoke_test.input_parameters
    s3_client = awshelper.get_client(awshelper.ServiceName.s3)
    consolidated_bucket_name = config.DeploymentDetails.consolidated_inventory_bucket_name
    object_path = s3.get_inventory_prefix_at_consolidated_bucket(input_parameters.run_id) + utility.random_string()
    body = bytes('hello world', 'utf-8')
    s3_client.put_object(
        Bucket=consolidated_bucket_name,
        Key=object_path,
        Body=body)

    encountered_exception = False
    try:
        smoketest.cleanup_and_verify()
    except Exception:
        encountered_exception = True
    assert encountered_exception is False
def get_bucket_count():
    s3_client = awshelper.get_client(awshelper.ServiceName.s3)
    response = s3_client.list_buckets()
    return len(response['Buckets'])
Esempio n. 7
0
def get_object_count(bucket_name):
    s3_client = awshelper.get_client(awshelper.ServiceName.s3)
    object_list = s3_client.list_objects_v2(Bucket=bucket_name)
    object_count = object_list['KeyCount']
    return object_count
Esempio n. 8
0
def setup_s3_and_ddb(aws_credentials):
    mock_cloudformation().start()
    mock_dynamodb2().start()
    mock_s3().start()
    mock_ses().start()
    mock_sts().start()
    dynamodb_client = awshelper.get_resource(awshelper.ServiceName.dynamodb)
    table = dynamodb_client.create_table(
        TableName=config.DefaultValue.config_table_name,
        KeySchema=[
            {
                'AttributeName': 'partitionkey',
                'KeyType': 'HASH'
            },
            {
                'AttributeName': 'sortkey',
                'KeyType': 'RANGE'
            }
        ],
        AttributeDefinitions=[
            {
                'AttributeName': 'partitionkey',
                'AttributeType': 'S'
            },
            {
                'AttributeName': 'sortkey',
                'AttributeType': 'S'
            }

        ]
    )

    s3_client = awshelper.get_client(awshelper.ServiceName.s3)
    s3_client.create_bucket(
        Bucket=TestValues.test_bucket_1_name,
        CreateBucketConfiguration={
            'LocationConstraint': 'us-west-2'})

    s3_client.create_bucket(
        Bucket=TestValues.test_bucket_2_name,
        CreateBucketConfiguration={
            'LocationConstraint': 'us-west-2'})

    body = bytes('hello world', 'utf-8')

    s3_client.put_object(
        Bucket=TestValues.test_bucket_1_name,
        Key='sampleobject',
        Body=body)

    s3_client.create_bucket(
        Bucket=config.DeploymentDetails.consolidated_inventory_bucket_name,
        CreateBucketConfiguration={
            'LocationConstraint': 'us-west-2'})

    index = config.ServiceParameters.iterator_count

    ddb.store_iterator_index(
        config.ServiceParameters.inventory_monitor_iterator_name,
        index)

    yield TestResources(table, None, None)
    mock_sts().stop()
    mock_ses().stop()
    mock_s3().stop()
    mock_dynamodb2().stop()
    mock_cloudformation().stop()