diff options
| author | stuppie | 2026-03-09 18:42:22 -0600 |
|---|---|---|
| committer | stuppie | 2026-03-09 18:42:22 -0600 |
| commit | a68a9eb9873c7502c2b7bddb55c4eb61689a48a2 (patch) | |
| tree | 6a4df8d399e94532dd3938f53f467913f412ce10 /tests/models/network/nmap.py | |
| parent | cf274a5814e02aefc0c9e25f96927b3163a4abaf (diff) | |
| download | generalresearch-a68a9eb9873c7502c2b7bddb55c4eb61689a48a2.tar.gz generalresearch-a68a9eb9873c7502c2b7bddb55c4eb61689a48a2.zip | |
add IPLabel, NmapRun, RDNSResult, ToolRun, model/managers/tests. nmap xml parser. + test. work in progress
Diffstat (limited to 'tests/models/network/nmap.py')
| -rw-r--r-- | tests/models/network/nmap.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/models/network/nmap.py b/tests/models/network/nmap.py new file mode 100644 index 0000000..4fc7014 --- /dev/null +++ b/tests/models/network/nmap.py @@ -0,0 +1,32 @@ +import os + +import pytest + +from generalresearch.models.network.xml_parser import NmapXmlParser + + +@pytest.fixture +def nmap_xml_str(request) -> str: + fp = os.path.join(request.config.rootpath, "data/nmaprun1.xml") + with open(fp, "r") as f: + data = f.read() + return data + + +@pytest.fixture +def nmap_xml_str2(request) -> str: + fp = os.path.join(request.config.rootpath, "data/nmaprun2.xml") + with open(fp, "r") as f: + data = f.read() + return data + + +def test_nmap_xml_parser(nmap_xml_str, nmap_xml_str2): + p = NmapXmlParser() + n = p.parse_xml(nmap_xml_str) + assert n.tcp_open_ports == [61232] + assert len(n.trace.hops) == 18 + + n = p.parse_xml(nmap_xml_str2) + assert n.tcp_open_ports == [22, 80, 9929, 31337] + assert n.trace is None |
