Beispiel #1
0
    def test_get_encryptors(self):
        encryption = {
            'control_location': 'front-end',
            'provider': 'LuksEncryptor'
        }
        encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                    **encryption)
        self.assertIsInstance(encryptor, luks.LuksEncryptor,
                              "encryptor is not an instance of LuksEncryptor")

        encryption = {
            'control_location': 'front-end',
            'provider': 'CryptsetupEncryptor'
        }
        encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                    **encryption)
        self.assertIsInstance(
            encryptor, cryptsetup.CryptsetupEncryptor,
            "encryptor is not an instance of"
            "CryptsetupEncryptor")

        encryption = {
            'control_location': 'front-end',
            'provider': 'NoOpEncryptor'
        }
        encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                    **encryption)
        self.assertIsInstance(encryptor, nop.NoOpEncryptor,
                              "encryptor is not an instance of NoOpEncryptor")
Beispiel #2
0
    def test_get_encryptors(self):
        encryption = {'control_location': 'front-end',
                      'provider': 'LuksEncryptor'}
        encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                    **encryption)
        self.assertIsInstance(encryptor,
                              luks.LuksEncryptor,
                              "encryptor is not an instance of LuksEncryptor")

        encryption = {'control_location': 'front-end',
                      'provider': 'CryptsetupEncryptor'}
        encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                    **encryption)
        self.assertIsInstance(encryptor,
                              cryptsetup.CryptsetupEncryptor,
                              "encryptor is not an instance of"
                              "CryptsetupEncryptor")

        encryption = {'control_location': 'front-end',
                      'provider': 'NoOpEncryptor'}
        encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                    **encryption)
        self.assertIsInstance(encryptor,
                              nop.NoOpEncryptor,
                              "encryptor is not an instance of NoOpEncryptor")
Beispiel #3
0
    def test_get_direct_encryptor_log(self, log):
        encryption = {
            'control_location': 'front-end',
            'provider': 'LuksEncryptor'
        }
        encryptors.get_volume_encryptor(self.connection_info, **encryption)

        encryption = {
            'control_location': 'front-end',
            'provider': 'nova.volume.encryptors.luks.LuksEncryptor'
        }
        encryptors.get_volume_encryptor(self.connection_info, **encryption)

        log.warning.assert_has_calls([
            mock.call(
                "Use of the in tree encryptor class %(provider)s by "
                "directly referencing the implementation class will be "
                "blocked in the 16.0.0 Pike release of Nova.",
                {'provider': 'LuksEncryptor'}),
            mock.call(
                "Use of the in tree encryptor class %(provider)s by "
                "directly referencing the implementation class will be "
                "blocked in the 16.0.0 Pike release of Nova.",
                {'provider': 'nova.volume.encryptors.luks.LuksEncryptor'})
        ])
Beispiel #4
0
 def test_error_log(self, log):
     encryption = {'control_location': 'front-end',
                   'provider': 'TestEncryptor'}
     provider = 'TestEncryptor'
     try:
         encryptors.get_volume_encryptor(self.connection_info, **encryption)
     except Exception as e:
         log.error.assert_called_once_with(_LE("Error instantiating "
                                               "%(provider)s: "
                                               "%(exception)s"),
                   {'provider': provider, 'exception': e})
Beispiel #5
0
 def test_get_missing_out_of_tree_encryptor_log(self, log):
     provider = 'TestEncryptor'
     encryption = {'control_location': 'front-end',
                   'provider': provider}
     try:
         encryptors.get_volume_encryptor(self.connection_info, **encryption)
     except Exception as e:
         log.error.assert_called_once_with("Error instantiating "
                                           "%(provider)s: "
                                           "%(exception)s",
                                           {'provider': provider,
                                            'exception': e})
         log.warning.assert_called_once_with("Use of the out of tree "
                                             "encryptor class %(provider)s "
                                             "will be blocked with the "
                                             "16.0.0 Pike release of Nova.",
                                             {'provider': provider})
Beispiel #6
0
 def test_get_missing_out_of_tree_encryptor_log(self, log):
     provider = 'TestEncryptor'
     encryption = {'control_location': 'front-end', 'provider': provider}
     try:
         encryptors.get_volume_encryptor(self.connection_info, **encryption)
     except Exception as e:
         log.error.assert_called_once_with(
             "Error instantiating "
             "%(provider)s: "
             "%(exception)s", {
                 'provider': provider,
                 'exception': e
             })
         log.warning.assert_called_once_with(
             "Use of the out of tree "
             "encryptor class %(provider)s "
             "will be blocked with the "
             "16.0.0 Pike release of Nova.", {'provider': provider})
Beispiel #7
0
    def test_get_direct_encryptor_log(self, log):
        encryption = {'control_location': 'front-end',
                      'provider': 'LuksEncryptor'}
        encryptors.get_volume_encryptor(self.connection_info, **encryption)

        encryption = {'control_location': 'front-end',
                      'provider': 'nova.volume.encryptors.luks.LuksEncryptor'}
        encryptors.get_volume_encryptor(self.connection_info, **encryption)

        log.warning.assert_has_calls([
            mock.call("Use of the in tree encryptor class %(provider)s by "
                      "directly referencing the implementation class will be "
                      "blocked in the 16.0.0 Pike release of Nova.",
                      {'provider': 'LuksEncryptor'}),
            mock.call("Use of the in tree encryptor class %(provider)s by "
                      "directly referencing the implementation class will be "
                      "blocked in the 16.0.0 Pike release of Nova.",
                      {'provider':
                           'nova.volume.encryptors.luks.LuksEncryptor'})])
Beispiel #8
0
 def _test_get_encryptor(self, provider, expected_provider_class):
     encryption = {'control_location': 'front-end', 'provider': provider}
     encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                 **encryption)
     self.assertIsInstance(encryptor, expected_provider_class)
Beispiel #9
0
 def _get_volume_encryptor(self, connection_info, encryption):
     encryptor = encryptors.get_volume_encryptor(connection_info,
                                                 **encryption)
     return encryptor
Beispiel #10
0
 def _test_get_encryptor(self, provider, expected_provider_class):
     encryption = {'control_location': 'front-end',
                   'provider': provider}
     encryptor = encryptors.get_volume_encryptor(self.connection_info,
                                                 **encryption)
     self.assertIsInstance(encryptor, expected_provider_class)