def test_heartbeat_and_challenge(self): file1 = Heartbeat(self.file_path, "mysecret") file1.generate_challenges(10, self.root_seed) challenge = file1.random_challenge() # Create hash_response from seed and duplicate file file2 = Heartbeat(self.file_path2) answer = file2.meet_challenge(challenge) self.assertTrue(file1.check_answer(answer)) # Create hash_answer from seed and edited file file3 = Heartbeat(self.file_path3) answer = file3.meet_challenge(challenge) # This should not match self.assertFalse(file1.check_answer(answer))
class Client(object): def __init__(self, file_path): self.target_file = Heartbeat(file_path, "mysecret") def answer(self, challenge): return self.target_file.meet_challenge(challenge)