Skip to content

Commit

Permalink
enable Alpn_H3_Success test (dotnet#56818)
Browse files Browse the repository at this point in the history
* enable Alpn_H3_Success test

* update
  • Loading branch information
wfurt authored Aug 4, 2021
1 parent e5c0b81 commit bfee0bb
Showing 1 changed file with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ public async Task ServerCertificateCustomValidationCallback_Succeeds()
Assert.Equal(HttpVersion.Version30, response.Version);
Assert.Null(callbackRequest);
Assert.Equal(1, invocationCount);

await serverTask;
}

[OuterLoop]
Expand Down Expand Up @@ -630,7 +632,6 @@ private static async Task SendDataForever(Http3LoopbackStream stream)
}

[ConditionalFact(nameof(IsMsQuicSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/56609")]
public async Task Alpn_H3_Success()
{
// Mock doesn't use ALPN.
Expand All @@ -642,44 +643,32 @@ public async Task Alpn_H3_Success()
var options = new Http3Options() { Alpn = SslApplicationProtocol.Http3.ToString() };
using Http3LoopbackServer server = CreateHttp3LoopbackServer(options);

using var clientDone = new SemaphoreSlim(0);
using var serverDone = new SemaphoreSlim(0);

Http3LoopbackConnection connection = null;
Task serverTask = Task.Run(async () =>
{
using Http3LoopbackConnection connection = (Http3LoopbackConnection)await server.EstablishGenericConnectionAsync();

SslApplicationProtocol negotiatedAlpn = ExtractMsQuicNegotiatedAlpn(connection);
Assert.Equal(SslApplicationProtocol.Http3, negotiatedAlpn);

connection = (Http3LoopbackConnection)await server.EstablishGenericConnectionAsync();
using Http3LoopbackStream stream = await connection.AcceptRequestStreamAsync();
await stream.HandleRequestAsync();

serverDone.Release();
await clientDone.WaitAsync();
});

Task clientTask = Task.Run(async () =>
using HttpClient client = CreateHttpClient();
using HttpRequestMessage request = new()
{
using HttpClient client = CreateHttpClient();

using HttpRequestMessage request = new()
{
Method = HttpMethod.Get,
RequestUri = server.Address,
Version = HttpVersion30,
VersionPolicy = HttpVersionPolicy.RequestVersionExact
};
HttpResponseMessage response = await client.SendAsync(request).WaitAsync(TimeSpan.FromSeconds(10));

response.EnsureSuccessStatusCode();
Assert.Equal(HttpVersion.Version30, response.Version);
Method = HttpMethod.Get,
RequestUri = server.Address,
Version = HttpVersion30,
VersionPolicy = HttpVersionPolicy.RequestVersionExact
};
HttpResponseMessage response = await client.SendAsync(request).WaitAsync(TimeSpan.FromSeconds(10));
response.EnsureSuccessStatusCode();
Assert.Equal(HttpVersion.Version30, response.Version);

clientDone.Release();
await serverDone.WaitAsync();
});
await serverTask;
Assert.NotNull(connection);

await new[] { clientTask, serverTask }.WhenAllOrAnyFailed(200_000);
SslApplicationProtocol negotiatedAlpn = ExtractMsQuicNegotiatedAlpn(connection);
Assert.Equal(new SslApplicationProtocol("h3"), negotiatedAlpn);
connection.Dispose();
}

[ConditionalFact(nameof(IsMsQuicSupported))]
Expand Down

0 comments on commit bfee0bb

Please sign in to comment.