mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-30 07:56:21 +08:00
fix(i18n): translate site authentication diagnostics
This commit is contained in:
@@ -400,6 +400,19 @@
|
||||
"无法打开网站!": "Unable to open the site!",
|
||||
"无法获取Token": "Unable to get token",
|
||||
"连接成功": "Connection successful",
|
||||
"网页可访问(按站点设置检查登录状态,未验证用户认证接口)": "Page reachable (login checked according to site settings; user-authentication endpoint not verified)",
|
||||
"请求超时": "Request timed out",
|
||||
"DNS 解析失败": "DNS resolution failed",
|
||||
"代理连接失败": "Proxy connection failed",
|
||||
"TLS 连接失败": "TLS connection failed",
|
||||
"网络连接失败": "Network connection failed",
|
||||
"认证请求失败": "Authentication request failed",
|
||||
"认证接口未收到响应": "No response from the authentication endpoint",
|
||||
"认证接口返回内容为空": "Authentication endpoint returned an empty response",
|
||||
"认证接口返回内容与预期不符(不是 JSON 对象)": "Unexpected authentication response (expected a JSON object)",
|
||||
"认证接口返回内容与预期不符(不是有效 JSON)": "Unexpected authentication response (invalid JSON)",
|
||||
"认证接口返回内容与预期不符(缺少认证状态)": "Unexpected authentication response (missing authentication status)",
|
||||
"认证未通过,请检查凭据和站点用户状态!": "Authentication was not approved. Check your credentials and site account status.",
|
||||
"Cookie已失效": "Cookie has expired",
|
||||
"鉴权已过期或无效": "Authentication has expired or is invalid",
|
||||
"Cookie已过期": "Cookie has expired",
|
||||
@@ -658,6 +671,14 @@
|
||||
"渠道授权服务不可用": "The channel authorization service is unavailable"
|
||||
},
|
||||
"message_patterns": [
|
||||
{
|
||||
"source": "认证接口返回 HTTP {status}",
|
||||
"target": "Authentication endpoint returned HTTP {status}"
|
||||
},
|
||||
{
|
||||
"source": "用户认证出错({error_type})",
|
||||
"target": "User authentication error ({error_type})"
|
||||
},
|
||||
{
|
||||
"source": "{name} 未能加入整理队列,请稍后重试",
|
||||
"target": "Could not add {name} to the organization queue. Try again later"
|
||||
|
||||
@@ -362,6 +362,19 @@
|
||||
"无法打开网站!": "無法開啟網站!",
|
||||
"无法获取Token": "無法取得 Token",
|
||||
"连接成功": "連線成功",
|
||||
"网页可访问(按站点设置检查登录状态,未验证用户认证接口)": "網頁可存取(依站點設定檢查登入狀態,未驗證使用者認證介面)",
|
||||
"请求超时": "請求逾時",
|
||||
"DNS 解析失败": "DNS 解析失敗",
|
||||
"代理连接失败": "代理連線失敗",
|
||||
"TLS 连接失败": "TLS 連線失敗",
|
||||
"网络连接失败": "網路連線失敗",
|
||||
"认证请求失败": "認證請求失敗",
|
||||
"认证接口未收到响应": "認證介面未收到回應",
|
||||
"认证接口返回内容为空": "認證介面回傳內容為空",
|
||||
"认证接口返回内容与预期不符(不是 JSON 对象)": "認證介面回傳內容不符預期(不是 JSON 物件)",
|
||||
"认证接口返回内容与预期不符(不是有效 JSON)": "認證介面回傳內容不符預期(不是有效 JSON)",
|
||||
"认证接口返回内容与预期不符(缺少认证状态)": "認證介面回傳內容不符預期(缺少認證狀態)",
|
||||
"认证未通过,请检查凭据和站点用户状态!": "認證未通過,請檢查憑據和站點使用者狀態!",
|
||||
"Cookie已失效": "Cookie 已失效",
|
||||
"鉴权已过期或无效": "鑑權已過期或無效",
|
||||
"Cookie已过期": "Cookie 已過期",
|
||||
@@ -606,6 +619,14 @@
|
||||
"渠道授权服务不可用": "渠道授權服務無法使用"
|
||||
},
|
||||
"message_patterns": [
|
||||
{
|
||||
"source": "认证接口返回 HTTP {status}",
|
||||
"target": "認證介面回傳 HTTP {status}"
|
||||
},
|
||||
{
|
||||
"source": "用户认证出错({error_type})",
|
||||
"target": "使用者認證出錯({error_type})"
|
||||
},
|
||||
{
|
||||
"source": "{name} 未能加入整理队列,请稍后重试",
|
||||
"target": "無法將 {name} 加入整理佇列,請稍後再試"
|
||||
|
||||
@@ -13,6 +13,7 @@ from app.application.site.auth import (
|
||||
normalize_site_auth_params,
|
||||
)
|
||||
from app.scheduler import reconcile as scheduler_reconcile
|
||||
from app.runtime.localization import LocaleHelper
|
||||
from app.schemas.site import SiteAuth
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.startup.initializers import modules as module_initializer
|
||||
@@ -144,6 +145,54 @@ def test_auth_site_does_not_persist_failed_parameters(monkeypatch) -> None:
|
||||
config.set.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("locale,message,expected", [
|
||||
("en-US", "请求超时", "Request timed out"),
|
||||
("en-US", "认证接口返回 HTTP 403", "Authentication endpoint returned HTTP 403"),
|
||||
("en-US", "用户认证出错(RuntimeError)", "User authentication error (RuntimeError)"),
|
||||
("zh-TW", "请求超时", "請求逾時"),
|
||||
("zh-TW", "认证接口返回 HTTP 403", "認證介面回傳 HTTP 403"),
|
||||
("zh-TW", "用户认证出错(RuntimeError)", "使用者認證出錯(RuntimeError)"),
|
||||
])
|
||||
def test_auth_failure_response_keeps_the_requested_language(monkeypatch, locale, message, expected) -> None:
|
||||
"""
|
||||
认证资源的新诊断通过真实 API 响应本地化,不让前端原样显示中文 fallback。
|
||||
"""
|
||||
helper = Mock()
|
||||
helper.get_authsites.return_value = HAIDAN_AUTH_SITES
|
||||
helper.check_user.return_value = (False, message)
|
||||
_patch_auth_endpoint(monkeypatch, helper, Mock())
|
||||
token = LocaleHelper.set_current_locale(locale)
|
||||
try:
|
||||
response = site_endpoint.auth_site(SiteAuth(site="haidan", params={"id": 123}), SimpleNamespace())
|
||||
finally:
|
||||
LocaleHelper.reset_current_locale(token)
|
||||
|
||||
assert response.message == expected
|
||||
assert response.success is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("locale,expected", [
|
||||
("en-US", "Page reachable (login checked according to site settings; user-authentication endpoint not verified)"),
|
||||
("zh-TW", "網頁可存取(依站點設定檢查登入狀態,未驗證使用者認證介面)"),
|
||||
])
|
||||
def test_connectivity_scope_response_keeps_the_requested_language(monkeypatch, locale, expected) -> None:
|
||||
"""
|
||||
站点测试成功的范围说明经过 API 翻译后再由前端展示。
|
||||
"""
|
||||
chain = Mock()
|
||||
chain.test.return_value = (True, "网页可访问(按站点设置检查登录状态,未验证用户认证接口)")
|
||||
monkeypatch.setattr(site_endpoint, "SiteChain", Mock(return_value=chain))
|
||||
query = Mock(get_sync=Mock(return_value=SimpleNamespace(domain="site.test")))
|
||||
token = LocaleHelper.set_current_locale(locale)
|
||||
try:
|
||||
response = site_endpoint.test_site(1, query=query)
|
||||
finally:
|
||||
LocaleHelper.reset_current_locale(token)
|
||||
|
||||
assert response.message == expected
|
||||
assert response.success is True
|
||||
|
||||
|
||||
def test_startup_auth_prefers_environment_configuration(monkeypatch) -> None:
|
||||
"""
|
||||
设置环境变量时启动认证应从环境读取,而不是使用旧持久化配置。
|
||||
|
||||
Reference in New Issue
Block a user