def test_error_base64(self): t = MailAttachments.withhashes(self.attachments_test_1) t.run(filtercontenttypes=False, intelligence=False) files = [] for i in t: f = write_payload(i["payload"], i["extension"], i["content_transfer_encoding"]) files.append(f) for i in files: os.remove(i)
def test_write_payload(self): with open(text_files) as f: payload = f.read() sha1_origin = fingerprints(payload).sha1 file_path = utils.write_payload(payload.encode("base64"), ".txt") self.assertEqual(os.path.splitext(file_path)[-1], ".txt") with open(file_path) as f: payload = f.read() sha1_clone = fingerprints(payload).sha1 self.assertEqual(sha1_origin, sha1_clone) self.assertTrue(os.path.exists(file_path)) os.remove(file_path) self.assertFalse(os.path.exists(file_path))