diff --git a/src/api/hive_api.py b/src/api/hive_api.py index 0bf1ba76..cf052d53 100644 --- a/src/api/hive_api.py +++ b/src/api/hive_api.py @@ -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: diff --git a/tests/unit/test_hive_api.py b/tests/unit/test_hive_api.py index 4511c104..616f7e26 100644 --- a/tests/unit/test_hive_api.py +++ b/tests/unit/test_hive_api.py @@ -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"" + ) + 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 (