forked from p34709852/monkey
Modify unit tests
This commit is contained in:
parent
a2c11759a4
commit
353e9844dc
|
@ -15,13 +15,18 @@ def host():
|
|||
return VictimHost(IP, DOMAIN_NAME)
|
||||
|
||||
|
||||
def _get_stub_queryIPForName(netbios_names):
|
||||
def stub_queryIPForName(*args, **kwargs):
|
||||
return netbios_names
|
||||
return stub_queryIPForName
|
||||
|
||||
|
||||
def test_get_dc_details_multiple_netbios_names(host, monkeypatch):
|
||||
def mock_queryIPForName(*args, **kwargs):
|
||||
return NETBIOS_NAMES
|
||||
|
||||
monkeypatch.setattr(NetBIOS, "queryIPForName", mock_queryIPForName)
|
||||
|
||||
NETBIOS_NAMES = ["Name1", "Name2", "Name3"]
|
||||
|
||||
stub_queryIPForName = _get_stub_queryIPForName(NETBIOS_NAMES)
|
||||
monkeypatch.setattr(NetBIOS, "queryIPForName", stub_queryIPForName)
|
||||
|
||||
dc_ip, dc_name, dc_handle = get_dc_details(host)
|
||||
assert dc_ip == IP
|
||||
assert dc_name == NETBIOS_NAMES[0]
|
||||
|
@ -29,12 +34,11 @@ def test_get_dc_details_multiple_netbios_names(host, monkeypatch):
|
|||
|
||||
|
||||
def test_get_dc_details_no_netbios_names(host, monkeypatch):
|
||||
def mock_queryIPForName(*args, **kwargs):
|
||||
return NETBIOS_NAMES
|
||||
|
||||
monkeypatch.setattr(NetBIOS, "queryIPForName", mock_queryIPForName)
|
||||
|
||||
NETBIOS_NAMES = []
|
||||
|
||||
stub_queryIPForName = _get_stub_queryIPForName(NETBIOS_NAMES)
|
||||
monkeypatch.setattr(NetBIOS, "queryIPForName", stub_queryIPForName)
|
||||
|
||||
dc_ip, dc_name, dc_handle = get_dc_details(host)
|
||||
assert dc_ip == IP
|
||||
assert dc_name == ""
|
||||
|
|
Loading…
Reference in New Issue