Update core dependencies
This also removes testing on .NET Core 3.1, which is out of support. Signed-off-by: Jon Skeet <jonskeet@google.com>
This commit is contained in:
parent
1fe92ab054
commit
8999fce15f
|
@ -17,12 +17,6 @@ jobs:
|
||||||
- name: Check out our repo
|
- name: Check out our repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# We need the .NET Core 3.1 runtime for testing
|
|
||||||
- name: Setup .NET Core 3.1
|
|
||||||
uses: actions/setup-dotnet@v3
|
|
||||||
with:
|
|
||||||
dotnet-version: 3.1.x
|
|
||||||
|
|
||||||
# Build with .NET 6.0 SDK
|
# Build with .NET 6.0 SDK
|
||||||
- name: Setup .NET 6.0
|
- name: Setup .NET 6.0
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
|
|
|
@ -15,12 +15,6 @@ jobs:
|
||||||
- name: Check out our repo
|
- name: Check out our repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# We need the .NET Core 3.1 runtime for testing
|
|
||||||
- name: Setup .NET Core 3.1
|
|
||||||
uses: actions/setup-dotnet@v3
|
|
||||||
with:
|
|
||||||
dotnet-version: 3.1.x
|
|
||||||
|
|
||||||
# Build with .NET 6.0 SDK
|
# Build with .NET 6.0 SDK
|
||||||
- name: Setup .NET 6.0
|
- name: Setup .NET 6.0
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
|
@ -37,4 +31,3 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
dotnet pack -c Release -p:ContinuousIntegrationBuild=true -o $PWD/nuget
|
dotnet pack -c Release -p:ContinuousIntegrationBuild=true -o $PWD/nuget
|
||||||
for file in nuget/*.nupkg; do dotnet nuget push -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} $file; done
|
for file in nuget/*.nupkg; do dotnet nuget push -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} $file; done
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||||
<!-- Source-only package with nullable reference annotations. -->
|
<!-- Source-only package with nullable reference annotations. -->
|
||||||
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="All" />
|
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.14" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<LangVersion>8.0</LangVersion>
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
<PackageReference Include="xunit.runner.console" Version="2.4.2">
|
<PackageReference Include="xunit.runner.console" Version="2.4.2">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|
|
@ -13,6 +13,7 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
@ -160,12 +161,15 @@ namespace CloudNative.CloudEvents.UnitTests
|
||||||
{
|
{
|
||||||
request.Headers[header.Key] = header.Value.Single();
|
request.Headers[header.Key] = header.Value.Single();
|
||||||
}
|
}
|
||||||
foreach (var header in message.Content.Headers)
|
if (message.Content?.Headers is HttpContentHeaders contentHeaders)
|
||||||
|
{
|
||||||
|
foreach (var header in contentHeaders)
|
||||||
{
|
{
|
||||||
request.Headers[header.Key] = header.Value.Single();
|
request.Headers[header.Key] = header.Value.Single();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var contentBytes = await message.Content.ReadAsByteArrayAsync();
|
var contentBytes = await (message.Content?.ReadAsByteArrayAsync() ?? Task.FromResult(Array.Empty<byte>()));
|
||||||
request.Body = new MemoryStream(contentBytes);
|
request.Body = new MemoryStream(contentBytes);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Binary, formatter));
|
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Binary, formatter));
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var content = response.Content;
|
var content = response.Content;
|
||||||
Assert.Equal("text/plain", content.Headers.ContentType.MediaType);
|
Assert.Equal("text/plain", content.Headers.ContentType!.MediaType);
|
||||||
Assert.Equal("plain text", await content.ReadAsStringAsync());
|
Assert.Equal("plain text", await content.ReadAsStringAsync());
|
||||||
Assert.Equal("1.0", response.Headers.GetValues("ce-specversion").Single());
|
Assert.Equal("1.0", response.Headers.GetValues("ce-specversion").Single());
|
||||||
Assert.Equal(cloudEvent.Type, response.Headers.GetValues("ce-type").Single());
|
Assert.Equal(cloudEvent.Type, response.Headers.GetValues("ce-type").Single());
|
||||||
|
@ -229,7 +229,7 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
var response = await GetResponseAsync(
|
var response = await GetResponseAsync(
|
||||||
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Binary, formatter));
|
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Binary, formatter));
|
||||||
var content = response.Content;
|
var content = response.Content;
|
||||||
Assert.Equal("application/json", content.Headers.ContentType.MediaType);
|
Assert.Equal("application/json", content.Headers.ContentType!.MediaType);
|
||||||
Assert.Equal("\"plain text\"", await content.ReadAsStringAsync());
|
Assert.Equal("\"plain text\"", await content.ReadAsStringAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Structured, formatter));
|
async context => await cloudEvent.CopyToHttpListenerResponseAsync(context.Response, ContentMode.Structured, formatter));
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var content = response.Content;
|
var content = response.Content;
|
||||||
Assert.Equal(MimeUtilities.MediaType + "+json", content.Headers.ContentType.MediaType);
|
Assert.Equal(MimeUtilities.MediaType + "+json", content.Headers.ContentType!.MediaType);
|
||||||
var bytes = await content.ReadAsByteArrayAsync();
|
var bytes = await content.ReadAsByteArrayAsync();
|
||||||
|
|
||||||
var parsed = new JsonEventFormatter().DecodeStructuredModeMessage(bytes, MimeUtilities.ToContentType(content.Headers.ContentType), extensionAttributes: null);
|
var parsed = new JsonEventFormatter().DecodeStructuredModeMessage(bytes, MimeUtilities.ToContentType(content.Headers.ContentType), extensionAttributes: null);
|
||||||
|
@ -284,7 +284,7 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
|
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var content = response.Content;
|
var content = response.Content;
|
||||||
Assert.Equal(MimeUtilities.BatchMediaType + "+json", content.Headers.ContentType.MediaType);
|
Assert.Equal(MimeUtilities.BatchMediaType + "+json", content.Headers.ContentType!.MediaType);
|
||||||
var bytes = await content.ReadAsByteArrayAsync();
|
var bytes = await content.ReadAsByteArrayAsync();
|
||||||
var parsedBatch = new JsonEventFormatter().DecodeBatchModeMessage(bytes, MimeUtilities.ToContentType(content.Headers.ContentType), extensionAttributes: null);
|
var parsedBatch = new JsonEventFormatter().DecodeBatchModeMessage(bytes, MimeUtilities.ToContentType(content.Headers.ContentType), extensionAttributes: null);
|
||||||
AssertBatchesEqual(batch, parsedBatch);
|
AssertBatchesEqual(batch, parsedBatch);
|
||||||
|
@ -299,7 +299,7 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
var guid = Guid.NewGuid().ToString();
|
var guid = Guid.NewGuid().ToString();
|
||||||
request.Headers.Add(TestContextHeader, guid);
|
request.Headers.Add(TestContextHeader, guid);
|
||||||
|
|
||||||
T result = default;
|
T result = default!;
|
||||||
bool executed = false;
|
bool executed = false;
|
||||||
|
|
||||||
PendingRequests[guid] = async context =>
|
PendingRequests[guid] = async context =>
|
||||||
|
|
|
@ -84,7 +84,8 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
|
|
||||||
private async Task HandleContext(HttpListenerContext requestContext)
|
private async Task HandleContext(HttpListenerContext requestContext)
|
||||||
{
|
{
|
||||||
var ctxHeaderValue = requestContext.Request.Headers[TestContextHeader];
|
var ctxHeaderValue = requestContext.Request.Headers[TestContextHeader]
|
||||||
|
?? throw new InvalidOperationException("Test context header was missing");
|
||||||
|
|
||||||
if (PendingRequests.TryRemove(ctxHeaderValue, out var pending))
|
if (PendingRequests.TryRemove(ctxHeaderValue, out var pending))
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,8 @@ using System.Threading.Tasks;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using static CloudNative.CloudEvents.UnitTests.TestHelpers;
|
using static CloudNative.CloudEvents.UnitTests.TestHelpers;
|
||||||
|
|
||||||
|
// Type or member is obsolete - this whole file is testing WebRequest integration.
|
||||||
|
#pragma warning disable SYSLIB0014
|
||||||
namespace CloudNative.CloudEvents.Http.UnitTests
|
namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
{
|
{
|
||||||
public class HttpWebExtensionsTest : HttpTestBase
|
public class HttpWebExtensionsTest : HttpTestBase
|
||||||
|
@ -163,7 +165,7 @@ namespace CloudNative.CloudEvents.Http.UnitTests
|
||||||
var guid = Guid.NewGuid().ToString();
|
var guid = Guid.NewGuid().ToString();
|
||||||
request.Headers.Add(TestContextHeader, guid);
|
request.Headers.Add(TestContextHeader, guid);
|
||||||
|
|
||||||
T result = default;
|
T result = default!;
|
||||||
bool executed = false;
|
bool executed = false;
|
||||||
|
|
||||||
PendingRequests[guid] = async context =>
|
PendingRequests[guid] = async context =>
|
||||||
|
|
Loading…
Reference in New Issue