'Test volume can be created from an encrypted volume.'

def test_create_volume_from_encrypted_volume(self):

    self.mock_object(key_manager, 'API', fake_keymgr.fake_api)
    cipher = 'aes-xts-plain64'
    key_size = 256
    volume_api = cinder.volume.api.API()
    ctxt = context.get_admin_context()
    db.volume_type_create(ctxt, {'id': '61298380-0c12-11e3-bfd6-4b48424183be', 'name': 'LUKS'})
    db.volume_type_encryption_create(ctxt, '61298380-0c12-11e3-bfd6-4b48424183be', {'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER, 'cipher': cipher, 'key_size': key_size})
    db_vol_type = db.volume_type_get_by_name(context.get_admin_context(), 'LUKS')
    volume_src = volume_api.create(self.context, 1, 'name', 'description', volume_type=db_vol_type)
    volume_src['status'] = 'available'
    volume_dst = volume_api.create(self.context, 1, 'name', 'description', source_volume=volume_src)
    self.assertEqual(volume_dst['id'], db.volume_get(context.get_admin_context(), volume_dst['id']).id)
    self.assertEqual(volume_src['id'], db.volume_get(context.get_admin_context(), volume_dst['id']).source_volid)
    self.assertIsNotNone(volume_src['encryption_key_id'])
    self.assertIsNotNone(volume_dst['encryption_key_id'])
    km = volume_api.key_manager
    volume_src_key = km.get(self.context, volume_src['encryption_key_id'])
    volume_dst_key = km.get(self.context, volume_dst['encryption_key_id'])
    self.assertEqual(volume_src_key, volume_dst_key)
