fix: stop scoring every HTTPS port as a BMC; name the missing license
netOrk's discovery took six switches for BMCs: the PortSpec for 443 added 5 points to every device with a web UI, and nothing else scored them. The port now carries no weight. The real BMC, a Supermicro X10DRL-i, was not recognised at all. Its web UI (ATEN firmware) gets a rule, as do iDRAC and iLO; discovery fetches those landing pages today. A rule for a Redfish error body covers the service root once discovery reads it. That board refuses Redfish without a Supermicro license, even the service root (403 OemLicenseNotPassed, "SUM DCMS OOB"). The library reports only the status, so open() reads the error body once more and raises RedfishLicenseError naming the licenses. Release 0.1.1.
This commit is contained in:
1 parent
c7d947a870
commit
93bbc63f3d
10 files changed
+183
-8
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""What netOrk's discovery scores the driver on, checked against recorded pages.
|
||||
|
||||
netOrk lowercases the page (title, Server header, body) and matches each rule's
|
||||
pattern as a substring; a port that answers adds its PortSpec weight.
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from napalm_redfish import RedfishDriver
|
||||
|
||||
X10 = Path(__file__).parent / "fixtures" / "supermicro-x10drl-i-3.91"
|
||||
|
||||
|
||||
def _score(text: str) -> float:
|
||||
text = " ".join(text.lower().split())
|
||||
return sum(rule.weight for rule in RedfishDriver.HTTP_FINGERPRINT if rule.pattern in text)
|
||||
|
||||
|
||||
def test_an_open_https_port_proves_nothing():
|
||||
# Every switch with a web UI answers on 443; the port alone made six of
|
||||
# them look like BMCs.
|
||||
assert [spec.weight for spec in RedfishDriver.PORT_SPECS if spec.port == 443] == [0.0]
|
||||
|
||||
|
||||
def test_service_root_is_still_probed():
|
||||
assert any("/redfish/v1/" in spec.paths for spec in RedfishDriver.PORT_SPECS)
|
||||
|
||||
|
||||
def test_supermicro_landing_page_is_recognised():
|
||||
assert _score((X10 / "landing_page.html").read_text()) >= 6.0
|
||||
|
||||
|
||||
def test_redfish_error_body_is_recognised():
|
||||
# An unlicensed X10 refuses even the service root, but the refusal is
|
||||
# unmistakably Redfish.
|
||||
assert _score(json.dumps(json.loads((X10 / "service_root_403.json").read_text()))) >= 6.0
|
||||
|
||||
|
||||
def test_idrac_and_ilo_landing_pages_are_recognised():
|
||||
assert _score("<title>iDRAC9 - Login</title>") >= 6.0
|
||||
assert _score("<title>iLO 5</title> HPE Integrated Lights-Out") >= 6.0
|
||||
|
||||
|
||||
def test_a_switch_page_scores_nothing():
|
||||
page = '<html><head><title>Loading...</title></head><body>Web Switch</body></html>'
|
||||
assert _score(page) == 0.0
|
||||
Reference in new issue
Block a user