コード例 #1
0
 def test_invalid_second_parameter(self):
     """
     The method checks the generation of an exception when
     the second parameter is incorrect.
     """
     with self.assertRaises(ValueError):
         crypto_wrapper.encrypt(DATA, None)
コード例 #2
0
 def test_invalid_first_parameter(self):
     """
     The method checks the generation of an exception when
     the first parameter is incorrect.
     """
     key = crypto_wrapper.generate_key()
     with self.assertRaises(ValueError):
         crypto_wrapper.encrypt(None, key)
コード例 #3
0
 def test_encrypted_data_type(self):
     """
     The method checks the type of encrypted data
     """
     key = crypto_wrapper.generate_key()
     encrypted_data = crypto_wrapper.encrypt(DATA, key)
     self.assertEquals(type(encrypted_data), type(b''))
コード例 #4
0
 def test_encrypt_is_not_empty(self):
     """
     The method checks the presence of encrypted data.
     """
     key = crypto_wrapper.generate_key()
     encrypted_data = crypto_wrapper.encrypt(DATA, key)
     self.assertTrue(encrypted_data)
コード例 #5
0
 def test_correct_decryption(self):
     """
     The method checks the correctness of the decryption.
     """
     key = crypto_wrapper.generate_key()
     encrypted_data = crypto_wrapper.encrypt(DATA, key)
     decrypted_data = crypto_wrapper.decrypt(encrypted_data, key)
     self.assertEquals(DATA, decrypted_data)
コード例 #6
0
 def test_invalid_second_parameter(self):
     """
     The method checks the generation of an exception when
     the second parameter is incorrect.
     """
     key = crypto_wrapper.generate_key()
     encrypted_data = crypto_wrapper.encrypt(DATA, key)
     with self.assertRaises(ValueError):
         crypto_wrapper.decrypt(encrypted_data, None)