예제 #1
0
    def test_verify_file(self):
        # setup - create test file
        shutil.copyfile(self.filepath['unencrypted'], self.filepath['test'])
        verified_encrypt_file(TEST_KEY,
                              self.filepath['test'],
                              self.filepath['encryption-test-result'])

        self.assertEqual(verify_file(TEST_KEY,
                                     self.filepath['encryption-test-result']),
                         True)
        self.assertEqual(verify_file("Bad password!",
                                     self.filepath['encryption-test-result']),
                         False)
        # Test bad file input
        self.assertEqual(verify_file("Bad password!",
                                     self.filepath['test']),
                         False)
예제 #2
0
    def test_encrypt_and_decrypt_file_verified_are_reversible(self):
        # setup - create test file
        shutil.copyfile(self.filepath['unencrypted'], self.filepath['test'])

        # test encrypt
        verified_encrypt_file(TEST_KEY,
                              self.filepath['test'],
                              self.filepath['encryption-test-result'])

        # assert is different from the original
        self.assertFalse(filecmp.cmp(self.filepath['encryption-test-result'],
                                     self.filepath['test']))

        verified_decrypt_file(TEST_KEY,
                              self.filepath['encryption-test-result'],
                              self.filepath['test'])

        # assert back to original
        self.assertTrue(filecmp.cmp(self.filepath['test'],
                                    self.filepath['unencrypted']),
                        "Files don't match!")