MCPcopy Create free account
hub / github.com/astercloud/aster / TestContentTypeValidation

Function TestContentTypeValidation

server/handlers_test.go:458–477  ·  view source on GitHub ↗

TestContentTypeValidation 测试 Content-Type 验证

(t *testing.T)

Source from the content-addressed store, hash-verified

456
457// TestContentTypeValidation 测试 Content-Type 验证
458func TestContentTypeValidation(t *testing.T) {
459 srv, cleanup := setupTestServer(t)
460 defer cleanup()
461
462 t.Run("MissingContentType", func(t *testing.T) {
463 body := `{"template_id": "chat"}`
464 req := httptest.NewRequest(http.MethodPost, "/v1/agents", strings.NewReader(body))
465 // 不设置 Content-Type
466 w := httptest.NewRecorder()
467
468 srv.Router().ServeHTTP(w, req)
469
470 // Gin 默认会尝试解析,但可能失败
471 assert.NotEqual(t, http.StatusOK, w.Code)
472 })
473
474 t.Run("WrongContentType", func(t *testing.T) {
475 t.Skip("Content-Type validation varies by implementation")
476 })
477}
478
479// TestQueryParameters 测试查询参数
480func TestQueryParameters(t *testing.T) {

Callers

nothing calls this directly

Calls 4

setupTestServerFunction · 0.85
RunMethod · 0.45
ServeHTTPMethod · 0.45
RouterMethod · 0.45

Tested by

no test coverage detected