This repository has been archived by the owner on Oct 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.py
executable file
·80 lines (65 loc) · 4 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
from configparser import ConfigParser
import phishfry
import unittest
config = ConfigParser()
config.read("/opt/phishfry/config.ini")
user = config["test"]["user"]
password = config["test"]["pass"]
account = phishfry.Account(user, password)
class TestPhishfry(unittest.TestCase):
def test_remediate_forward_to_group(self):
# restore first in case deleted
account.Restore("[email protected]", "<CAAoaDjT=8xPVW6e=yyv2eji7rzUMxPwnv6uMJJVzYbFK=LPCVw@mail.gmail.com>", True)
# test deleting email that was forwarded to group
results = account.Remove("[email protected]", "<CAAoaDjT=8xPVW6e=yyv2eji7rzUMxPwnv6uMJJVzYbFK=LPCVw@mail.gmail.com>", True)
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
# test restoring email that was forwarded to group
results = account.Restore("[email protected]", "<CAAoaDjT=8xPVW6e=yyv2eji7rzUMxPwnv6uMJJVzYbFK=LPCVw@mail.gmail.com>", True)
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
def test_remediate_non_existent_message(self):
# restore first in case it is deleted
account.Restore("[email protected]", "<non-existent-message-id>")
# test deleting non existent message
results = account.Remove("[email protected]", "<non-existent-message-id>")
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
self.assertEqual(results["[email protected]"].message, "Message not found")
# test restoring non existent message
results = account.Restore("[email protected]", "<non-existent-message-id>")
self.assertIn("[email protected]", results)
self.assertFalse(results["[email protected]"].success)
self.assertEqual(results["[email protected]"].message, "Message not found")
def test_remediate_reply_to_external_mailbox(self):
# restore first in case deleted
account.Restore("[email protected]", "<CAAoaDjQJ3Kor1nZMPJwEN56KK0pBDxyjhJjR-Hgj7ZA85hKy-w@mail.gmail.com>")
# test deleting email that was forwarded to external mailbox
results = account.Remove("[email protected]", "<CAAoaDjQJ3Kor1nZMPJwEN56KK0pBDxyjhJjR-Hgj7ZA85hKy-w@mail.gmail.com>")
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
# test restoring email that was forwarded to external mailbox
results = account.Restore("[email protected]", "<CAAoaDjQJ3Kor1nZMPJwEN56KK0pBDxyjhJjR-Hgj7ZA85hKy-w@mail.gmail.com>")
self.assertIn("[email protected]", results)
self.assertTrue(results["[email protected]"].success)
def test_resolve_alias(self):
mailbox = account.GetMailbox("[email protected]")
self.assertEqual(mailbox.address, "[email protected]")
def test_resolve_non_existent_email(self):
mailbox = account.GetMailbox("[email protected]")
self.assertEqual(mailbox, None)
def test_expand_distribution_list(self):
mailbox = account.GetMailbox("[email protected]")
members = mailbox.Expand()
self.assertEqual(len(members), 2)
def test_get_group_owner(self):
mailbox = account.GetMailbox("[email protected]")
owner = mailbox.GetOwner()
self.assertEqual(owner.group.address, "[email protected]")
if __name__ == '__main__':
unittest.main(verbosity=2)