Ejemplo n.º 1
0
    def test_no_validate(self):
        """ Test that the --no-validate option turns off validation.
        """
        aws_svc, encryptor_image, guest_image = _build_aws_service()
        sg = aws_svc.create_security_group('test', 'test', vpc_id='vpc-1')

        values = DummyValues()
        values.security_group_ids = [sg.id]

        # Validation checks that the security group is not in the default
        # subnet.
        with self.assertRaises(brkt_cli.ValidationError):
            brkt_cli._connect_and_validate(aws_svc, values, encryptor_image.id)

        # Exception is not raised when we turn off validation.
        values.validate = False
        brkt_cli._connect_and_validate(aws_svc, values, encryptor_image.id)
Ejemplo n.º 2
0
    def test_duplicate_image_name(self):
        """ Test that we detect name collisions with the encrypted image.
        """
        aws_svc, encryptor_image, guest_image = _build_aws_service()

        # No name.
        values = DummyValues()
        image = None
        for image_id, i in aws_svc.images.iteritems():
            values.ami = image_id
            image = i
        brkt_cli._connect_and_validate(aws_svc, values, encryptor_image.id)

        # Unique name.
        image.name = 'My image'
        values.encrypted_ami_name = 'Propsed name'
        brkt_cli._connect_and_validate(aws_svc, values, encryptor_image.id)

        # Name collision.
        values.encrypted_ami_name = image.name
        with self.assertRaises(brkt_cli.ValidationError):
            brkt_cli._connect_and_validate(aws_svc, values, encryptor_image.id)