Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/api/hive_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# json.JSONDecodeError subclass.
_REQUEST_ERRORS = (OSError, RuntimeError, json.JSONDecodeError)

_SSO_ASSIGNMENT = re.compile(r'window\.(\w+)\s*=\s*"([^"]*)"')
# The SSO page has used both `window.Key="value",` and `window.Key = 'value';`.
_SSO_ASSIGNMENT = re.compile(r"""window\.(\w+)\s*=\s*["']([^"']*)["']""")


class HiveApi:
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/test_hive_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,27 @@ def test_successful_parse_returns_login_data(self):
# REGION mirrors UPID
assert result["REGION"] == "eu-west-1_abc"

def test_parses_single_quoted_assignments_with_spaces(self):
"""Parses the SSO page format in use since October 2026."""
api = _make_api()
html_content = (
b"<script>"
b"window.HiveSSOPoolId = 'eu-west-1_abc';\n"
b"window.HiveSSOPublicCognitoClientId = 'client123';"
b"</script>"
)
mock_resp = MagicMock()
mock_resp.content = html_content
mock_resp.status_code = 200

with patch("apyhiveapi.api.hive_api.requests.get", return_value=mock_resp):
result = api.get_login_info()

assert result is not None
assert result["UPID"] == "eu-west-1_abc"
assert result["CLIID"] == "client123"
assert result["REGION"] == "eu-west-1_abc"

def test_os_error_calls_error_and_raises_connection_error(self):
api = _make_api()
with (
Expand Down
Loading