mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 17:10:26 +01:00
Fix google protobuf WellKnownTypes: Empty, Duration and Timestamp (#1231)
* Fix google protobuf WellKnownTypes: Timestamp and Duration * Fix protobuf Empty * . * small refactor * 006 * fix * policy * --- * <PackageReference Include="ProtoBufJsonConverter" Version="0.7.0" />
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Facts;
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public sealed class IgnoreOnContinuousIntegrationFact : FactAttribute
|
||||
{
|
||||
private const string SkipReason = "Ignore when run via CI/CD";
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright © WireMock.Net
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using WireMock.Net.Testcontainers.Utils;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Facts;
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public sealed class RunOnDockerPlatformFact : FactAttribute
|
||||
{
|
||||
public RunOnDockerPlatformFact(string platform)
|
||||
|
||||
@@ -7,8 +7,10 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Greet;
|
||||
using Grpc.Net.Client;
|
||||
using NarrowIntegrationTest.Lookup;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
@@ -17,6 +19,7 @@ using Xunit;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace WireMock.Net.Tests;
|
||||
|
||||
public partial class WireMockServerTests
|
||||
{
|
||||
private const string ProtoDefinition = @"
|
||||
@@ -34,6 +37,12 @@ message HelloRequest {
|
||||
|
||||
message HelloReply {
|
||||
string message = 1;
|
||||
enum PhoneType {
|
||||
none = 0;
|
||||
mobile = 1;
|
||||
home = 2;
|
||||
}
|
||||
PhoneType phoneType = 2;
|
||||
}
|
||||
";
|
||||
|
||||
@@ -48,6 +57,8 @@ import ""google/protobuf/duration.proto"";
|
||||
|
||||
service Greeter {
|
||||
rpc SayNothing (google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc SayTimestamp (MyMessageTimestamp) returns (MyMessageTimestamp);
|
||||
rpc SayDuration (MyMessageDuration) returns (MyMessageDuration);
|
||||
}
|
||||
|
||||
message MyMessageTimestamp {
|
||||
@@ -128,8 +139,6 @@ message Other {
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -171,23 +180,18 @@ message Other {
|
||||
var responseBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAcKBWhlbGxv");
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes()
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes_Empty()
|
||||
{
|
||||
// Arrange
|
||||
var bytes = Convert.FromBase64String("CgRzdGVm");
|
||||
|
||||
using var server = WireMockServer.Start();
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/grpc/Greeter/SayNothing")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithBodyAsProtoBuf(ProtoDefinitionWithWellKnownTypes, "google.protobuf.Empty",
|
||||
@@ -198,6 +202,7 @@ message Other {
|
||||
);
|
||||
|
||||
// Act
|
||||
var bytes = Convert.FromBase64String("CgRzdGVm");
|
||||
var protoBuf = new ByteArrayContent(bytes);
|
||||
protoBuf.Headers.ContentType = new MediaTypeHeaderValue("application/grpc-web");
|
||||
|
||||
@@ -208,9 +213,91 @@ message Other {
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var responseBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
|
||||
Convert.ToBase64String(responseBytes).Should().Be("");
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAA=");
|
||||
}
|
||||
|
||||
server.Stop();
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes_Timestamp()
|
||||
{
|
||||
// Arrange
|
||||
using var server = WireMockServer.Start();
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/grpc/Greeter/SayTimestamp")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithBodyAsProtoBuf(ProtoDefinitionWithWellKnownTypes, "communication.api.v1.MyMessageTimestamp",
|
||||
new
|
||||
{
|
||||
ts = new
|
||||
{
|
||||
Seconds = 1722301323,
|
||||
Nanos = 12300
|
||||
}
|
||||
}
|
||||
)
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithTransformer()
|
||||
);
|
||||
|
||||
// Act
|
||||
var bytes = Convert.FromBase64String("CgkIi/egtQYQuWA=");
|
||||
var protoBuf = new ByteArrayContent(bytes);
|
||||
protoBuf.Headers.ContentType = new MediaTypeHeaderValue("application/grpc-web");
|
||||
|
||||
var client = server.CreateClient();
|
||||
var response = await client.PostAsync("/grpc/Greeter/SayTimestamp", protoBuf);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var responseBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAsKCQiL96C1BhCMYA==");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes_Duration()
|
||||
{
|
||||
// Arrange
|
||||
using var server = WireMockServer.Start();
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/grpc/Greeter/SayDuration")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithBodyAsProtoBuf(ProtoDefinitionWithWellKnownTypes, "communication.api.v1.MyMessageDuration",
|
||||
new
|
||||
{
|
||||
du = new
|
||||
{
|
||||
Seconds = 1722301323,
|
||||
Nanos = 12300
|
||||
}
|
||||
}
|
||||
)
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithTransformer()
|
||||
);
|
||||
|
||||
// Act
|
||||
var bytes = Convert.FromBase64String("CgkIi/egtQYQuWA=");
|
||||
var protoBuf = new ByteArrayContent(bytes);
|
||||
protoBuf.Headers.ContentType = new MediaTypeHeaderValue("application/grpc-web");
|
||||
|
||||
var client = server.CreateClient();
|
||||
var response = await client.PostAsync("/grpc/Greeter/SayDuration", protoBuf);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var responseBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAsKCQiL96C1BhCMYA==");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -228,7 +315,6 @@ message Other {
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/grpc/Greeter/SayNothing")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.WithProtoDefinition(id)
|
||||
.RespondWith(Response.Create()
|
||||
@@ -250,9 +336,7 @@ message Other {
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var responseBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
|
||||
Convert.ToBase64String(responseBytes).Should().Be("");
|
||||
|
||||
server.Stop();
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAA=");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -294,8 +378,6 @@ message Other {
|
||||
var responseBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
|
||||
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAcKBWhlbGxv");
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -326,15 +408,12 @@ message Other {
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" });
|
||||
|
||||
// Assert
|
||||
reply.Message.Should().Be("hello stef POST");
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -367,15 +446,12 @@ message Other {
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" });
|
||||
|
||||
// Assert
|
||||
reply.Message.Should().Be("hello stef POST");
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -411,15 +487,214 @@ message Other {
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" });
|
||||
|
||||
// Assert
|
||||
reply.Message.Should().Be("hello stef POST");
|
||||
}
|
||||
|
||||
server.Stop();
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes_Empty_UsingGrpcGeneratedClient()
|
||||
{
|
||||
// Arrange
|
||||
var definition = await System.IO.File.ReadAllTextAsync("./Grpc/greet.proto");
|
||||
|
||||
using var server = WireMockServer.Start(useHttp2: true);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/greet.Greeter/SayNothing")
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithHeader("Content-Type", "application/grpc")
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithBodyAsProtoBuf(definition, "google.protobuf.Empty",
|
||||
new { }
|
||||
)
|
||||
);
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayNothingAsync(new Empty());
|
||||
|
||||
// Assert
|
||||
reply.Should().Be(new Empty());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes_Timestamp_UsingGrpcGeneratedClient()
|
||||
{
|
||||
// Arrange
|
||||
const int seconds = 1722301323;
|
||||
const int nanos = 12300;
|
||||
var definition = await System.IO.File.ReadAllTextAsync("./Grpc/greet.proto");
|
||||
|
||||
using var server = WireMockServer.Start(useHttp2: true);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/greet.Greeter/SayTimestamp")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithHeader("Content-Type", "application/grpc")
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithBodyAsProtoBuf(definition, "greet.MyMessageTimestamp",
|
||||
new MyMessageTimestamp
|
||||
{
|
||||
Ts = new Timestamp
|
||||
{
|
||||
Seconds = seconds,
|
||||
Nanos = nanos
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayTimestampAsync(new MyMessageTimestamp { Ts = Timestamp.FromDateTime(DateTime.UtcNow) });
|
||||
|
||||
// Assert
|
||||
reply.Ts.Should().Be(new Timestamp { Seconds = seconds, Nanos = nanos });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes_Duration_UsingGrpcGeneratedClient()
|
||||
{
|
||||
// Arrange
|
||||
const int seconds = 1722301323;
|
||||
const int nanos = 12300;
|
||||
var definition = await System.IO.File.ReadAllTextAsync("./Grpc/greet.proto");
|
||||
|
||||
using var server = WireMockServer.Start(useHttp2: true);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/greet.Greeter/SayDuration")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithHeader("Content-Type", "application/grpc")
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithBodyAsProtoBuf(definition, "greet.MyMessageDuration",
|
||||
new MyMessageDuration
|
||||
{
|
||||
Du = new Duration
|
||||
{
|
||||
Seconds = seconds,
|
||||
Nanos = nanos
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayDurationAsync(new MyMessageDuration { Du = Duration.FromTimeSpan(TimeSpan.MinValue) });
|
||||
|
||||
// Assert
|
||||
reply.Du.Should().Be(new Duration { Seconds = seconds, Nanos = nanos });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_Enum_UsingGrpcGeneratedClient()
|
||||
{
|
||||
// Arrange
|
||||
var definition = await System.IO.File.ReadAllTextAsync("./Grpc/greet.proto");
|
||||
|
||||
using var server = WireMockServer.Start(useHttp2: true);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/greet.Greeter/SayHello")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithHeader("Content-Type", "application/grpc")
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithBodyAsProtoBuf(definition, "greet.HelloReply",
|
||||
new HelloReply
|
||||
{
|
||||
Message = "hello",
|
||||
PhoneType = HelloReply.Types.PhoneType.Home
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
var client = new Greeter.GreeterClient(channel);
|
||||
|
||||
var reply = await client.SayHelloAsync(new HelloRequest());
|
||||
|
||||
// Assert
|
||||
reply.Message.Should().Be("hello");
|
||||
reply.PhoneType.Should().Be(HelloReply.Types.PhoneType.Home);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsProtoBuf_Enum_UsingPolicyGrpcGeneratedClient()
|
||||
{
|
||||
// Arrange
|
||||
const int seconds = 1722301323;
|
||||
const int nanos = 12300;
|
||||
const string version = "test";
|
||||
const string correlationId = "correlation";
|
||||
var definition = await System.IO.File.ReadAllTextAsync("./Grpc/policy.proto");
|
||||
|
||||
using var server = WireMockServer.Start(useHttp2: true);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingPost()
|
||||
.WithPath("/Policy.PolicyService/GetVersion")
|
||||
.WithBody(new NotNullOrEmptyMatcher())
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithHeader("Content-Type", "application/grpc")
|
||||
.WithTrailingHeader("grpc-status", "0")
|
||||
.WithBodyAsProtoBuf(definition, "NarrowIntegrationTest.Lookup.GetVersionResponse",
|
||||
new GetVersionResponse
|
||||
{
|
||||
Version = version,
|
||||
DateHired = new Timestamp
|
||||
{
|
||||
Seconds = seconds,
|
||||
Nanos = nanos
|
||||
},
|
||||
Client = new NarrowIntegrationTest.Lookup.Client
|
||||
{
|
||||
ClientName = NarrowIntegrationTest.Lookup.Client.Types.Clients.BillingCenter,
|
||||
CorrelationId = correlationId
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Act
|
||||
var channel = GrpcChannel.ForAddress(server.Url!);
|
||||
var client = new PolicyService.PolicyServiceClient(channel);
|
||||
|
||||
var reply = await client.GetVersionAsync(new GetVersionRequest());
|
||||
|
||||
// Assert
|
||||
reply.Version.Should().Be(version);
|
||||
reply.DateHired.Should().Be(new Timestamp { Seconds = seconds, Nanos = nanos });
|
||||
reply.Client.ClientName.Should().Be(NarrowIntegrationTest.Lookup.Client.Types.Clients.BillingCenter);
|
||||
reply.Client.CorrelationId.Should().Be(correlationId);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,33 +1,41 @@
|
||||
// Copyright 2019 The gRPC Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package greet;
|
||||
|
||||
// The greeting service definition.
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
service Greeter {
|
||||
// Sends a greeting
|
||||
rpc SayNothing (google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc SayHello (HelloRequest) returns (HelloReply);
|
||||
rpc SayEmpty (MyMessageEmpty) returns (MyMessageEmpty);
|
||||
rpc SayTimestamp (MyMessageTimestamp) returns (MyMessageTimestamp);
|
||||
rpc SayDuration (MyMessageDuration) returns (MyMessageDuration);
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message HelloReply {
|
||||
string message = 1;
|
||||
enum PhoneType {
|
||||
none = 0;
|
||||
mobile = 1;
|
||||
home = 2;
|
||||
}
|
||||
PhoneType phoneType = 2;
|
||||
}
|
||||
|
||||
message MyMessageTimestamp {
|
||||
google.protobuf.Timestamp ts = 1;
|
||||
}
|
||||
|
||||
message MyMessageDuration {
|
||||
google.protobuf.Duration du = 1;
|
||||
}
|
||||
|
||||
message MyMessageEmpty {
|
||||
google.protobuf.Empty e = 1;
|
||||
}
|
||||
40
test/WireMock.Net.Tests/Grpc/policy.proto
Normal file
40
test/WireMock.Net.Tests/Grpc/policy.proto
Normal file
@@ -0,0 +1,40 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace = "NarrowIntegrationTest.Lookup";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
package Policy;
|
||||
|
||||
service PolicyService {
|
||||
rpc GetVersion (GetVersionRequest) returns (GetVersionResponse);
|
||||
}
|
||||
|
||||
message GetVersionRequest {
|
||||
Client Client = 1;
|
||||
|
||||
}
|
||||
message GetVersionResponse {
|
||||
string Version = 1;
|
||||
google.protobuf.Timestamp DateHired = 2;
|
||||
Client Client = 3;
|
||||
}
|
||||
|
||||
message Client {
|
||||
string CorrelationId = 1;
|
||||
enum Clients {
|
||||
Unknown = 0;
|
||||
QMS = 1;
|
||||
BillingCenter = 2;
|
||||
PAS = 3;
|
||||
Payroll = 4;
|
||||
Portal = 5;
|
||||
SFO = 6;
|
||||
QuoteAndBind = 7;
|
||||
LegacyConversion = 8;
|
||||
BindNow = 9;
|
||||
PaymentPortal = 10 ;
|
||||
PricingEngine = 11;
|
||||
}
|
||||
Clients ClientName = 2;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>net452;net461;netcoreapp3.1;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>net452;net461;netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<DebugType>full</DebugType>
|
||||
@@ -113,6 +113,7 @@
|
||||
</PackageReference>
|
||||
|
||||
<Protobuf Include="Grpc\greet.proto" GrpcServices="Client" />
|
||||
<Protobuf Include="Grpc\policy.proto" GrpcServices="Client" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0'">
|
||||
@@ -132,8 +133,13 @@
|
||||
<None Update="cert.pem">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Grpc\policy.proto">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<GrpcServices>Client</GrpcServices>
|
||||
</None>
|
||||
<None Update="Grpc\greet.proto">
|
||||
<GrpcServices>Client</GrpcServices>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="responsebody.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
||||
@@ -215,10 +215,10 @@ public partial class WireMockServerTests
|
||||
{
|
||||
// Arrange
|
||||
var port = PortUtils.FindFreeTcpPort();
|
||||
var IPv4 = GetIPAddressesByFamily(System.Net.Sockets.AddressFamily.InterNetwork);
|
||||
var IPv4 = GetIPAddressesByFamily(AddressFamily.InterNetwork);
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
Urls = ["http://0.0.0.0:" + port],
|
||||
Urls = ["http://0.0.0.0:" + port]
|
||||
};
|
||||
using var server = WireMockServer.Start(settings);
|
||||
|
||||
@@ -234,15 +234,16 @@ public partial class WireMockServerTests
|
||||
}
|
||||
}
|
||||
|
||||
#if NET8_0_OR_GREATER
|
||||
[IgnoreOnContinuousIntegrationFact]
|
||||
public async Task WireMockServer_WithUrl0000_Should_Listen_On_All_IPs_IPv6()
|
||||
{
|
||||
// Arrange
|
||||
var port = PortUtils.FindFreeTcpPort();
|
||||
var IPv6 = GetIPAddressesByFamily(System.Net.Sockets.AddressFamily.InterNetworkV6);
|
||||
var IPv6 = GetIPAddressesByFamily(AddressFamily.InterNetworkV6);
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
Urls = ["http://0.0.0.0:" + port],
|
||||
Urls = ["http://0.0.0.0:" + port]
|
||||
};
|
||||
using var server = WireMockServer.Start(settings);
|
||||
|
||||
@@ -257,6 +258,7 @@ public partial class WireMockServerTests
|
||||
response.Should().Be("x");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user