Beispiel #1
0
 def test_delete_different_resource_id_and_file_path(self):
     """ This makes sure that delete deletes when the resource_id and
     the private_key_path differ.
     """
     temp_key = tempfile.mktemp()
     ctx = self.mock_ctx('test_delete_different_resource_id_and_file_path')
     ctx.node.properties['private_key_path'] = temp_key
     ctx.node.properties['resource_id'] = 'something_else'
     current_ctx.set(ctx=ctx)
     keypair.create(ctx=ctx)
     self.assertTrue(os.path.exists(temp_key))
     keypair.delete(ctx=ctx)
     self.assertFalse(os.path.exists(temp_key))
    def test_delete(self):
        """ this tests that keypair delete removes the keypair from
            the account
        """
        ctx = self.mock_ctx('test_delete')
        current_ctx.set(ctx=ctx)

        ec2_client = connection.EC2ConnectionClient().client()
        kp = ec2_client.create_key_pair('test_delete')
        ctx.instance.runtime_properties['aws_resource_id'] = kp.name
        ctx.instance.runtime_properties['key_path'] = \
            self.create_dummy_key_path(ctx=ctx)
        keypair.delete(ctx=ctx)
        self.assertEquals(None, ec2_client.get_key_pair(kp.name))
Beispiel #3
0
    def test_delete(self):
        """ this tests that keypair delete removes the keypair from
            the account
        """
        ctx = self.mock_ctx('test_delete')
        current_ctx.set(ctx=ctx)

        ec2_client = connection.EC2ConnectionClient().client()
        kp = ec2_client.create_key_pair('test_delete')
        ctx.instance.runtime_properties['aws_resource_id'] = kp.name
        ctx.instance.runtime_properties['key_path'] = \
            self.create_dummy_key_path(ctx=ctx)
        keypair.delete(ctx=ctx)
        self.assertEquals(None, ec2_client.get_key_pair(kp.name))
Beispiel #4
0
    def test_runtime_property_deleted(self):
        """ This tests that the key pair type is added to and removed from the
        runtime_properties.
        """
        ctx = self.mock_ctx('test_key_pair_type')
        current_ctx.set(ctx=ctx)

        keypair.create(ctx=ctx)
        self.assertIn('external_type', ctx.instance.runtime_properties.keys())
        self.assertEqual('keypair',
                         ctx.instance.runtime_properties['external_type'])

        keypair.delete(ctx=ctx)
        self.assertNotIn('external_type',
                         ctx.instance.runtime_properties.keys())
Beispiel #5
0
    def test_delete_use_external(self):
        """ This tests that delete function removes the
        runtime_properties for external resource.
        """

        ctx = self.mock_ctx('test_delete_use_external')
        current_ctx.set(ctx=ctx)

        ec2_client = connection.EC2ConnectionClient().client()
        kp = ec2_client.create_key_pair('test_delete_use_external')
        ctx.node.properties['use_external_resource'] = True
        ctx.node.properties['resource_id'] = kp.name
        ctx.instance.runtime_properties['aws_resource_id'] = kp.name
        keypair.delete(ctx=ctx)
        self.assertNotIn('aws_resource_id', ctx.instance.runtime_properties)
 def test_delete_different_resource_id_and_file_path(self):
     """ This makes sure that delete deletes when the resource_id and
     the private_key_path differ.
     """
     temp_key = tempfile.mktemp()
     ctx = self.mock_ctx(
         'test_delete_different_resource_id_and_file_path')
     ctx.node.properties['private_key_path'] = temp_key
     ctx.node.properties['resource_id'] = 'something_else'
     current_ctx.set(ctx=ctx)
     keypair.create(ctx=ctx)
     self.assertTrue(
         os.path.exists(temp_key))
     keypair.delete(ctx=ctx)
     self.assertFalse(
         os.path.exists(temp_key))
    def test_delete_use_external(self):
        """ This tests that delete function removes the
        runtime_properties for external resource.
        """

        ctx = self.mock_ctx('test_delete_use_external')
        current_ctx.set(ctx=ctx)

        ec2_client = connection.EC2ConnectionClient().client()
        kp = ec2_client.create_key_pair(
            'test_delete_use_external')
        ctx.node.properties['use_external_resource'] = True
        ctx.node.properties['resource_id'] = kp.name
        ctx.instance.runtime_properties['aws_resource_id'] = kp.name
        keypair.delete(ctx=ctx)
        self.assertNotIn('aws_resource_id', ctx.instance.runtime_properties)
    def test_runtime_property_deleted(self):
        """ This tests that the key pair type is added to and removed from the
        runtime_properties.
        """
        ctx = self.mock_ctx('test_key_pair_type')
        current_ctx.set(ctx=ctx)

        keypair.create(ctx=ctx)
        self.assertIn('external_type',
                      ctx.instance.runtime_properties.keys())
        self.assertEqual('keypair',
                         ctx.instance.runtime_properties['external_type'])

        keypair.delete(ctx=ctx)
        self.assertNotIn('external_type',
                         ctx.instance.runtime_properties.keys())