Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
03f69dd3
Commit
03f69dd3
authored
Feb 20, 2026
by
yangjianbo
Browse files
fix(proxy): 将401/405质量检测结果调整为告警
parent
d14c24bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/admin_service.go
View file @
03f69dd3
...
...
@@ -1908,8 +1908,13 @@ func runProxyQualityTarget(ctx context.Context, client *http.Client, target prox
}
if
_
,
ok
:=
target
.
AllowedStatuses
[
resp
.
StatusCode
];
ok
{
item
.
Status
=
"pass"
item
.
Message
=
fmt
.
Sprintf
(
"HTTP %d"
,
resp
.
StatusCode
)
if
resp
.
StatusCode
>=
http
.
StatusOK
&&
resp
.
StatusCode
<
http
.
StatusMultipleChoices
{
item
.
Status
=
"pass"
item
.
Message
=
fmt
.
Sprintf
(
"HTTP %d"
,
resp
.
StatusCode
)
}
else
{
item
.
Status
=
"warn"
item
.
Message
=
fmt
.
Sprintf
(
"HTTP %d(目标可达,但鉴权或方法受限)"
,
resp
.
StatusCode
)
}
return
item
}
...
...
backend/internal/service/admin_service_proxy_quality_test.go
View file @
03f69dd3
...
...
@@ -52,6 +52,27 @@ func TestRunProxyQualityTarget_SoraChallenge(t *testing.T) {
}
func
TestRunProxyQualityTarget_AllowedStatusPass
(
t
*
testing
.
T
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
_
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusOK
)
_
,
_
=
w
.
Write
([]
byte
(
`{"models":[]}`
))
}))
defer
server
.
Close
()
target
:=
proxyQualityTarget
{
Target
:
"gemini"
,
URL
:
server
.
URL
,
Method
:
http
.
MethodGet
,
AllowedStatuses
:
map
[
int
]
struct
{}{
http
.
StatusOK
:
{},
},
}
item
:=
runProxyQualityTarget
(
context
.
Background
(),
server
.
Client
(),
target
)
require
.
Equal
(
t
,
"pass"
,
item
.
Status
)
require
.
Equal
(
t
,
http
.
StatusOK
,
item
.
HTTPStatus
)
}
func
TestRunProxyQualityTarget_AllowedStatusWarnForUnauthorized
(
t
*
testing
.
T
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
_
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
_
,
_
=
w
.
Write
([]
byte
(
`{"error":"unauthorized"}`
))
...
...
@@ -68,6 +89,7 @@ func TestRunProxyQualityTarget_AllowedStatusPass(t *testing.T) {
}
item
:=
runProxyQualityTarget
(
context
.
Background
(),
server
.
Client
(),
target
)
require
.
Equal
(
t
,
"
pass
"
,
item
.
Status
)
require
.
Equal
(
t
,
"
warn
"
,
item
.
Status
)
require
.
Equal
(
t
,
http
.
StatusUnauthorized
,
item
.
HTTPStatus
)
require
.
Contains
(
t
,
item
.
Message
,
"目标可达"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment