test: 补齐规格纠偏安全场景 (#258)

This commit is contained in:
chengma
2026-08-17 18:37:39 +08:00
parent be900b2411
commit 29cf66ce96
4 changed files with 138 additions and 11 deletions
@@ -220,6 +220,18 @@ func applyAPISpecContractMutation(mutation string, taskID *string, request map[s
case "attempt_id_too_long":
request["attempt_id"] = strings.Repeat("a", 192)
*key = apiSpecIdempotencyKey(*taskID, request)
case "candidate_count_101":
candidates := make([]any, 0, 101)
for index := 1; index <= 101; index++ {
value := "测试尺码" + strconv.Itoa(index)
candidates = append(candidates, map[string]any{
"candidate_id": "c" + strconv.Itoa(index),
"raw_text": value,
"options": map[string]any{"color": "测试黑", "size": value},
})
}
request["candidates"] = candidates
apiSpecRefreshHashes(*taskID, request, key)
case "body_too_large":
request["future_padding"] = strings.Repeat("x", 64<<10)
case "task_not_found":
@@ -46,12 +46,13 @@ type purchaseSpecContractCase struct {
}
type purchaseSpecContractModel struct {
Conclusion string `json:"conclusion"`
CandidateID string `json:"candidate_id"`
ConfidenceBPS int `json:"confidence_bps"`
Reason string `json:"reason"`
MissingDimensions []string `json:"missing_dimensions"`
Error string `json:"error"`
Conclusion string `json:"conclusion"`
CandidateID string `json:"candidate_id"`
ConfidenceBPS int `json:"confidence_bps"`
Reason string `json:"reason"`
ConflictDimensions []string `json:"conflict_dimensions"`
MissingDimensions []string `json:"missing_dimensions"`
Error string `json:"error"`
}
type purchaseSpecContractExpected struct {
@@ -230,11 +231,12 @@ func contractAIClientForCase(testCase purchaseSpecContractCase) *contractAIModel
return client
}
client.response = AIModelMatchResponse{
Conclusion: testCase.Model.Conclusion,
CandidateID: testCase.Model.CandidateID,
ConfidenceBPS: testCase.Model.ConfidenceBPS,
Reason: testCase.Model.Reason,
MissingDimensions: append([]string(nil), testCase.Model.MissingDimensions...),
Conclusion: testCase.Model.Conclusion,
CandidateID: testCase.Model.CandidateID,
ConfidenceBPS: testCase.Model.ConfidenceBPS,
Reason: testCase.Model.Reason,
ConflictDimensions: append([]string(nil), testCase.Model.ConflictDimensions...),
MissingDimensions: append([]string(nil), testCase.Model.MissingDimensions...),
}
return client
}