python-xiaobiu 0.2.3__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/CHANGELOG.md +17 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/PKG-INFO +14 -1
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/README.md +13 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/pyproject.toml +1 -1
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/__init__.py +8 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/ac_status.py +33 -6
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/client.py +9 -2
- python_xiaobiu-0.2.4/src/xiaobiu/session.py +67 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_ac_control.py +63 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_ac_status.py +29 -4
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/uv.lock +2 -2
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/.github/workflows/python-publish.yml +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/.gitignore +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-design/bdd-specs.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/_index.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-001-ac-enums-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-001-ac-enums-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-002-ac-cmd-mappings-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-002-ac-cmd-mappings-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-003-ac-app-oper-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-003-ac-app-oper-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-004-ac-highlevel-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-004-ac-highlevel-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-005-ac-panel-template-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-005-ac-panel-template-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-006-ac-timers-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-006-ac-timers-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-007-ac-state-hvac-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-007-ac-state-hvac-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-008-cli-ac-control-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-008-cli-ac-control-test.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/task-009-docs-readme-impl.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-02-ac-control-align-ha-design/bdd-specs.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-02-ac-control-align-ha-plan/_index.md +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/ac_control.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/app_api.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/captcha_bridge.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/cli.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/crypto.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/exceptions.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/har_templates.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/models.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/parsers.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/persistence.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/src/xiaobiu/sms_login.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/__init__.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_app_api.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_captcha_bridge.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_cli.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_client.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_crypto.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_har_templates.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_models.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_parsers.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_persistence.py +0 -0
- {python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/tests/test_sms_login.py +0 -0
|
@@ -4,6 +4,23 @@ All notable changes to `python-xiaobiu` are documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.2.4] - 2026-11-25
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- `client.silent_login()` and the `xiaobiu.session` module: renew the
|
|
11
|
+
passport session with the cookies already stored, exactly like
|
|
12
|
+
`AutoLoginPresenter.autoLogin` does — the app re-posts
|
|
13
|
+
`https://passport.suning.com/ids/login` with no credentials and
|
|
14
|
+
`service=https://shcss.suning.com/shcss-web/`, which yields a fresh
|
|
15
|
+
`?ticket=ST...` when the session is still good.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- `keep_alive()` now renews the ticket first and only then calls
|
|
19
|
+
`queryMemberBaseInfo.do`, so a stale ticket is renewed silently instead
|
|
20
|
+
of surfacing as an authentication failure.
|
|
21
|
+
- `queryMemberBaseInfo.do` tries the silent renewal before the service
|
|
22
|
+
bootstrap when it is redirected to the login page.
|
|
23
|
+
|
|
7
24
|
## [0.2.3] - 2026-11-25
|
|
8
25
|
|
|
9
26
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-xiaobiu
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Suning biu smart home SMS login and session client
|
|
5
5
|
Project-URL: Homepage, https://github.com/FaintGhost/python-xiaobiu
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/FaintGhost/python-xiaobiu/issues
|
|
@@ -112,6 +112,19 @@ client.list_device_timers(family_id=37790, device_id="...")
|
|
|
112
112
|
client.get_device_panel_template(family_id=37790, device_id="...")
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
### Session renewal
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
client.silent_login() # renew the passport ticket from the stored cookies
|
|
119
|
+
client.keep_alive() # renew, then confirm the API still answers
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Mirrors `AutoLoginPresenter.autoLogin`: the app re-posts
|
|
123
|
+
`https://passport.suning.com/ids/login` with **no credentials** and
|
|
124
|
+
`service=https://shcss.suning.com/shcss-web/`. A live session answers
|
|
125
|
+
`ok` and redirects to `?ticket=ST...`; an expired one answers the login
|
|
126
|
+
page JSON, which raises `AuthenticationError`.
|
|
127
|
+
|
|
115
128
|
### Timers
|
|
116
129
|
|
|
117
130
|
```python
|
|
@@ -91,6 +91,19 @@ client.list_device_timers(family_id=37790, device_id="...")
|
|
|
91
91
|
client.get_device_panel_template(family_id=37790, device_id="...")
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
### Session renewal
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
client.silent_login() # renew the passport ticket from the stored cookies
|
|
98
|
+
client.keep_alive() # renew, then confirm the API still answers
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Mirrors `AutoLoginPresenter.autoLogin`: the app re-posts
|
|
102
|
+
`https://passport.suning.com/ids/login` with **no credentials** and
|
|
103
|
+
`service=https://shcss.suning.com/shcss-web/`. A live session answers
|
|
104
|
+
`ok` and redirects to `?ticket=ST...`; an expired one answers the login
|
|
105
|
+
page JSON, which raises `AuthenticationError`.
|
|
106
|
+
|
|
94
107
|
### Timers
|
|
95
108
|
|
|
96
109
|
```python
|
|
@@ -7,6 +7,11 @@ from .client import (
|
|
|
7
7
|
main,
|
|
8
8
|
parse_jsonp_or_json,
|
|
9
9
|
)
|
|
10
|
+
from .session import (
|
|
11
|
+
SILENT_LOGIN_SERVICE,
|
|
12
|
+
SILENT_LOGIN_URL,
|
|
13
|
+
silent_login,
|
|
14
|
+
)
|
|
10
15
|
from .models import (
|
|
11
16
|
AirConditionerStatus,
|
|
12
17
|
AuthState,
|
|
@@ -42,7 +47,10 @@ __all__ = [
|
|
|
42
47
|
"SignedRequestTemplate",
|
|
43
48
|
"SuningError",
|
|
44
49
|
"SuningSmartHomeClient",
|
|
50
|
+
"SILENT_LOGIN_SERVICE",
|
|
51
|
+
"SILENT_LOGIN_URL",
|
|
45
52
|
"SwingMode",
|
|
53
|
+
"silent_login",
|
|
46
54
|
"Timer",
|
|
47
55
|
"main",
|
|
48
56
|
"parse_jsonp_or_json",
|
|
@@ -18,6 +18,7 @@ from .app_api import (
|
|
|
18
18
|
decode_app_api_response,
|
|
19
19
|
is_login_redirect,
|
|
20
20
|
)
|
|
21
|
+
from . import session
|
|
21
22
|
from .exceptions import AuthenticationError, SuningError
|
|
22
23
|
from .models import (
|
|
23
24
|
AirConditionerStatus,
|
|
@@ -412,20 +413,38 @@ def bootstrap_service(client: Any, service_name: str) -> dict[str, Any]:
|
|
|
412
413
|
|
|
413
414
|
|
|
414
415
|
def query_member_base_info(client: Any) -> dict[str, Any]:
|
|
416
|
+
"""Read the member profile, following the passport ticket redirect.
|
|
417
|
+
|
|
418
|
+
The endpoint always answers ``302`` to passport with a per-call
|
|
419
|
+
``service`` parameter; following it makes passport mint a service
|
|
420
|
+
ticket from the ``TGC`` cookie and hand control back with JSON. Only a
|
|
421
|
+
response that *ends* on the login page means the session is gone.
|
|
422
|
+
"""
|
|
423
|
+
|
|
415
424
|
response = client.session.get(
|
|
416
425
|
MEMBER_BASE_INFO_URL,
|
|
417
426
|
timeout=client.timeout,
|
|
418
|
-
allow_redirects=
|
|
427
|
+
allow_redirects=True,
|
|
419
428
|
)
|
|
420
|
-
if
|
|
421
|
-
|
|
429
|
+
if "/ids/login" in str(response.url):
|
|
430
|
+
try:
|
|
431
|
+
session.silent_login(client)
|
|
432
|
+
except SuningError:
|
|
433
|
+
bootstrap_service(client, "shcss")
|
|
422
434
|
response = client.session.get(
|
|
423
435
|
MEMBER_BASE_INFO_URL,
|
|
424
436
|
timeout=client.timeout,
|
|
425
|
-
allow_redirects=
|
|
437
|
+
allow_redirects=True,
|
|
426
438
|
)
|
|
439
|
+
if "/ids/login" in str(response.url):
|
|
440
|
+
raise AuthenticationError("member base info redirected to login")
|
|
427
441
|
response.raise_for_status()
|
|
428
|
-
|
|
442
|
+
try:
|
|
443
|
+
data = response.json()
|
|
444
|
+
except ValueError as error:
|
|
445
|
+
raise AuthenticationError(
|
|
446
|
+
"member base info returned a non-JSON body"
|
|
447
|
+
) from error
|
|
429
448
|
if data.get("code") != "0":
|
|
430
449
|
raise AuthenticationError(data.get("desc") or "member base info request failed")
|
|
431
450
|
client._touch_state()
|
|
@@ -433,8 +452,16 @@ def query_member_base_info(client: Any) -> dict[str, Any]:
|
|
|
433
452
|
|
|
434
453
|
|
|
435
454
|
def keep_alive(client: Any) -> dict[str, Any]:
|
|
455
|
+
"""Renew the passport ticket first, then confirm the API accepts it.
|
|
456
|
+
|
|
457
|
+
The app re-posts the login form with no credentials on start-up
|
|
458
|
+
(``AutoLoginPresenter.autoLogin``) so the ticket never goes stale; doing
|
|
459
|
+
the same here means a quiet renewal instead of a loud reauth prompt.
|
|
460
|
+
"""
|
|
461
|
+
|
|
462
|
+
renewal = session.silent_login(client)
|
|
436
463
|
member_info = query_member_base_info(client)
|
|
437
|
-
return {"member": member_info}
|
|
464
|
+
return {"renewal": renewal, "member": member_info}
|
|
438
465
|
|
|
439
466
|
|
|
440
467
|
__all__ = [
|
|
@@ -26,6 +26,7 @@ from requests.cookies import create_cookie
|
|
|
26
26
|
|
|
27
27
|
from . import (
|
|
28
28
|
ac_control,
|
|
29
|
+
session,
|
|
29
30
|
ac_status,
|
|
30
31
|
app_api,
|
|
31
32
|
exceptions,
|
|
@@ -296,9 +297,15 @@ class SuningSmartHomeClient:
|
|
|
296
297
|
def query_member_base_info(self) -> dict[str, Any]:
|
|
297
298
|
return ac_status.query_member_base_info(self)
|
|
298
299
|
|
|
300
|
+
def silent_login(self) -> dict[str, Any]:
|
|
301
|
+
"""Renew the passport ticket using the cookies already stored."""
|
|
302
|
+
|
|
303
|
+
return session.silent_login(self)
|
|
304
|
+
|
|
299
305
|
def keep_alive(self) -> dict[str, Any]:
|
|
300
|
-
|
|
301
|
-
|
|
306
|
+
"""Renew the ticket and confirm the API still accepts the session."""
|
|
307
|
+
|
|
308
|
+
return ac_status.keep_alive(self)
|
|
302
309
|
|
|
303
310
|
# ------------------------------------------------------------------
|
|
304
311
|
# app-api plumbing (kept as thin forwards so the legacy
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Session renewal that mirrors the app's silent login.
|
|
2
|
+
|
|
3
|
+
``AutoLoginPresenter.autoLogin`` posts the passport login form with no
|
|
4
|
+
credentials at all: the existing cookies are what identifies the user, and
|
|
5
|
+
the ``service`` parameter decides which site's ticket passport mints. A
|
|
6
|
+
successful call answers ``ok`` and redirects to ``<service>?ticket=ST...``;
|
|
7
|
+
an expired session answers the login-page JSON instead.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
from .exceptions import AuthenticationError, SuningError
|
|
15
|
+
|
|
16
|
+
SILENT_LOGIN_URL = "https://passport.suning.com/ids/login"
|
|
17
|
+
SILENT_LOGIN_SERVICE = "https://shcss.suning.com/shcss-web/"
|
|
18
|
+
SILENT_LOGIN_THEME = "zn"
|
|
19
|
+
SILENT_LOGIN_CHANNEL = "MOBILE"
|
|
20
|
+
SILENT_LOGIN_REMEMBER_ME_TYPE = "app"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def build_silent_login_payload(client: Any) -> dict[str, str]:
|
|
24
|
+
"""Form fields ``autoLogin`` sends; credentials are deliberately absent."""
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
"rememberMe": "true",
|
|
28
|
+
"rememberMeType": SILENT_LOGIN_REMEMBER_ME_TYPE,
|
|
29
|
+
"service": SILENT_LOGIN_SERVICE,
|
|
30
|
+
"dfpToken": str(getattr(client.state, "dfp_token", "") or ""),
|
|
31
|
+
"loginTheme": SILENT_LOGIN_THEME,
|
|
32
|
+
"loginChannel": SILENT_LOGIN_CHANNEL,
|
|
33
|
+
"terminal": SILENT_LOGIN_CHANNEL,
|
|
34
|
+
"jsonViewType": "true",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def silent_login(client: Any) -> dict[str, Any]:
|
|
39
|
+
"""Renew the session with the cookies already in the session jar."""
|
|
40
|
+
|
|
41
|
+
response = client.session.post(
|
|
42
|
+
SILENT_LOGIN_URL,
|
|
43
|
+
data=build_silent_login_payload(client),
|
|
44
|
+
timeout=client.timeout,
|
|
45
|
+
allow_redirects=True,
|
|
46
|
+
)
|
|
47
|
+
body = (response.text or "").strip()
|
|
48
|
+
ticket = "ticket=ST" in str(response.url)
|
|
49
|
+
if ticket or body.lower() == "ok":
|
|
50
|
+
client._touch_state()
|
|
51
|
+
return {
|
|
52
|
+
"renewed": True,
|
|
53
|
+
"final_url": response.url,
|
|
54
|
+
"body": body[:120],
|
|
55
|
+
}
|
|
56
|
+
if "loginPage" in body or '"res_code":-1' in body:
|
|
57
|
+
raise AuthenticationError("静默登录失败:会话已失效,请重新登录")
|
|
58
|
+
raise SuningError(f"静默登录返回了无法识别的响应: {body[:120]}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
"SILENT_LOGIN_CHANNEL",
|
|
63
|
+
"SILENT_LOGIN_SERVICE",
|
|
64
|
+
"SILENT_LOGIN_URL",
|
|
65
|
+
"build_silent_login_payload",
|
|
66
|
+
"silent_login",
|
|
67
|
+
]
|
|
@@ -871,3 +871,66 @@ def test_set_device_timer_body_and_enabled_flag() -> None:
|
|
|
871
871
|
disabled = json.loads(sent[1])
|
|
872
872
|
assert disabled["timer"].startswith("F,")
|
|
873
873
|
assert json.loads(disabled["cmd"]) == {"C_POWER": "0"}
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
def test_silent_login_renews_with_stored_cookies() -> None:
|
|
877
|
+
"""No credentials are sent: the cookie jar and ``service`` do the work."""
|
|
878
|
+
|
|
879
|
+
from xiaobiu import session as session_module
|
|
880
|
+
|
|
881
|
+
sent: list[dict[str, str]] = []
|
|
882
|
+
|
|
883
|
+
class StubResponse:
|
|
884
|
+
url = "https://shcss.suning.com/shcss-web/?ticket=ST123"
|
|
885
|
+
text = "ok"
|
|
886
|
+
|
|
887
|
+
class StubState:
|
|
888
|
+
dfp_token = "dfp-abc"
|
|
889
|
+
|
|
890
|
+
class StubClient:
|
|
891
|
+
timeout = 5
|
|
892
|
+
state = StubState()
|
|
893
|
+
|
|
894
|
+
def _touch_state(self) -> None:
|
|
895
|
+
pass
|
|
896
|
+
|
|
897
|
+
class _Session:
|
|
898
|
+
def post(self, url, *, data, timeout, allow_redirects):
|
|
899
|
+
assert url == session_module.SILENT_LOGIN_URL
|
|
900
|
+
sent.append(dict(data))
|
|
901
|
+
return StubResponse()
|
|
902
|
+
|
|
903
|
+
session = _Session()
|
|
904
|
+
|
|
905
|
+
result = session_module.silent_login(StubClient())
|
|
906
|
+
assert result["renewed"] is True
|
|
907
|
+
payload = sent[0]
|
|
908
|
+
assert payload["service"] == session_module.SILENT_LOGIN_SERVICE
|
|
909
|
+
assert payload["rememberMe"] == "true"
|
|
910
|
+
assert payload["dfpToken"] == "dfp-abc"
|
|
911
|
+
assert "username" not in payload
|
|
912
|
+
assert "password2" not in payload
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
def test_silent_login_reports_expired_session() -> None:
|
|
916
|
+
from xiaobiu import session as session_module
|
|
917
|
+
|
|
918
|
+
class StubResponse:
|
|
919
|
+
url = "https://passport.suning.com/ids/login"
|
|
920
|
+
text = '{"res_message":"loginPage","res_code":-1}'
|
|
921
|
+
|
|
922
|
+
class StubClient:
|
|
923
|
+
timeout = 5
|
|
924
|
+
state = type("S", (), {"dfp_token": ""})()
|
|
925
|
+
|
|
926
|
+
def _touch_state(self) -> None:
|
|
927
|
+
pass
|
|
928
|
+
|
|
929
|
+
class _Session:
|
|
930
|
+
def post(self, *_args, **_kwargs):
|
|
931
|
+
return StubResponse()
|
|
932
|
+
|
|
933
|
+
session = _Session()
|
|
934
|
+
|
|
935
|
+
with pytest.raises(session_module.AuthenticationError):
|
|
936
|
+
session_module.silent_login(StubClient())
|
|
@@ -391,20 +391,45 @@ def test_list_family_infos_parses_expected_payload_shape(monkeypatch) -> None:
|
|
|
391
391
|
|
|
392
392
|
|
|
393
393
|
|
|
394
|
-
def
|
|
394
|
+
def test_keep_alive_renews_then_queries_member_info(monkeypatch) -> None:
|
|
395
|
+
"""The app renews the ticket on start-up, so keep_alive does too."""
|
|
396
|
+
|
|
395
397
|
client = SuningSmartHomeClient()
|
|
396
398
|
member_payload = {"code": "0", "desc": "SUCCESS"}
|
|
399
|
+
renewal_payload = {"renewed": True, "final_url": "https://x/?ticket=ST1", "body": "ok"}
|
|
400
|
+
|
|
401
|
+
calls: list[str] = []
|
|
402
|
+
|
|
403
|
+
# ac_status.keep_alive() reaches for the module-level helpers, not the
|
|
404
|
+
# client methods, so patch those.
|
|
405
|
+
from xiaobiu import ac_status as ac_status_module
|
|
406
|
+
|
|
407
|
+
def fake_silent_login(_client):
|
|
408
|
+
calls.append("renew")
|
|
409
|
+
return renewal_payload
|
|
410
|
+
|
|
411
|
+
def fake_member_info(_client):
|
|
412
|
+
calls.append("member")
|
|
413
|
+
return member_payload
|
|
397
414
|
|
|
398
|
-
monkeypatch.setattr(
|
|
415
|
+
monkeypatch.setattr(
|
|
416
|
+
ac_status_module.session, "silent_login", fake_silent_login
|
|
417
|
+
)
|
|
418
|
+
monkeypatch.setattr(
|
|
419
|
+
ac_status_module, "query_member_base_info", fake_member_info
|
|
420
|
+
)
|
|
399
421
|
monkeypatch.setattr(
|
|
400
422
|
client,
|
|
401
423
|
"list_families",
|
|
402
|
-
lambda: (_ for _ in ()).throw(
|
|
424
|
+
lambda: (_ for _ in ()).throw(
|
|
425
|
+
AssertionError("keep_alive should not call list_families")
|
|
426
|
+
),
|
|
403
427
|
)
|
|
404
428
|
|
|
405
429
|
payload = client.keep_alive()
|
|
406
430
|
|
|
407
|
-
assert
|
|
431
|
+
assert calls == ["renew", "member"]
|
|
432
|
+
assert payload == {"renewal": renewal_payload, "member": member_payload}
|
|
408
433
|
|
|
409
434
|
|
|
410
435
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
version = 1
|
|
2
|
-
revision =
|
|
2
|
+
revision = 5
|
|
3
3
|
requires-python = ">=3.14"
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
@@ -293,7 +293,7 @@ wheels = [
|
|
|
293
293
|
|
|
294
294
|
[[package]]
|
|
295
295
|
name = "python-xiaobiu"
|
|
296
|
-
version = "0.2.
|
|
296
|
+
version = "0.2.4"
|
|
297
297
|
source = { editable = "." }
|
|
298
298
|
dependencies = [
|
|
299
299
|
{ name = "cryptography" },
|
|
File without changes
|
|
File without changes
|
{python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-design/bdd-specs.md
RENAMED
|
File without changes
|
{python_xiaobiu-0.2.3 → python_xiaobiu-0.2.4}/docs/plans/2026-06-01-ac-control-plan/_index.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|