Skip to content

Commit 82a158a

Browse files
committed
fix: accept valid CM3000 status page with redirect markers
1 parent 6637533 commit 82a158a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

app/drivers/cm3000.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,20 @@ def _ensure_status_page(html: str) -> None:
197197
if not html:
198198
raise RuntimeError("CM3000 returned an empty status page")
199199

200+
has_sys_info = _RE_SYS_INFO.search(html) is not None
201+
has_channel_data = any(
202+
regex.search(html) for regex in (_RE_DS_QAM, _RE_US_ATDMA, _RE_DS_OFDM, _RE_US_OFDMA)
203+
)
204+
if has_sys_info and has_channel_data:
205+
return
206+
200207
lower_html = html.lower()
201208
if any(marker in lower_html for marker in _LOGIN_MARKERS):
202209
raise RuntimeError(
203210
"CM3000 authentication failed: modem returned a login page instead "
204211
"of DocsisStatus.htm after authentication"
205212
)
206213

207-
has_sys_info = _RE_SYS_INFO.search(html) is not None
208-
has_channel_data = any(
209-
regex.search(html) for regex in (_RE_DS_QAM, _RE_US_ATDMA, _RE_DS_OFDM, _RE_US_OFDMA)
210-
)
211214
if not has_sys_info or not has_channel_data:
212215
raise RuntimeError(
213216
"CM3000 status page did not contain the expected DOCSIS data blocks"

tests/test_cm3000_driver.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,21 @@ def test_login_rejects_login_page_false_positive(self, driver):
273273
with pytest.raises(RuntimeError, match="returned a login page"):
274274
driver.login()
275275

276+
def test_login_accepts_status_page_even_with_login_markers(self, driver):
277+
mock_response = MagicMock()
278+
mock_response.raise_for_status = MagicMock()
279+
mock_response.text = """
280+
<script>
281+
if (sessionStorage.getItem('PrivateKey') === null) {
282+
window.location.replace('../Login.htm');
283+
}
284+
</script>
285+
""" + STATUS_HTML
286+
287+
with patch.object(driver._session, "get", return_value=mock_response):
288+
driver.login()
289+
assert driver._status_html == mock_response.text
290+
276291

277292
# -- DOCSIS data: structure --
278293

0 commit comments

Comments
 (0)