Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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''))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)