blob: 082a8bfc59a1943ea950e51ef5f195c88ca1bc1d [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
48 return self.create_server(image=image,
49 create_kwargs={'key_name': keypair['name']})
Kaitlin Farr366a51f2014-04-21 12:43:54 -040050
Matt Riedemanncd2872a2015-03-13 09:50:25 -070051 def create_encrypted_volume(self, encryption_provider, volume_type):
52 volume_type = self.create_volume_type(name=volume_type)
Masayuki Igawa1f0ad632014-08-05 13:36:56 +090053 self.create_encryption_type(type_id=volume_type['id'],
Kaitlin Farr366a51f2014-04-21 12:43:54 -040054 provider=encryption_provider,
55 key_size=512,
56 cipher='aes-xts-plain64',
57 control_location='front-end')
Jordan Pittier1e443ec2015-11-20 16:15:58 +010058 return self.create_volume(volume_type=volume_type['name'])
Kaitlin Farr366a51f2014-04-21 12:43:54 -040059
Jordan Pittier1e443ec2015-11-20 16:15:58 +010060 def attach_detach_volume(self, server, volume):
61 attached_volume = self.nova_volume_attach(server, volume)
62 self.nova_volume_detach(server, attached_volume)
Kaitlin Farr366a51f2014-04-21 12:43:54 -040063
Chris Hoge7579c1a2015-02-26 14:12:15 -080064 @test.idempotent_id('79165fb4-5534-4b9d-8429-97ccffb8f86e')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040065 @test.services('compute', 'volume', 'image')
66 def test_encrypted_cinder_volumes_luks(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010067 server = self.launch_instance()
68 volume = self.create_encrypted_volume('nova.volume.encryptors.'
69 'luks.LuksEncryptor',
70 volume_type='luks')
71 self.attach_detach_volume(server, volume)
Kaitlin Farr366a51f2014-04-21 12:43:54 -040072
Chris Hoge7579c1a2015-02-26 14:12:15 -080073 @test.idempotent_id('cbc752ed-b716-4717-910f-956cce965722')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040074 @test.services('compute', 'volume', 'image')
75 def test_encrypted_cinder_volumes_cryptsetup(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010076 server = self.launch_instance()
77 volume = self.create_encrypted_volume('nova.volume.encryptors.'
78 'cryptsetup.CryptsetupEncryptor',
79 volume_type='cryptsetup')
80 self.attach_detach_volume(server, volume)