package admission import ( "net/http/httptest" "strings" "testing" "github.com/gin-gonic/gin" ) func TestProbePayloadRejectsCredentialFields(t *testing.T) { gin.SetMode(gin.TestMode) recorder := httptest.NewRecorder() ctx, _ := gin.CreateTestContext(recorder) ctx.Request = httptest.NewRequest("POST", "/api/v1/admission/devices/device/probe", strings.NewReader(`{"address":"http://192.0.2.10/onvif","version":1,"password":"must-not-be-accepted"}`)) ctx.Request.Header.Set("Content-Type", "application/json") var request ProbeRequest if err := bindStrict(ctx, &request); err == nil { t.Fatal("credential-like unknown field accepted") } }