From f996e5ba1946680d01c260d5320a91be1ae47458 Mon Sep 17 00:00:00 2001 From: Garrett Beatty Date: Tue, 10 Dec 2024 12:32:11 -0500 Subject: [PATCH] Revert "add cookie value encoding" This reverts commit 86b3f5ecbcbd1c0dc1d7f25db6ef1cfb313c12b4. --- .../src/Amazon.Lambda.TestTool/HttpContextExtensions.cs | 2 +- .../HttpContextExtensionsTests.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/HttpContextExtensions.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/HttpContextExtensions.cs index 07a7629af..93b86fc05 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/HttpContextExtensions.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/HttpContextExtensions.cs @@ -44,7 +44,7 @@ public static APIGatewayHttpApiV2ProxyRequest ToApiGatewayHttpV2Request( RouteKey = $"{request.Method} {matchedConfig.Path}", RawPath = request.Path, RawQueryString = request.QueryString.Value, - Cookies = request.Cookies.Select(c => $"{c.Key}={HttpUtility.UrlEncode(c.Value)}").ToArray(), + Cookies = request.Cookies.Select(c => $"{c.Key}={c.Value}").ToArray(), Headers = headers, QueryStringParameters = queryStringParameters, PathParameters = pathParameters ?? new Dictionary(), diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/HttpContextExtensionsTests.cs b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/HttpContextExtensionsTests.cs index 20fcdb0d6..83302cdeb 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/HttpContextExtensionsTests.cs +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/HttpContextExtensionsTests.cs @@ -52,7 +52,7 @@ public void ToApiGatewayHttpV2Request_ShouldReturnValidApiGatewayHttpApiV2ProxyR request.QueryString = new QueryString("?status=pending"); request.Headers["User-Agent"] = "TestAgent"; request.Headers["Accept"] = "application/json"; - request.Headers["Cookie"] = "session=abc123; theme=dark; complex=this+has+spaces;"; + request.Headers["Cookie"] = "session=abc123; theme=dark"; var result = context.ToApiGatewayHttpV2Request(); @@ -61,10 +61,9 @@ public void ToApiGatewayHttpV2Request_ShouldReturnValidApiGatewayHttpApiV2ProxyR Assert.Equal("GET /api/users/{userId}/orders", result.RouteKey); Assert.Equal("/api/users/123/orders", result.RawPath); Assert.Equal("?status=pending", result.RawQueryString); - Assert.Equal(3, result.Cookies.Length); + Assert.Equal(2, result.Cookies.Length); Assert.Contains("session=abc123", result.Cookies); Assert.Contains("theme=dark", result.Cookies); - Assert.Contains("complex=this%2bhas%2bspaces", result.Cookies); Assert.Equal("123", result.PathParameters["userId"]); Assert.Equal("GET", result.RequestContext.Http.Method); Assert.Equal("/api/users/123/orders", result.RequestContext.Http.Path);