blob: a05b1b18378d5c92541c77c3e1b74efd51a67fae [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
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080017from tempest.lib import decorators
Kaitlin Farr366a51f2014-04-21 12:43:54 -040018from tempest.scenario import manager
19from tempest import test
20
Matt Riedemann79b3b492015-06-20 14:20:44 -070021CONF = config.CONF
22
Kaitlin Farr366a51f2014-04-21 12:43:54 -040023
24class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
25
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000026 """The test suite for encrypted cinder volumes
27
Kaitlin Farr366a51f2014-04-21 12:43:54 -040028 This test is for verifying the functionality of encrypted cinder volumes.
29
30 For both LUKS and cryptsetup encryption types, this test performs
31 the following:
32 * Creates an image in Glance
33 * Boots an instance from the image
34 * Creates an encryption type (as admin)
35 * Creates a volume of that encryption type (as a regular user)
36 * Attaches and detaches the encrypted volume to the instance
Kaitlin Farr366a51f2014-04-21 12:43:54 -040037 """
38
Matt Riedemann79b3b492015-06-20 14:20:44 -070039 @classmethod
40 def skip_checks(cls):
41 super(TestEncryptedCinderVolumes, cls).skip_checks()
42 if not CONF.compute_feature_enabled.attach_encrypted_volume:
43 raise cls.skipException('Encrypted volume attach is not supported')
44
Kaitlin Farr366a51f2014-04-21 12:43:54 -040045 def launch_instance(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010046 image = self.glance_image_create()
47 keypair = self.create_keypair()
48
zhufl13c9c892017-02-10 12:04:07 +080049 return self.create_server(image_id=image, 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,
David Moreau-Simardfedca6f2016-08-23 15:37:05 -040055 key_size=256,
Kaitlin Farr366a51f2014-04-21 12:43:54 -040056 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
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080064 @decorators.idempotent_id('79165fb4-5534-4b9d-8429-97ccffb8f86e')
Sean Dague49505df2017-03-01 11:35:58 -050065 @test.attr(type='slow')
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
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080074 @decorators.idempotent_id('cbc752ed-b716-4717-910f-956cce965722')
Sean Dague49505df2017-03-01 11:35:58 -050075 @test.attr(type='slow')
Kaitlin Farr366a51f2014-04-21 12:43:54 -040076 @test.services('compute', 'volume', 'image')
77 def test_encrypted_cinder_volumes_cryptsetup(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +010078 server = self.launch_instance()
79 volume = self.create_encrypted_volume('nova.volume.encryptors.'
80 'cryptsetup.CryptsetupEncryptor',
81 volume_type='cryptsetup')
82 self.attach_detach_volume(server, volume)