Exemplo n.º 1
0
class TestACMEncryptDecrypt(unittest.TestCase):
    def setUp(self):
        self.acm = ACM(a=1, b=1, n=2)

    @unittest.expectedFailure
    def test_validation_encrypt_matrix_is_good(self):
        try:
            matrix = np.ones(5, 5)
            self.acm.encrypt(matrix)
            self.acm.decrypt(matrix)
            self.fail('Validation is succeed and no errors')
        except ValidationError as validation_error:
            actual = validation_error.errors
            expected = "matrix is not a square matrix"
            self.assertEqual(expected, actual)

    def test_validation_encrypt_matrix_square_problem(self):
        try:
            matrix = np.ones((5, 3))
            self.acm.encrypt(matrix)
            self.acm.decrypt(matrix)
            self.fail('Validation is succeed and no errors')
        except ValidationError as validation_error:
            actual = validation_error.errors
            expected = "matrix is not a square matrix"
            self.assertEqual(expected, actual)
Exemplo n.º 2
0
 def test_encrypt_decrypt(self):
     acm = ACM(a=1, b=2, n=1)
     ciphermatrix = acm.encrypt(self.plainmatrix)
     actual = acm.decrypt(ciphermatrix)
     expected = self.plainmatrix
     self.assertTrue(np.array_equal(expected, actual))