Files
teng-lin--notebooklm-py/tests/unit/test_auth_instance_invariant.py
wehub-resource-sync 09e9f3545f
Test / Code Quality (push) Has been cancelled
Test / Test (macos-latest, Python 3.10) (push) Has been cancelled
Test / Test (macos-latest, Python 3.11) (push) Has been cancelled
Test / Test (macos-latest, Python 3.12) (push) Has been cancelled
Test / Test (macos-latest, Python 3.13) (push) Has been cancelled
Test / Test (macos-latest, Python 3.14) (push) Has been cancelled
Test / Test (ubuntu-latest, Python 3.10) (push) Has been cancelled
Test / Test (ubuntu-latest, Python 3.11) (push) Has been cancelled
Test / Test (ubuntu-latest, Python 3.12) (push) Has been cancelled
Test / Test (ubuntu-latest, Python 3.13) (push) Has been cancelled
Test / Test (ubuntu-latest, Python 3.14) (push) Has been cancelled
Test / Test (windows-latest, Python 3.10) (push) Has been cancelled
Test / Test (windows-latest, Python 3.11) (push) Has been cancelled
Test / Test (windows-latest, Python 3.12) (push) Has been cancelled
Test / Test (windows-latest, Python 3.13) (push) Has been cancelled
Test / Test (windows-latest, Python 3.14) (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
dependency-audit / pip-audit (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:30:13 +08:00

41 lines
1.2 KiB
Python

"""Auth identity invariants for client-owned composition."""
from __future__ import annotations
import pytest
from notebooklm._request_types import AuthSnapshot
from notebooklm.auth import AuthTokens
from tests._helpers.client_factory import build_client_shell_for_tests
def _make_auth() -> AuthTokens:
return AuthTokens(
cookies={"SID": "x", "__Secure-1PSIDTS": "y"},
csrf_token="csrf",
session_id="sid",
)
@pytest.mark.asyncio
async def test_snapshot_provider_captures_client_auth_by_identity() -> None:
"""Transport snapshots must pass the identical client-owned auth object."""
auth = _make_auth()
client = build_client_shell_for_tests(auth)
captured: dict[str, AuthTokens] = {}
async def snapshot(*, auth: AuthTokens) -> AuthSnapshot:
captured["auth"] = auth
return AuthSnapshot(
csrf_token=auth.csrf_token,
session_id=auth.session_id,
authuser=auth.authuser,
account_email=auth.account_email,
)
client._collaborators.auth_coord.snapshot = snapshot # type: ignore[method-assign]
await client._composed.transport._snapshot_provider()
assert captured["auth"] is client._auth