forked from p15670423/monkey
Refactored test_user_creds.py to pytest from unittests
This commit is contained in:
parent
502bc3b296
commit
f28cd5305c
|
@ -1,37 +1,27 @@
|
||||||
from unittest import TestCase
|
|
||||||
|
|
||||||
from monkey_island.cc.environment.user_creds import UserCreds
|
from monkey_island.cc.environment.user_creds import UserCreds
|
||||||
|
|
||||||
|
|
||||||
class TestUserCreds(TestCase):
|
def test_to_dict_empty_creds():
|
||||||
def test_to_dict(self):
|
user_creds = UserCreds()
|
||||||
user_creds = UserCreds()
|
assert user_creds.to_dict() == {}
|
||||||
self.assertDictEqual(user_creds.to_dict(), {})
|
|
||||||
|
|
||||||
user_creds = UserCreds(username="Test")
|
|
||||||
self.assertDictEqual(user_creds.to_dict(), {"user": "Test"})
|
|
||||||
|
|
||||||
user_creds = UserCreds(password_hash="abc1231234")
|
def test_to_dict_full_creds():
|
||||||
self.assertDictEqual(user_creds.to_dict(), {"password_hash": "abc1231234"})
|
user_creds = UserCreds(username="Test", password_hash="abc1231234")
|
||||||
|
assert user_creds.to_dict() == {"user": "Test", "password_hash": "abc1231234"}
|
||||||
|
|
||||||
user_creds = UserCreds(username="Test", password_hash="abc1231234")
|
|
||||||
self.assertDictEqual(user_creds.to_dict(), {"user": "Test", "password_hash": "abc1231234"})
|
|
||||||
|
|
||||||
def test_to_auth_user(self):
|
def test_to_auth_user_full_credentials():
|
||||||
user_creds = UserCreds(username="Test", password_hash="abc1231234")
|
user_creds = UserCreds(username="Test", password_hash="abc1231234")
|
||||||
auth_user = user_creds.to_auth_user()
|
auth_user = user_creds.to_auth_user()
|
||||||
self.assertEqual(auth_user.id, 1)
|
assert auth_user.id == 1
|
||||||
self.assertEqual(auth_user.username, "Test")
|
assert auth_user.username == "Test"
|
||||||
self.assertEqual(auth_user.secret, "abc1231234")
|
assert auth_user.secret == "abc1231234"
|
||||||
|
|
||||||
user_creds = UserCreds(username="Test")
|
|
||||||
auth_user = user_creds.to_auth_user()
|
|
||||||
self.assertEqual(auth_user.id, 1)
|
|
||||||
self.assertEqual(auth_user.username, "Test")
|
|
||||||
self.assertEqual(auth_user.secret, "")
|
|
||||||
|
|
||||||
user_creds = UserCreds(password_hash="abc1231234")
|
def test_to_auth_user_username_only():
|
||||||
auth_user = user_creds.to_auth_user()
|
user_creds = UserCreds(username="Test")
|
||||||
self.assertEqual(auth_user.id, 1)
|
auth_user = user_creds.to_auth_user()
|
||||||
self.assertEqual(auth_user.username, "")
|
assert auth_user.id == 1
|
||||||
self.assertEqual(auth_user.secret, "abc1231234")
|
assert auth_user.username == "Test"
|
||||||
|
assert auth_user.secret == ""
|
||||||
|
|
Loading…
Reference in New Issue