blob: dcd77ad05ba598a3d90c6b30d1802594510f9d30 [file] [log] [blame]
Kaitlin Farr366a51f2014-04-21 12:43:54 -04001# Copyright (c) 2014 The Johns Hopkins University/Applied Physics Laboratory
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Matt Riedemann79b3b492015-06-20 14:20:44 -070016from tempest import config
Kaitlin Farr366a51f2014-04-21 12:43:54 -040017from tempest.scenario import manager
18from tempest import test
19
Matt Riedemann79b3b492015-06-20 14:20:44 -070020CONF = config.CONF
21
Kaitlin Farr366a51f2014-04-21 12:43:54 -040022
23class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
24
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000025 """The test suite for encrypted cinder volumes
26
Kaitlin Farr366a51f2014-04-21 12:43:54 -040027 This test is for verifying the functionality of encrypted cinder volumes.
28
29 For both LUKS and cryptsetup encryption types, this test performs
30 the following:
31 * Creates an image in Glance
32 * Boots an instance from the image
33 * Creates an encryption type (as admin)
34 * Creates a volume of that encryption type (as a regular user)
35 * Attaches and detaches the encrypted volume to the instance
Kaitlin Farr366a51f2014-04-21 12:43:54 -040036 """
37
Matt Riedemann79b3b492015-06-20 14:20:44 -070038 @classmethod
39 def skip_checks(cls):
40 super(TestEncryptedCinderVolumes, cls).skip_checks()
41 if not CONF.compute_feature_enabled.attach_encrypted_volume:
42 raise cls.skipException('Encrypted volume attach is not supported')
43
Kaitlin Farr366a51f2014-04-21 12:43:54 -040044 def launch_instance(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010045 image = self.glance_image_create()
46 keypair = self.create_keypair()
47
lanoux5fc14522015-09-21 08:17:35 +000048 return self.create_server(image_id=image,
49 key_name=keypair['name'],
50 wait_until='ACTIVE')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040051
Matt Riedemanncd2872a2015-03-13 09:50:25 -070052 def create_encrypted_volume(self, encryption_provider, volume_type):
53 volume_type = self.create_volume_type(name=volume_type)
Masayuki Igawa1f0ad632014-08-05 13:36:56 +090054 self.create_encryption_type(type_id=volume_type['id'],
Kaitlin Farr366a51f2014-04-21 12:43:54 -040055 provider=encryption_provider,
56 key_size=512,
57 cipher='aes-xts-plain64',
58 control_location='front-end')
Jordan Pittier1e443ec2015-11-20 16:15:58 +010059 return self.create_volume(volume_type=volume_type['name'])
Kaitlin Farr366a51f2014-04-21 12:43:54 -040060
Jordan Pittier1e443ec2015-11-20 16:15:58 +010061 def attach_detach_volume(self, server, volume):
62 attached_volume = self.nova_volume_attach(server, volume)
63 self.nova_volume_detach(server, attached_volume)
Kaitlin Farr366a51f2014-04-21 12:43:54 -040064
Chris Hoge7579c1a2015-02-26 14:12:15 -080065 @test.idempotent_id('79165fb4-5534-4b9d-8429-97ccffb8f86e')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040066 @test.services('compute', 'volume', 'image')
67 def test_encrypted_cinder_volumes_luks(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010068 server = self.launch_instance()
69 volume = self.create_encrypted_volume('nova.volume.encryptors.'
70 'luks.LuksEncryptor',
71 volume_type='luks')
72 self.attach_detach_volume(server, volume)
Kaitlin Farr366a51f2014-04-21 12:43:54 -040073
Chris Hoge7579c1a2015-02-26 14:12:15 -080074 @test.idempotent_id('cbc752ed-b716-4717-910f-956cce965722')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040075 @test.services('compute', 'volume', 'image')
76 def test_encrypted_cinder_volumes_cryptsetup(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010077 server = self.launch_instance()
78 volume = self.create_encrypted_volume('nova.volume.encryptors.'
79 'cryptsetup.CryptsetupEncryptor',
80 volume_type='cryptsetup')
81 self.attach_detach_volume(server, volume)