feat(update): integrate managed installs and recoverable in-app updates (#6168)
Add owner-aware Stable and Preview updates with explicit consent, verified release plans, protected process handoff and bounded service recovery. Keep configuration and conversations separate from program rollback. Include the compact About controls, Windows long-path support, native package recovery checks and optional macOS Dock lifecycle integration. Preserve documented guidance for installations owned by other managers. This code integration does not publish packages, enable signing or advance the public update channel. Co-authored-by: chengyongru <61816729+chengyongru@users.noreply.github.com>
This commit is contained in:
1 parent
76da55994b
commit
fbb61a373f
216 files changed
+27948
-1084
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
import time
|
||||
from collections.abc import Callable
|
||||
from types import SimpleNamespace
|
||||
@@ -43,6 +44,7 @@ def _fake_interactive_login(
|
||||
provider,
|
||||
proxy,
|
||||
open_browser,
|
||||
storage,
|
||||
) -> OAuthToken:
|
||||
captured.update(
|
||||
provider=provider,
|
||||
@@ -80,6 +82,7 @@ def test_authorization_url_comes_from_oauth_cli_kit() -> None:
|
||||
assert params["state"]
|
||||
finally:
|
||||
flow.cancel()
|
||||
flow.wait_closed()
|
||||
|
||||
|
||||
def test_local_flow_delegates_browser_and_callback_to_public_oauth_cli_kit(
|
||||
@@ -248,3 +251,41 @@ def test_remote_flow_expires_while_waiting_for_callback(
|
||||
complete_openai_codex_oauth_login(flow)
|
||||
finally:
|
||||
flow.cancel()
|
||||
flow.wait_closed()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("finish", ["cancel", "expiry", "success"])
|
||||
def test_worker_exit_and_credential_commit_are_distinct(monkeypatch, tmp_path, finish):
|
||||
entered, release = threading.Event(), threading.Event()
|
||||
target = tmp_path / "oauth.json"
|
||||
monkeypatch.setenv("OAUTH_CLI_KIT_TOKEN_PATH", str(target))
|
||||
|
||||
def login(*, print_fn, storage, **_kwargs):
|
||||
print_fn(_authorization_url())
|
||||
entered.set()
|
||||
assert release.wait(3)
|
||||
token = OAuthToken(access="fixture-access", refresh="fixture-refresh", expires=123)
|
||||
storage.save(token)
|
||||
return token
|
||||
|
||||
monkeypatch.setattr(codex_oauth, "login_oauth_interactive", login)
|
||||
flow = start_openai_codex_oauth_login(timeout_s=5, open_browser=False)
|
||||
try:
|
||||
assert entered.wait(1)
|
||||
assert flow.has_pending_work
|
||||
if finish == "cancel":
|
||||
flow.cancel()
|
||||
elif finish == "expiry":
|
||||
# Advance the shared clock used by both the flow and its save guard.
|
||||
now = time.monotonic() + 10
|
||||
monkeypatch.setattr(codex_oauth, "time", SimpleNamespace(monotonic=lambda: now))
|
||||
assert flow.has_pending_work
|
||||
assert not target.exists()
|
||||
finally:
|
||||
release.set()
|
||||
flow.wait_closed()
|
||||
assert not flow.has_pending_work
|
||||
assert target.exists() is (finish == "success")
|
||||
if finish != "success":
|
||||
with pytest.raises(OpenAICodexOAuthError):
|
||||
flow.complete()
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import queue
|
||||
import threading
|
||||
@@ -191,6 +192,50 @@ def test_pending_login_accepts_authorization_code_from_remote_browser(
|
||||
assert get_xai_oauth_login_status() == token
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cancel_joins_accepted_callback_request_and_expiry_timer(monkeypatch):
|
||||
entered, release, server_closing = threading.Event(), threading.Event(), threading.Event()
|
||||
monkeypatch.setattr(xai_oauth, "_discover", lambda _: _Discovery(
|
||||
authorization_endpoint="https://auth.x.ai/oauth2/authorize",
|
||||
token_endpoint="https://auth.x.ai/oauth2/token", userinfo_endpoint=None,
|
||||
))
|
||||
callback_page = xai_oauth._callback_page
|
||||
|
||||
def render_callback(*args):
|
||||
entered.set()
|
||||
assert release.wait(3)
|
||||
return callback_page(*args)
|
||||
|
||||
monkeypatch.setattr(xai_oauth, "_callback_page", render_callback)
|
||||
flow = start_xai_oauth_login(timeout_s=5)
|
||||
server_close = flow._server.server_close
|
||||
|
||||
def observed_close():
|
||||
server_closing.set()
|
||||
server_close()
|
||||
|
||||
monkeypatch.setattr(flow._server, "server_close", observed_close)
|
||||
params = parse_qs(urlsplit(flow.authorization_url).query)
|
||||
request = asyncio.create_task(asyncio.to_thread(httpx.get, flow.redirect_uri, params={
|
||||
"code": "fixture-code", "state": params["state"][0],
|
||||
}, trust_env=False))
|
||||
try:
|
||||
assert await asyncio.to_thread(entered.wait, 1)
|
||||
flow.cancel()
|
||||
closing = asyncio.create_task(asyncio.to_thread(flow.wait_closed))
|
||||
assert await asyncio.to_thread(server_closing.wait, 1)
|
||||
assert flow.has_pending_work
|
||||
assert not closing.done()
|
||||
finally:
|
||||
release.set()
|
||||
flow.cancel()
|
||||
await asyncio.to_thread(flow.wait_closed)
|
||||
response = await request
|
||||
await closing
|
||||
assert response.status_code == 200
|
||||
assert not flow.has_pending_work
|
||||
|
||||
|
||||
def test_expired_token_refreshes_once_and_persists_rotated_refresh_token(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path,
|
||||
|
||||
Reference in new issue
Block a user