blob: 99837ebd1b174f5243c5556762f633dbae200b09 [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):
45 self.glance_image_create()
46 self.nova_boot()
47
Matt Riedemanncd2872a2015-03-13 09:50:25 -070048 def create_encrypted_volume(self, encryption_provider, volume_type):
49 volume_type = self.create_volume_type(name=volume_type)
Masayuki Igawa1f0ad632014-08-05 13:36:56 +090050 self.create_encryption_type(type_id=volume_type['id'],
Kaitlin Farr366a51f2014-04-21 12:43:54 -040051 provider=encryption_provider,
52 key_size=512,
53 cipher='aes-xts-plain64',
54 control_location='front-end')
Masayuki Igawa1f0ad632014-08-05 13:36:56 +090055 self.volume = self.create_volume(volume_type=volume_type['name'])
Kaitlin Farr366a51f2014-04-21 12:43:54 -040056
57 def attach_detach_volume(self):
Jordan Pittier7cf64762015-10-14 15:01:12 +020058 self.volume = self.nova_volume_attach(self.server, self.volume)
59 self.nova_volume_detach(self.server, self.volume)
Kaitlin Farr366a51f2014-04-21 12:43:54 -040060
Chris Hoge7579c1a2015-02-26 14:12:15 -080061 @test.idempotent_id('79165fb4-5534-4b9d-8429-97ccffb8f86e')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040062 @test.services('compute', 'volume', 'image')
63 def test_encrypted_cinder_volumes_luks(self):
64 self.launch_instance()
65 self.create_encrypted_volume('nova.volume.encryptors.'
Matt Riedemanncd2872a2015-03-13 09:50:25 -070066 'luks.LuksEncryptor',
67 volume_type='luks')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040068 self.attach_detach_volume()
Kaitlin Farr366a51f2014-04-21 12:43:54 -040069
Chris Hoge7579c1a2015-02-26 14:12:15 -080070 @test.idempotent_id('cbc752ed-b716-4717-910f-956cce965722')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040071 @test.services('compute', 'volume', 'image')
72 def test_encrypted_cinder_volumes_cryptsetup(self):
73 self.launch_instance()
74 self.create_encrypted_volume('nova.volume.encryptors.'
Matt Riedemanncd2872a2015-03-13 09:50:25 -070075 'cryptsetup.CryptsetupEncryptor',
76 volume_type='cryptsetup')
Joe Gordon28788b42015-02-25 12:42:37 -080077 self.attach_detach_volume()