Skip to content

Commit

Permalink
Update TestProxy from Net6 to Net8 (#9012)
Browse files Browse the repository at this point in the history
* Update TestProxy from Net6 to Net8

* Update ci.yml from net6->net8

* Update for code changes
  • Loading branch information
JimSuplizio authored Sep 19, 2024
1 parent 3135b76 commit 2176fa3
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion tools/test-proxy/Azure.Sdk.Tools.TestProxy/Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);1591;AZC0001;AZC0012;CA1724;CA1801;CA1812;CA1822;SA1028</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
Expand All @@ -12,18 +12,10 @@
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
<PackageReference Include="Azure.Core" Version="1.24.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Azure.Core" Version="1.24.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Security.Utilities.Core" Version="1.4.14" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Azure.Core" Version="1.43.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.5" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -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;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
}
}
12 changes: 6 additions & 6 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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.");
Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions tools/test-proxy/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.10.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="Azure.Core" Version="1.43.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.0" />
</ItemGroup>

</Project>

0 comments on commit 2176fa3

Please sign in to comment.