fix(feishu): use /page/cli verification URL for QR onboarding

Co-authored-by: HammerHound AI <26013314+hammerhoundai@users.noreply.github.com>
This commit is contained in:
ubuntuandHammerHound AI authored and Xubin Ren committed 2026-09-15 14:02:29 +08:00
1 parent 0afebd4747
commit 1fd0cca7e2
2 files changed
+51

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
"""Feishu/Lark QR onboarding: verification URL handling."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from nanobot.channels.feishu import runtime as feishu_runtime
def _begin_response(uri: str) -> dict:
return {
"device_code": "dc-test",
"verification_uri_complete": uri,
"interval": 5,
"expire_in": 3600,
}
@pytest.mark.parametrize(
"returned",
[
"https://open.feishu.cn/page/launcher?user_code=ABCD-EFGH",
"https://open.larksuite.com/page/launcher?user_code=ABCD-EFGH",
],
)
def test_launcher_url_rewritten_to_cli_page(returned: str) -> None:
"""The registration endpoint returns /page/launcher, which rejects these
device codes instantly; the CLI page is the one that works."""
with patch.object(feishu_runtime, "_post_registration",
return_value=_begin_response(returned)):
start = feishu_runtime._begin_registration("feishu")
assert start["qr_url"].startswith(
returned.split("/page/")[0] + "/page/cli?user_code="
)
def test_cli_url_passed_through_unchanged() -> None:
uri = "https://open.feishu.cn/page/cli?user_code=ABCD-EFGH"
with patch.object(feishu_runtime, "_post_registration",
return_value=_begin_response(uri)):
start = feishu_runtime._begin_registration("feishu")
assert start["qr_url"] == uri