Skip to content

Commit 2176fa3

Browse files
authored
Update TestProxy from Net6 to Net8 (#9012)
* Update TestProxy from Net6 to Net8 * Update ci.yml from net6->net8 * Update for code changes
1 parent 3135b76 commit 2176fa3

File tree

17 files changed

+35
-54
lines changed

17 files changed

+35
-54
lines changed

tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests/Azure.Sdk.Tools.Assets.MaintenanceTool.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

tools/assets-automation/assets-maintenance-tool/Azure.Sdk.Tools.Assets.MaintenanceTool/Azure.Sdk.Tools.Assets.MaintenanceTool.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<WarningsAsErrors>nullable</WarningsAsErrors>

tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/Azure.Sdk.Tools.TestProxy.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<IsPublishable>false</IsPublishable>
77
</PropertyGroup>

tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/MatcherTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public async Task CustomMatcherMatchesDifferentUriOrder()
287287
};
288288
foreach (var kvp in requestHeaders)
289289
{
290-
playbackContext.Request.Headers.Add(kvp.Key, kvp.Value);
290+
playbackContext.Request.Headers.Append(kvp.Key, kvp.Value);
291291
}
292292
playbackContext.Request.Method = "POST";
293293

@@ -332,7 +332,7 @@ public async Task EncodedUriAmpersandWorksCrossplat()
332332
};
333333
foreach (var kvp in requestHeaders)
334334
{
335-
playbackContext.Request.Headers.Add(kvp.Key, kvp.Value);
335+
playbackContext.Request.Headers.Append(kvp.Key, kvp.Value);
336336
}
337337
var queryString = "?api-version=1.0&year=2023&basinId=AL&govId=5";
338338
var path = "/weather/tropical/storms/json";

tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/RecordTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public async Task TestPlaybackThrowsOnDifferentUriOrder()
212212
};
213213
foreach (var kvp in requestHeaders)
214214
{
215-
playbackContext.Request.Headers.Add(kvp.Key, kvp.Value);
215+
playbackContext.Request.Headers.Append(kvp.Key, kvp.Value);
216216
}
217217
playbackContext.Request.Method = "POST";
218218

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public async Task AddSanitizers()
166166

167167
if (recordingId != null)
168168
{
169-
Response.Headers.Add("x-recording-id", recordingId);
169+
Response.Headers.Append("x-recording-id", recordingId);
170170
}
171171

172172
var json = JsonSerializer.Serialize(new { Sanitizers = registeredSanitizers });
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0</TargetFrameworks>
44
<NoWarn>$(NoWarn);1591;AZC0001;AZC0012;CA1724;CA1801;CA1812;CA1822;SA1028</NoWarn>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<IsPackable>true</IsPackable>
@@ -12,18 +12,10 @@
1212
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
1313
</PropertyGroup>
1414

15-
<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
16-
<PackageReference Include="Azure.Core" Version="1.24.0" />
17-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
18-
</ItemGroup>
19-
20-
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
21-
<PackageReference Include="Azure.Core" Version="1.24.0" />
22-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
23-
</ItemGroup>
24-
2515
<ItemGroup>
2616
<PackageReference Include="Microsoft.Security.Utilities.Core" Version="1.4.14" />
2717
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
18+
<PackageReference Include="Azure.Core" Version="1.43.0" />
19+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.5" />
2820
</ItemGroup>
2921
</Project>

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/Exceptions/HttpException.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Net;
@@ -36,11 +36,5 @@ public HttpException(HttpStatusCode statusCode, string message, Exception innerE
3636
{
3737
StatusCode = statusCode;
3838
}
39-
40-
protected HttpException(HttpStatusCode statusCode, SerializationInfo info, StreamingContext context) : base(info, context)
41-
{
42-
StatusCode = statusCode;
43-
}
44-
4539
}
4640
}

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/HttpExceptionMiddleware.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public async Task Invoke(HttpContext context)
4848

4949
if (e is TestRecordingMismatchException)
5050
{
51-
response.Headers.Add("x-request-mismatch", "true");
52-
response.Headers.Add("x-request-mismatch-error", encodedException);
51+
response.Headers.Append("x-request-mismatch", "true");
52+
response.Headers.Append("x-request-mismatch-error", encodedException);
5353
}
5454
else
5555
{
56-
response.Headers.Add("x-request-known-exception", "true");
57-
response.Headers.Add("x-request-known-exception-error", encodedException);
56+
response.Headers.Append("x-request-known-exception", "true");
57+
response.Headers.Append("x-request-known-exception-error", encodedException);
5858
}
5959

6060
var bodyObj = new
@@ -77,8 +77,8 @@ public async Task Invoke(HttpContext context)
7777
response.StatusCode = unexpectedStatusCode;
7878
response.ContentType = "application/json";
7979

80-
response.Headers.Add("x-request-exception", "true");
81-
response.Headers.Add("x-request-exception-error", Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Message)));
80+
response.Headers.Append("x-request-exception", "true");
81+
response.Headers.Append("x-request-exception-error", Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Message)));
8282

