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")
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")
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'}) ])
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})
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})
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})
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'})])
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)
def _get_volume_encryptor(self, connection_info, encryption): encryptor = encryptors.get_volume_encryptor(connection_info, **encryption) return encryptor