コード例 #1
0
    def test_encryption_info_column_without_info(self):
        fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
        type_id = fake_volume_type.id

        col = volume_type.EncryptionInfoColumn(type_id, {})
        self.assertEqual('-', col.human_readable())
        self.assertIsNone(col.machine_readable())
コード例 #2
0
    def test_type_list_with_encryption(self):
        encryption_type = \
            volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
                attrs={'volume_type_id': self.volume_types[0].id})
        encryption_info = {
            'provider': 'LuksEncryptor',
            'cipher': None,
            'key_size': None,
            'control_location': 'front-end',
        }
        encryption_columns = self.columns + [
            "Encryption",
        ]
        encryption_data = []
        encryption_data.append((
            self.volume_types[0].id,
            self.volume_types[0].name,
            self.volume_types[0].is_public,
            volume_type.EncryptionInfoColumn(
                self.volume_types[0].id,
                {self.volume_types[0].id: encryption_info}),
        ))
        encryption_data.append((
            self.volume_types[1].id,
            self.volume_types[1].name,
            self.volume_types[1].is_public,
            volume_type.EncryptionInfoColumn(self.volume_types[1].id, {}),
        ))

        self.encryption_types_mock.list.return_value = [encryption_type]
        arglist = [
            "--encryption-type",
        ]
        verifylist = [
            ("encryption_type", True),
        ]
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        columns, data = self.cmd.take_action(parsed_args)
        self.encryption_types_mock.list.assert_called_once_with()
        self.types_mock.list.assert_called_once_with(is_public=None)
        self.assertEqual(encryption_columns, columns)
        self.assertCountEqual(encryption_data, list(data))
コード例 #3
0
    def test_encryption_info_column_with_info(self):
        fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
        type_id = fake_volume_type.id

        encryption_info = {
            'provider': 'LuksEncryptor',
            'cipher': None,
            'key_size': None,
            'control_location': 'front-end',
        }
        col = volume_type.EncryptionInfoColumn(type_id,
                                               {type_id: encryption_info})
        self.assertEqual(utils.format_dict(encryption_info),
                         col.human_readable())
        self.assertEqual(encryption_info, col.machine_readable())