-
Notifications
You must be signed in to change notification settings - Fork 0
/
authManager_tests.py
59 lines (45 loc) · 2.46 KB
/
authManager_tests.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
import unittest
from authManager import AuthManager
class TestCode(unittest.TestCase):
def setUp(self):
self.auth_manager_plain = AuthManager("databases/plainDB.csv", False, False)
self.auth_manager_hash = AuthManager("databases/hashDB.csv", True, False)
self.auth_manager_salt = AuthManager("databases/saltDB.csv", True, True)
def test_file_runs(self):
self.assertEqual(1, 1)
def test_A_add_user(self):
self.assertTrue(self.auth_manager_plain.add_user("mike", "pass"))
self.assertTrue(self.auth_manager_hash.add_user("mike", "pass"))
self.assertTrue(self.auth_manager_salt.add_user("mike", "pass"))
def test_B_add_dup_user(self):
self.assertFalse(self.auth_manager_plain.add_user("mike", "pass"))
self.assertFalse(self.auth_manager_hash.add_user("mike", "pass"))
self.assertFalse(self.auth_manager_salt.add_user("mike", "pass"))
def test_C_add_second_user(self):
self.assertTrue(self.auth_manager_plain.add_user("john", "word"))
self.assertTrue(self.auth_manager_hash.add_user("john", "word"))
self.assertTrue(self.auth_manager_salt.add_user("john", "word"))
def test_D_add_third_user_dup_pass(self):
self.assertTrue(self.auth_manager_plain.add_user("bill", "word"))
self.assertTrue(self.auth_manager_hash.add_user("bill", "word"))
self.assertTrue(self.auth_manager_salt.add_user("bill", "word"))
def test_E_successful_login(self):
self.assertTrue(self.auth_manager_plain.login("mike", "pass"))
self.assertTrue(self.auth_manager_hash.login("mike", "pass"))
self.assertTrue(self.auth_manager_salt.login("mike", "pass"))
def test_F_bad_password(self):
self.assertFalse(self.auth_manager_plain.login("mike", "word"))
self.assertFalse(self.auth_manager_hash.login("mike", "word"))
self.assertFalse(self.auth_manager_salt.login("mike", "word"))
def test_G_bad_username(self):
self.assertFalse(self.auth_manager_plain.login("john", "pass"))
self.assertFalse(self.auth_manager_hash.login("john", "pass"))
self.assertFalse(self.auth_manager_salt.login("john", "pass"))
if __name__ == '__main__':
auth1 = AuthManager("databases/plainDB.csv", False, False)
auth2 = AuthManager("databases/hashDB.csv", True, False)
auth3 = AuthManager("databases/saltDB.csv", True, True)
auth1.clear_db()
auth2.clear_db()
auth3.clear_db()
unittest.main()