forked from p15670423/monkey
Tests: Move host fixtures to conftest.py
This commit is contained in:
parent
3d7586f713
commit
385449101d
|
@ -19,3 +19,36 @@ def patch_win32api_get_user_name(local_user):
|
||||||
win32api.NameSamCompatible = None
|
win32api.NameSamCompatible = None
|
||||||
|
|
||||||
sys.modules["win32api"] = win32api
|
sys.modules["win32api"] = win32api
|
||||||
|
|
||||||
|
|
||||||
|
def _create_host(http_enabled, https_enabled):
|
||||||
|
host = MagicMock()
|
||||||
|
host.services = {}
|
||||||
|
|
||||||
|
if http_enabled:
|
||||||
|
host.services["tcp-5985"] = {}
|
||||||
|
|
||||||
|
if https_enabled:
|
||||||
|
host.services["tcp-5986"] = {}
|
||||||
|
|
||||||
|
return host
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def https_only_host():
|
||||||
|
return _create_host(False, True)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def http_only_host():
|
||||||
|
return _create_host(True, False)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def http_and_https_both_enabled_host():
|
||||||
|
return _create_host(True, True)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def powershell_disabled_host():
|
||||||
|
return _create_host(False, False)
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
from unittest.mock import MagicMock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
# from infection_monkey.exploit.powershell_utils.auth_options import AuthOptions
|
# from infection_monkey.exploit.powershell_utils.auth_options import AuthOptions
|
||||||
from infection_monkey.exploit.powershell_utils.auth_options import (
|
from infection_monkey.exploit.powershell_utils.auth_options import (
|
||||||
AUTH_BASIC,
|
AUTH_BASIC,
|
||||||
|
@ -20,39 +16,6 @@ CREDENTIALS_LM_HASH = Credentials("user4", "LM_HASH:NONE", SecretType.LM_HASH)
|
||||||
CREDENTIALS_NT_HASH = Credentials("user5", "NONE:NT_HASH", SecretType.NT_HASH)
|
CREDENTIALS_NT_HASH = Credentials("user5", "NONE:NT_HASH", SecretType.NT_HASH)
|
||||||
|
|
||||||
|
|
||||||
def _create_host(http_enabled, https_enabled):
|
|
||||||
host = MagicMock()
|
|
||||||
host.services = {}
|
|
||||||
|
|
||||||
if http_enabled:
|
|
||||||
host.services["tcp-5985"] = {}
|
|
||||||
|
|
||||||
if https_enabled:
|
|
||||||
host.services["tcp-5986"] = {}
|
|
||||||
|
|
||||||
return host
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def https_only_host():
|
|
||||||
return _create_host(False, True)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def http_only_host():
|
|
||||||
return _create_host(True, False)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def http_and_https_both_enabled_host():
|
|
||||||
return _create_host(True, True)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def powershell_disabled_host():
|
|
||||||
return _create_host(False, False)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_auth_options__ssl_false_with_no_open_ports(powershell_disabled_host):
|
def test_get_auth_options__ssl_false_with_no_open_ports(powershell_disabled_host):
|
||||||
auth_options = get_auth_options(CREDENTIALS_WITH_PASSWORD, powershell_disabled_host)
|
auth_options = get_auth_options(CREDENTIALS_WITH_PASSWORD, powershell_disabled_host)
|
||||||
assert auth_options.ssl is False
|
assert auth_options.ssl is False
|
||||||
|
|
Loading…
Reference in New Issue