forked from p15670423/monkey
Tests: Move PowerShell get_credentials() tests
Move the tests for the PowerShell exploiter's get_credentials() function to test_credential_generators.py, since get_credentials() is now contained in credential_generators.py
This commit is contained in:
parent
19c1d5c1ae
commit
b3436d660f
|
@ -0,0 +1,45 @@
|
|||
from infection_monkey.exploit.powershell_utils.auth_options import AuthOptions
|
||||
from infection_monkey.exploit.powershell_utils.credential_generators import get_credentials
|
||||
|
||||
TEST_USERNAMES = ["user1", "user2"]
|
||||
TEST_PASSWORDS = ["p1", "p2"]
|
||||
|
||||
|
||||
def test_get_credentials__empty_windows_true():
|
||||
credentials = get_credentials([], [], True, True)
|
||||
|
||||
assert len(credentials) == 1
|
||||
assert credentials[0] == AuthOptions(username=None, password=None, is_https=False)
|
||||
|
||||
|
||||
def test_get_credentials__empty_windows_false():
|
||||
credentials = get_credentials([], [], False, True)
|
||||
|
||||
assert len(credentials) == 0
|
||||
|
||||
|
||||
def test_get_credentials__username_only_windows_true():
|
||||
credentials = get_credentials(TEST_USERNAMES, [], True, True)
|
||||
|
||||
assert len(credentials) == 5
|
||||
assert AuthOptions(username=TEST_USERNAMES[0], password="", is_https=False) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[1], password="", is_https=False) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[0], password=None, is_https=True) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[1], password=None, is_https=True) in credentials
|
||||
|
||||
|
||||
def test_get_credentials__username_only_windows_false():
|
||||
credentials = get_credentials(TEST_USERNAMES, [], False, True)
|
||||
|
||||
assert len(credentials) == 2
|
||||
assert AuthOptions(username=TEST_USERNAMES[0], password="", is_https=False) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[1], password="", is_https=False) in credentials
|
||||
|
||||
|
||||
def test_get_credentials__username_password_windows_true():
|
||||
credentials = get_credentials(TEST_USERNAMES, TEST_PASSWORDS, True, True)
|
||||
|
||||
assert len(credentials) == 9
|
||||
for user in TEST_USERNAMES:
|
||||
for password in TEST_PASSWORDS:
|
||||
assert AuthOptions(username=user, password=password, is_https=True) in credentials
|
|
@ -1,51 +1,6 @@
|
|||
from infection_monkey.exploit.powershell_utils import utils
|
||||
from infection_monkey.exploit.powershell_utils.auth_options import AuthOptions
|
||||
from infection_monkey.exploit.powershell_utils.credential_generators import get_credentials
|
||||
from infection_monkey.model.host import VictimHost
|
||||
|
||||
TEST_USERNAMES = ["user1", "user2"]
|
||||
TEST_PASSWORDS = ["p1", "p2"]
|
||||
|
||||
|
||||
def test_get_credentials__empty_windows_true():
|
||||
credentials = get_credentials([], [], True, True)
|
||||
|
||||
assert len(credentials) == 1
|
||||
assert credentials[0] == AuthOptions(username=None, password=None, is_https=False)
|
||||
|
||||
|
||||
def test_get_credentials__empty_windows_false():
|
||||
credentials = get_credentials([], [], False, True)
|
||||
|
||||
assert len(credentials) == 0
|
||||
|
||||
|
||||
def test_get_credentials__username_only_windows_true():
|
||||
credentials = get_credentials(TEST_USERNAMES, [], True, True)
|
||||
|
||||
assert len(credentials) == 5
|
||||
assert AuthOptions(username=TEST_USERNAMES[0], password="", is_https=False) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[1], password="", is_https=False) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[0], password=None, is_https=True) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[1], password=None, is_https=True) in credentials
|
||||
|
||||
|
||||
def test_get_credentials__username_only_windows_false():
|
||||
credentials = get_credentials(TEST_USERNAMES, [], False, True)
|
||||
|
||||
assert len(credentials) == 2
|
||||
assert AuthOptions(username=TEST_USERNAMES[0], password="", is_https=False) in credentials
|
||||
assert AuthOptions(username=TEST_USERNAMES[1], password="", is_https=False) in credentials
|
||||
|
||||
|
||||
def test_get_credentials__username_password_windows_true():
|
||||
credentials = get_credentials(TEST_USERNAMES, TEST_PASSWORDS, True, True)
|
||||
|
||||
assert len(credentials) == 9
|
||||
for user in TEST_USERNAMES:
|
||||
for password in TEST_PASSWORDS:
|
||||
assert AuthOptions(username=user, password=password, is_https=True) in credentials
|
||||
|
||||
|
||||
def test_build_monkey_execution_command():
|
||||
host = VictimHost("127.0.0.1")
|
||||
|
|
Loading…
Reference in New Issue