@@ -243,91 +243,6 @@ func TestHandleRequestBody(t *testing.T) {
243243 string (rb .RequestBody .Response .BodyMutation .GetBody ()))
244244}
245245
246- func TestRemoveHeader (t * testing.T ) {
247- testCases := []struct {
248- Name string
249- Headers * corev3.HeaderMap
250- KeyToRemove string
251- ExpectedHeaders []* corev3.HeaderValue
252- }{
253- {
254- Name : "removes single matching header" ,
255- Headers : & corev3.HeaderMap {
256- Headers : []* corev3.HeaderValue {
257- {Key : "x-test" , RawValue : []byte ("value1" )},
258- {Key : "x-keep" , RawValue : []byte ("value2" )},
259- },
260- },
261- KeyToRemove : "x-test" ,
262- ExpectedHeaders : []* corev3.HeaderValue {
263- {Key : "x-keep" , RawValue : []byte ("value2" )},
264- },
265- },
266- {
267- Name : "removes multiple matching headers" ,
268- Headers : & corev3.HeaderMap {
269- Headers : []* corev3.HeaderValue {
270- {Key : "x-duplicate" , RawValue : []byte ("value1" )},
271- {Key : "x-keep" , RawValue : []byte ("value2" )},
272- {Key : "x-duplicate" , RawValue : []byte ("value3" )},
273- },
274- },
275- KeyToRemove : "x-duplicate" ,
276- ExpectedHeaders : []* corev3.HeaderValue {
277- {Key : "x-keep" , RawValue : []byte ("value2" )},
278- },
279- },
280- {
281- Name : "does nothing when key not found" ,
282- Headers : & corev3.HeaderMap {
283- Headers : []* corev3.HeaderValue {
284- {Key : "x-keep1" , RawValue : []byte ("value1" )},
285- {Key : "x-keep2" , RawValue : []byte ("value2" )},
286- },
287- },
288- KeyToRemove : "x-nonexistent" ,
289- ExpectedHeaders : []* corev3.HeaderValue {
290- {Key : "x-keep1" , RawValue : []byte ("value1" )},
291- {Key : "x-keep2" , RawValue : []byte ("value2" )},
292- },
293- },
294- {
295- Name : "handles empty header map" ,
296- Headers : & corev3.HeaderMap {
297- Headers : []* corev3.HeaderValue {},
298- },
299- KeyToRemove : "x-test" ,
300- ExpectedHeaders : []* corev3.HeaderValue {},
301- },
302- {
303- Name : "handles nil header map" ,
304- Headers : nil ,
305- KeyToRemove : "x-test" ,
306- ExpectedHeaders : nil ,
307- },
308- }
309-
310- for _ , tc := range testCases {
311- t .Run (tc .Name , func (t * testing.T ) {
312- mcpReq := & MCPRequest {
313- Headers : tc .Headers ,
314- }
315-
316- mcpReq .RemoveHeader (tc .KeyToRemove )
317-
318- if tc .ExpectedHeaders == nil {
319- require .Nil (t , mcpReq .Headers )
320- } else {
321- require .Equal (t , len (tc .ExpectedHeaders ), len (mcpReq .Headers .Headers ))
322- for i , expectedHeader := range tc .ExpectedHeaders {
323- require .Equal (t , expectedHeader .Key , mcpReq .Headers .Headers [i ].Key )
324- require .Equal (t , expectedHeader .RawValue , mcpReq .Headers .Headers [i ].RawValue )
325- }
326- }
327- })
328- }
329- }
330-
331246func TestHandleRequestHeaders (t * testing.T ) {
332247 logger := slog .New (slog .NewTextHandler (os .Stdout , nil ))
333248
0 commit comments