Modify unit tests

This commit is contained in:
Shreya 2021-02-23 12:57:50 +05:30
parent a2c11759a4
commit 353e9844dc
1 changed files with 14 additions and 10 deletions

View File

@ -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 == ""