From 2176fa38d852e04d99c4f9af9b59fbc88caf8112 Mon Sep 17 00:00:00 2001 From: James Suplizio Date: Thu, 19 Sep 2024 11:44:13 -0700 Subject: [PATCH] Update TestProxy from Net6 to Net8 (#9012) * Update TestProxy from Net6 to Net8 * Update ci.yml from net6->net8 * Update for code changes --- ...e.Sdk.Tools.Assets.MaintenanceTool.Tests.csproj | 2 +- .../Azure.Sdk.Tools.Assets.MaintenanceTool.csproj | 2 +- .../Azure.Sdk.Tools.TestProxy.Tests.csproj | 4 ++-- .../MatcherTests.cs | 4 ++-- .../Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs | 2 +- .../test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs | 2 +- .../Azure.Sdk.Tools.TestProxy.csproj | 14 +++----------- .../Common/Exceptions/HttpException.cs | 8 +------- .../Common/HttpExceptionMiddleware.cs | 12 ++++++------ .../Common/SecretScanner.cs | 1 - .../Common/TestRecordingMismatchException.cs | 4 ---- .../Azure.Sdk.Tools.TestProxy/RecordingHandler.cs | 12 ++++++------ tools/test-proxy/ci.yml | 10 +++++----- ...ure.Sdk.Tools.TestProxy.HttpClientSample.csproj | 2 +- ...e.Sdk.Tools.TestProxy.HttpPipelineSample.csproj | 2 +- ...Tools.TestProxy.HttpPipelineTestsExample.csproj | 2 +- ...re.Sdk.Tools.TestProxy.StorageBlobSample.csproj | 6 +++--- 17 files changed, 35 insertions(+), 54 deletions(-) diff --git a/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests.csproj b/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests.csproj index 000175aeb79..c157e84d5e6 100644 --- a/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests.csproj +++ b/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool/Azure.Sdk.Tools.Assets.MaintenanceTool.csproj b/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool/Azure.Sdk.Tools.Assets.MaintenanceTool.csproj index 4e636649756..06b72ab86c1 100644 --- a/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool/Azure.Sdk.Tools.Assets.MaintenanceTool.csproj +++ b/tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool/Azure.Sdk.Tools.Assets.MaintenanceTool.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 enable enable nullable diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/Azure.Sdk.Tools.TestProxy.Tests.csproj b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/Azure.Sdk.Tools.TestProxy.Tests.csproj index 9ab73a30465..79a1d4697eb 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/Azure.Sdk.Tools.TestProxy.Tests.csproj +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/Azure.Sdk.Tools.TestProxy.Tests.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 false false diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/MatcherTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/MatcherTests.cs index c8caad1686b..a21610217f5 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/MatcherTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/MatcherTests.cs @@ -287,7 +287,7 @@ public async Task CustomMatcherMatchesDifferentUriOrder() }; foreach (var kvp in requestHeaders) { - playbackContext.Request.Headers.Add(kvp.Key, kvp.Value); + playbackContext.Request.Headers.Append(kvp.Key, kvp.Value); } playbackContext.Request.Method = "POST"; @@ -332,7 +332,7 @@ public async Task EncodedUriAmpersandWorksCrossplat() }; foreach (var kvp in requestHeaders) { - playbackContext.Request.Headers.Add(kvp.Key, kvp.Value); + playbackContext.Request.Headers.Append(kvp.Key, kvp.Value); } var queryString = "?api-version=1.0&year=2023&basinId=AL&govId=5"; var path = "/weather/tropical/storms/json"; diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs index 8259e4ea09b..c8f9850b9ee 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs @@ -212,7 +212,7 @@ public async Task TestPlaybackThrowsOnDifferentUriOrder() }; foreach (var kvp in requestHeaders) { - playbackContext.Request.Headers.Add(kvp.Key, kvp.Value); + playbackContext.Request.Headers.Append(kvp.Key, kvp.Value); } playbackContext.Request.Method = "POST"; diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs index c59f518e58e..96e868ad4a9 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs @@ -166,7 +166,7 @@ public async Task AddSanitizers() if (recordingId != null) { - Response.Headers.Add("x-recording-id", recordingId); + Response.Headers.Append("x-recording-id", recordingId); } var json = JsonSerializer.Serialize(new { Sanitizers = registeredSanitizers }); diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Azure.Sdk.Tools.TestProxy.csproj b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Azure.Sdk.Tools.TestProxy.csproj index cb41c0c9a7b..098eb86cd67 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Azure.Sdk.Tools.TestProxy.csproj +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Azure.Sdk.Tools.TestProxy.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 $(NoWarn);1591;AZC0001;AZC0012;CA1724;CA1801;CA1812;CA1822;SA1028 true true @@ -12,18 +12,10 @@ false - - - - - - - - - - + + diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/Exceptions/HttpException.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/Exceptions/HttpException.cs index dc4c66886f8..1da303453f8 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/Exceptions/HttpException.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/Exceptions/HttpException.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -36,11 +36,5 @@ public HttpException(HttpStatusCode statusCode, string message, Exception innerE { StatusCode = statusCode; } - - protected HttpException(HttpStatusCode statusCode, SerializationInfo info, StreamingContext context) : base(info, context) - { - StatusCode = statusCode; - } - } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/HttpExceptionMiddleware.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/HttpExceptionMiddleware.cs index 8b567512be9..cedae83534b 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/HttpExceptionMiddleware.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/HttpExceptionMiddleware.cs @@ -48,13 +48,13 @@ public async Task Invoke(HttpContext context) if (e is TestRecordingMismatchException) { - response.Headers.Add("x-request-mismatch", "true"); - response.Headers.Add("x-request-mismatch-error", encodedException); + response.Headers.Append("x-request-mismatch", "true"); + response.Headers.Append("x-request-mismatch-error", encodedException); } else { - response.Headers.Add("x-request-known-exception", "true"); - response.Headers.Add("x-request-known-exception-error", encodedException); + response.Headers.Append("x-request-known-exception", "true"); + response.Headers.Append("x-request-known-exception-error", encodedException); } var bodyObj = new @@ -77,8 +77,8 @@ public async Task Invoke(HttpContext context) response.StatusCode = unexpectedStatusCode; response.ContentType = "application/json"; - response.Headers.Add("x-request-exception", "true"); - response.Headers.Add("x-request-exception-error", Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Message))); + response.Headers.Append("x-request-exception", "true"); + response.Headers.Append("x-request-exception-error", Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Message))); DebugLogger.LogError(unexpectedStatusCode, e); diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SecretScanner.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SecretScanner.cs index 8af2f8bdf7f..45b9faee435 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SecretScanner.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SecretScanner.cs @@ -7,7 +7,6 @@ using System.Threading; using System.Threading.Tasks; using Azure.Sdk.Tools.TestProxy.Console; -using Microsoft.Build.Tasks; using Microsoft.Security.Utilities; namespace Azure.Sdk.Tools.TestProxy.Common diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/TestRecordingMismatchException.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/TestRecordingMismatchException.cs index 0d82e2cece1..725b69962e4 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/TestRecordingMismatchException.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/TestRecordingMismatchException.cs @@ -22,9 +22,5 @@ public TestRecordingMismatchException(string message) : base(HttpStatusCode.NotF public TestRecordingMismatchException(string message, Exception innerException) : base(HttpStatusCode.NotFound, message, innerException) { } - - protected TestRecordingMismatchException(SerializationInfo info, StreamingContext context) : base(HttpStatusCode.NotFound, info, context) - { - } } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs index e6dc2eb4b9e..9938e2d4d98 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs @@ -239,7 +239,7 @@ public async Task StartRecordingAsync(string sessionId, HttpResponse outgoingRes DebugLogger.LogTrace($"RECORD START END {id}."); - outgoingResponse.Headers.Add("x-recording-id", id); + outgoingResponse.Headers.Append("x-recording-id", id); } public async Task HandleRecordRequestAsync(string recordingId, HttpRequest incomingRequest, HttpResponse outgoingResponse) @@ -328,7 +328,7 @@ public async Task HandleRecordRequestAsync(string recordingId, HttpRequest incom foreach (var header in upstreamResponse.Headers.Concat(upstreamResponse.Content.Headers)) { var values = new StringValues(header.Value.ToArray()); - outgoingResponse.Headers.Add(header.Key, values); + outgoingResponse.Headers.Append(header.Key, values); entry.Response.Headers.Add(header.Key, values); } @@ -445,7 +445,7 @@ public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResp await RestoreAssetsJson(assetsPath, true); var path = await GetRecordingPath(sessionId, assetsPath); var base64path = Convert.ToBase64String(Encoding.UTF8.GetBytes(path)); - outgoingResponse.Headers.Add("x-base64-recording-file-location", base64path); + outgoingResponse.Headers.Append("x-base64-recording-file-location", base64path); if (!File.Exists(path)) { throw new TestRecordingMismatchException($"Recording file path {path} does not exist."); @@ -465,11 +465,11 @@ public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResp throw new HttpException(HttpStatusCode.InternalServerError, $"Unexpectedly failed to add new playback session under id {id}."); } - outgoingResponse.Headers.Add("x-recording-id", id); + outgoingResponse.Headers.Append("x-recording-id", id); var json = JsonSerializer.Serialize(session.Session.Variables); - outgoingResponse.Headers.Add("Content-Type", "application/json"); + outgoingResponse.Headers.Append("Content-Type", "application/json"); // Write to the response await outgoingResponse.WriteAsync(json); @@ -577,7 +577,7 @@ public async Task HandlePlaybackRequest(string recordingId, HttpRequest incoming foreach (var header in match.Response.Headers) { - outgoingResponse.Headers.Add(header.Key, header.Value.ToArray()); + outgoingResponse.Headers.Append(header.Key, header.Value.ToArray()); } outgoingResponse.Headers.Remove("Transfer-Encoding"); diff --git a/tools/test-proxy/ci.yml b/tools/test-proxy/ci.yml index ea64e8460d5..f15cd590b3f 100644 --- a/tools/test-proxy/ci.yml +++ b/tools/test-proxy/ci.yml @@ -28,19 +28,19 @@ extends: ReleaseBinaries: true StandaloneExeMatrix: - rid: osx-x64 - framework: net6.0 + framework: net8.0 assembly: Azure.Sdk.Tools.TestProxy - rid: osx-arm64 - framework: net6.0 + framework: net8.0 assembly: Azure.Sdk.Tools.TestProxy - rid: win-x64 - framework: net6.0 + framework: net8.0 assembly: Azure.Sdk.Tools.TestProxy - rid: linux-x64 - framework: net6.0 + framework: net8.0 assembly: Azure.Sdk.Tools.TestProxy - rid: linux-arm64 - framework: net6.0 + framework: net8.0 assembly: Azure.Sdk.Tools.TestProxy TestPreSteps: - pwsh: | diff --git a/tools/test-proxy/sample-clients/net/http-client/Azure.Sdk.Tools.TestProxy.HttpClientSample.csproj b/tools/test-proxy/sample-clients/net/http-client/Azure.Sdk.Tools.TestProxy.HttpClientSample.csproj index 41f1d5ad4b2..a269962b552 100644 --- a/tools/test-proxy/sample-clients/net/http-client/Azure.Sdk.Tools.TestProxy.HttpClientSample.csproj +++ b/tools/test-proxy/sample-clients/net/http-client/Azure.Sdk.Tools.TestProxy.HttpClientSample.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 diff --git a/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineSample/Azure.Sdk.Tools.TestProxy.HttpPipelineSample.csproj b/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineSample/Azure.Sdk.Tools.TestProxy.HttpPipelineSample.csproj index 5ed281c81fa..2212f269730 100644 --- a/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineSample/Azure.Sdk.Tools.TestProxy.HttpPipelineSample.csproj +++ b/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineSample/Azure.Sdk.Tools.TestProxy.HttpPipelineSample.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 diff --git a/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample.csproj b/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample.csproj index 03bef459cd2..6e682a1969f 100644 --- a/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample.csproj +++ b/tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable false diff --git a/tools/test-proxy/sample-clients/net/storage-blob/Azure.Sdk.Tools.TestProxy.StorageBlobSample.csproj b/tools/test-proxy/sample-clients/net/storage-blob/Azure.Sdk.Tools.TestProxy.StorageBlobSample.csproj index 30edd022b34..13b1942382e 100644 --- a/tools/test-proxy/sample-clients/net/storage-blob/Azure.Sdk.Tools.TestProxy.StorageBlobSample.csproj +++ b/tools/test-proxy/sample-clients/net/storage-blob/Azure.Sdk.Tools.TestProxy.StorageBlobSample.csproj @@ -2,12 +2,12 @@ Exe - net6.0 + net8.0 - - + +