UT: Fix annoying pytest warning regarting TestAuthenticationError
This commit is contained in:
parent
e60297dff1
commit
dc3adc9d8b
|
@ -32,7 +32,7 @@ Config = namedtuple(
|
|||
)
|
||||
|
||||
|
||||
class TestAuthenticationError(Exception):
|
||||
class AuthenticationErrorForTests(Exception):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ def powershell_exploiter(monkeypatch):
|
|||
DROPPER_TARGET_PATH_64,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(powershell, "AuthenticationError", TestAuthenticationError)
|
||||
monkeypatch.setattr(powershell, "AuthenticationError", AuthenticationErrorForTests)
|
||||
monkeypatch.setattr(powershell, "is_windows_os", lambda: True)
|
||||
# It's regrettable to mock out a private method on the PowerShellExploiter instance object, but
|
||||
# it's necessary to avoid having to deal with the monkeyfs
|
||||
|
@ -69,7 +69,7 @@ def test_powershell_disabled(monkeypatch, powershell_exploiter):
|
|||
def test_powershell_http(monkeypatch, powershell_exploiter):
|
||||
def allow_http(_, credentials: Credentials, auth_options: AuthOptions):
|
||||
if not auth_options.ssl:
|
||||
raise TestAuthenticationError
|
||||
raise AuthenticationErrorForTests
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
|
@ -84,7 +84,7 @@ def test_powershell_http(monkeypatch, powershell_exploiter):
|
|||
def test_powershell_https(monkeypatch, powershell_exploiter):
|
||||
def allow_https(_, credentials: Credentials, auth_options: AuthOptions):
|
||||
if auth_options.ssl:
|
||||
raise TestAuthenticationError
|
||||
raise AuthenticationErrorForTests
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
|
@ -98,7 +98,7 @@ def test_powershell_https(monkeypatch, powershell_exploiter):
|
|||
|
||||
|
||||
def test_no_valid_credentials(monkeypatch, powershell_exploiter):
|
||||
mock_powershell_client = MagicMock(side_effect=TestAuthenticationError)
|
||||
mock_powershell_client = MagicMock(side_effect=AuthenticationErrorForTests)
|
||||
monkeypatch.setattr(powershell, "PowerShellClient", mock_powershell_client)
|
||||
|
||||
success = powershell_exploiter.exploit_host()
|
||||
|
@ -110,7 +110,7 @@ def authenticate(mock_client):
|
|||
if credentials.username == "user1" and credentials.secret == "pass2":
|
||||
return mock_client
|
||||
else:
|
||||
raise TestAuthenticationError("Invalid credentials")
|
||||
raise AuthenticationErrorForTests("Invalid credentials")
|
||||
|
||||
return inner
|
||||
|
||||
|
|
Loading…
Reference in New Issue