533db535f1
build / build (push) Successful in 1m12s
按已确认需求提供独立安全模型配置、真实探测、正式字典字段评估与原问题译中,持久批次支持只补空白、暂停恢复、有限重试、幂等和逐字段依据。覆盖固定规则、本地语言、组织关联与主表有效看板共用治理侧读模型,保留源生产和冻结历史。 验证:完整 make verify 退出0,702项Go与329项前端通过;默认118项外部/隔离集成明确跳过,另跑完整镜像及组织隔离PG竞态。12并发、输入漂移、过期租约、暂停/恢复及有限重试通过。用户授权的百炼 deepseek-v4.1-flash 完成真实后台与浏览器评估/翻译;552行、16列、11块看板及完整PNG、独立配置页测试/保存、重开恢复和零JS异常通过。仅非业务样本外发,自动处理关闭,原payload不变。 上线前治理库已做导出快照原生备份并真实恢复,60表行数与17个QA表内容哈希一致;不修改DobotAI生产或隧道。本提交时尚未部署,线上验收须独立完成。
77 lines
3.0 KiB
Go
77 lines
3.0 KiB
Go
package qaopsai
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestClientUsesConfiguredModelAndWriteOnlyKeyWithoutChangingInput(t *testing.T) {
|
|
count := 0
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
count++
|
|
if r.URL.Path != "/v1/chat/completions" || r.Header.Get("Authorization") != "Bearer fixture-only" {
|
|
t.Error("wrong route or authorization")
|
|
}
|
|
var request struct {
|
|
Model string `json:"model"`
|
|
Messages []struct{ Role, Content string } `json:"messages"`
|
|
ResponseFormat map[string]string `json:"response_format"`
|
|
}
|
|
if json.NewDecoder(r.Body).Decode(&request) != nil || request.Model != "fixture-model" || len(request.Messages) != 2 || request.ResponseFormat["type"] != "json_object" {
|
|
t.Error("configured protocol not used")
|
|
}
|
|
if len(request.Messages) == 2 && strings.Contains(request.Messages[1].Content, "fixture-only") {
|
|
t.Error("key copied into business prompt")
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write([]byte(`{"model":"fixture-returned-model","choices":[{"message":{"content":"{\"ok\":true}"},"finish_reason":"stop"}]}`))
|
|
}))
|
|
defer server.Close()
|
|
got, err := (Client{AllowPrivate: true}).Call(context.Background(), server.URL+"/v1", "fixture-model", "fixture-only", "Respond only with JSON", map[string]string{"question": "synthetic only"}, 64)
|
|
if err != nil || got.Content != `{"ok":true}` || got.Model != "fixture-returned-model" || count != 1 {
|
|
t.Fatalf("actual compatibility request not completed: response=%+v error=%v calls=%d", got, err, count)
|
|
}
|
|
}
|
|
|
|
func TestClientReleasesPerCallTransportConnections(t *testing.T) {
|
|
closed := make(chan struct{}, 1)
|
|
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
_, _ = w.Write([]byte(`{"model":"fixture","choices":[{"message":{"content":"{\"ok\":true}"},"finish_reason":"stop"}]}`))
|
|
}))
|
|
server.Config.ConnState = func(_ net.Conn, state http.ConnState) {
|
|
if state == http.StateClosed {
|
|
select {
|
|
case closed <- struct{}{}:
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
server.Start()
|
|
defer server.Close()
|
|
if _, err := (Client{AllowPrivate: true}).Call(context.Background(), server.URL, "fixture", "fixture-only", "json", map[string]string{}, 64); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
select {
|
|
case <-closed:
|
|
case <-time.After(time.Second):
|
|
t.Fatal("completed per-call transport left an idle model connection open")
|
|
}
|
|
}
|
|
|
|
func TestClientRejectsPrivateEndpointsBeforeSendingSecrets(t *testing.T) {
|
|
for _, encryptedDNS := range []bool{false, true} {
|
|
for _, base := range []string{"https://127.0.0.1:1/v1", "https://198.18.0.40/v1", "https://100.92.49.78/v1", "https://10.0.0.1/v1"} {
|
|
_, err := (Client{DNSOverTLS: encryptedDNS}).Call(context.Background(), base, "fixture", "fixture-only", "json", map[string]string{}, 32)
|
|
if err != ErrInvalid {
|
|
t.Fatalf("private/reserved destination accepted with encryptedDNS=%v: %v", encryptedDNS, err)
|
|
}
|
|
}
|
|
}
|
|
}
|