From 1828c65da77afc08060c232b8b146988e0580882 Mon Sep 17 00:00:00 2001 From: Alan Xu Date: Sat, 20 Jan 2024 22:40:02 +0800 Subject: [PATCH] test(parameters_name_decoding_handler_test.go): add test cases add test cases --- parameters_name_decoding_handler.go | 1 - parameters_name_decoding_handler_test.go | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/parameters_name_decoding_handler.go b/parameters_name_decoding_handler.go index 5d66c8e..3a169ca 100644 --- a/parameters_name_decoding_handler.go +++ b/parameters_name_decoding_handler.go @@ -71,7 +71,6 @@ func (handler *ParametersNameDecodingHandler) Intercept(pipeline Pipeline, middl ctx := req.Context() if obsOptions != nil { ctx, span := otel.GetTracerProvider().Tracer(obsOptions.GetTracerInstrumentationName()).Start(ctx, "ParametersNameDecodingHandler_Intercept") - span.SetAttributes(attribute.Bool("com.microsoft.kiota.handler.parameters_name_decoding.enable", reqOption.GetEnable())) req = req.WithContext(ctx) defer span.End() diff --git a/parameters_name_decoding_handler_test.go b/parameters_name_decoding_handler_test.go index 8a5f141..31d14a8 100644 --- a/parameters_name_decoding_handler_test.go +++ b/parameters_name_decoding_handler_test.go @@ -15,6 +15,15 @@ func TestItDecodesQueryParameterNames(t *testing.T) { {"?%24select=diplayName&api%2Eversion=2", "/?$select=diplayName&api.version=2"}, {"/api-version/?%24select=diplayName&api%2Eversion=2", "/api-version/?$select=diplayName&api.version=2"}, {"", "/"}, + {"?q=1%2B2", "/?q=1%2B2"}, //Values are not decoded + {"?q=M%26A", "/?q=M%26A"}, //Values are not decoded + {"?q%2D1=M%26A", "/?q-1=M%26A"}, //Values are not decoded but params are + {"?q%2D1&q=M%26A=M%26A", "/?q-1&q=M%26A=M%26A"}, //Values are not decoded but params are + {"?%24select=diplayName&api%2Dversion=1%2B2", "/?$select=diplayName&api-version=1%2B2"}, //Values are not decoded but params are + {"?%24select=diplayName&api%2Dversion=M%26A", "/?$select=diplayName&api-version=M%26A"}, //Values are not decoded but params are + {"?%24select=diplayName&api%7Eversion=M%26A", "/?$select=diplayName&api~version=M%26A"}, //Values are not decoded but params are + {"?%24select=diplayName&api%2Eversion=M%26A", "/?$select=diplayName&api.version=M%26A"}, //Values are not decoded but params are + {"?%24select=diplayName&api%2Eversion=M%26A", "/?$select=diplayName&api.version=M%26A"}, //Values are not decoded but params are } result := "" testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) { @@ -24,7 +33,6 @@ func TestItDecodesQueryParameterNames(t *testing.T) { })) defer func() { testServer.Close() }() for _, data := range testData { - handler := NewParametersNameDecodingHandler() input := testServer.URL + data[0] expected := data[1]