fix: clarify New-API authentication failures

This commit is contained in:
2026-07-22 00:49:32 +08:00
parent 6906c3b998
commit db51733383
4 changed files with 91 additions and 2 deletions
+15 -1
View File
@@ -1,4 +1,6 @@
from app.services.upstream_client import UpstreamClient
import pytest
from app.services.upstream_client import UpstreamClient, UpstreamError
def test_new_api_token_headers_include_authorization_and_new_api_user():
@@ -16,6 +18,18 @@ def test_new_api_token_headers_include_authorization_and_new_api_user():
assert "Nox-Api-User" not in headers
def test_new_api_token_rejects_dashboard_jwt():
client = UpstreamClient(
base_url="http://newapi.local",
api_prefix="",
auth_type="new_api_token",
auth_config={"token": "a" * 1200 + ".payload.signature", "user_id": "7"},
)
with pytest.raises(UpstreamError, match="面板登录 JWT"):
client._headers()
def test_nox_token_headers_include_authorization_and_nox_api_user():
client = UpstreamClient(
base_url="http://nox.local",