8383
DebugLogger.LogError(unexpectedStatusCode, e);
8484

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SecretScanner.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99
using Azure.Sdk.Tools.TestProxy.Console;
10-
using Microsoft.Build.Tasks;
1110
using Microsoft.Security.Utilities;
1211

1312
namespace Azure.Sdk.Tools.TestProxy.Common

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/TestRecordingMismatchException.cs

-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,5 @@ public TestRecordingMismatchException(string message) : base(HttpStatusCode.NotF
2222
public TestRecordingMismatchException(string message, Exception innerException) : base(HttpStatusCode.NotFound, message, innerException)
2323
{
2424
}
25-
26-
protected TestRecordingMismatchException(SerializationInfo info, StreamingContext context) : base(HttpStatusCode.NotFound, info, context)
27-
{
28-
}
2925
}
3026
}

tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public async Task StartRecordingAsync(string sessionId, HttpResponse outgoingRes
239239

240240

241241
DebugLogger.LogTrace($"RECORD START END {id}.");
242-
outgoingResponse.Headers.Add("x-recording-id", id);
242+
outgoingResponse.Headers.Append("x-recording-id", id);
243243
}
244244

245245
public async Task HandleRecordRequestAsync(string recordingId, HttpRequest incomingRequest, HttpResponse outgoingResponse)
@@ -328,7 +328,7 @@ public async Task HandleRecordRequestAsync(string recordingId, HttpRequest incom
328328
foreach (var header in upstreamResponse.Headers.Concat(upstreamResponse.Content.Headers))
329329
{
330330
var values = new StringValues(header.Value.ToArray());
331-
outgoingResponse.Headers.Add(header.Key, values);
331+
outgoingResponse.Headers.Append(header.Key, values);
332332
entry.Response.Headers.Add(header.Key, values);
333333
}
334334

@@ -445,7 +445,7 @@ public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResp
445445
await RestoreAssetsJson(assetsPath, true);
446446
var path = await GetRecordingPath(sessionId, assetsPath);
447447
var base64path = Convert.ToBase64String(Encoding.UTF8.GetBytes(path));
448-
outgoingResponse.Headers.Add("x-base64-recording-file-location", base64path);
448+
outgoingResponse.Headers.Append("x-base64-recording-file-location", base64path);
449449
if (!File.Exists(path))
450450
{
451451
throw new TestRecordingMismatchException($"Recording file path {path} does not exist.");
@@ -465,11 +465,11 @@ public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResp
465465
throw new HttpException(HttpStatusCode.InternalServerError, $"Unexpectedly failed to add new playback session under id {id}.");
466466
}
467467

468-
outgoingResponse.Headers.Add("x-recording-id", id);
468+
outgoingResponse.Headers.Append("x-recording-id", id);
469469

470470

471471
var json = JsonSerializer.Serialize(session.Session.Variables);
472-
outgoingResponse.Headers.Add("Content-Type", "application/json");
472+
outgoingResponse.Headers.Append("Content-Type", "application/json");
473473

474474
// Write to the response
475475
await outgoingResponse.WriteAsync(json);
@@ -577,7 +577,7 @@ public async Task HandlePlaybackRequest(string recordingId, HttpRequest incoming
577577

578578
foreach (var header in match.Response.Headers)
579579
{
580-
outgoingResponse.Headers.Add(header.Key, header.Value.ToArray());
580+
outgoingResponse.Headers.Append(header.Key, header.Value.ToArray());
581581
}
582582

583583
outgoingResponse.Headers.Remove("Transfer-Encoding");

tools/test-proxy/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ extends:
2828
ReleaseBinaries: true
2929
StandaloneExeMatrix:
3030
- rid: osx-x64
31-
framework: net6.0
31+
framework: net8.0
3232
assembly: Azure.Sdk.Tools.TestProxy
3333
- rid: osx-arm64
34-
framework: net6.0
34+
framework: net8.0
3535
assembly: Azure.Sdk.Tools.TestProxy
3636
- rid: win-x64
37-
framework: net6.0
37+
framework: net8.0
3838
assembly: Azure.Sdk.Tools.TestProxy
3939
- rid: linux-x64
40-
framework: net6.0
40+
framework: net8.0
4141
assembly: Azure.Sdk.Tools.TestProxy
4242
- rid: linux-arm64
43-
framework: net6.0
43+
framework: net8.0
4444
assembly: Azure.Sdk.Tools.TestProxy
4545
TestPreSteps:
4646
- pwsh: |

tools/test-proxy/sample-clients/net/http-client/Azure.Sdk.Tools.TestProxy.HttpClientSample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineSample/Azure.Sdk.Tools.TestProxy.HttpPipelineSample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

tools/test-proxy/sample-clients/net/http-pipeline/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample/Azure.Sdk.Tools.TestProxy.HttpPipelineTestsExample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66

77
<IsPackable>false</IsPackable>

tools/test-proxy/sample-clients/net/storage-blob/Azure.Sdk.Tools.TestProxy.StorageBlobSample.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Azure.Core" Version="1.10.0" />
10-
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
9+
<PackageReference Include="Azure.Core" Version="1.43.0" />
10+
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.0" />
1111
</ItemGroup>
1212

1313
</Project>

0 commit comments

Comments
 (0)