From bac99ad086dae74e1bb77b9531e65850ff727f52 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 4 Jun 2018 11:08:32 -0700 Subject: [PATCH] React to Uri scope break --- .../AddressRegistrationTests.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/Kestrel.FunctionalTests/AddressRegistrationTests.cs b/test/Kestrel.FunctionalTests/AddressRegistrationTests.cs index 3843c6c532..ce0fb4cef3 100644 --- a/test/Kestrel.FunctionalTests/AddressRegistrationTests.cs +++ b/test/Kestrel.FunctionalTests/AddressRegistrationTests.cs @@ -169,9 +169,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests { var response = await HttpClientSlim.GetStringAsync(testUrl, validateCertificate: false); - // Compare the response with Uri.ToString(), rather than testUrl directly. - // Required to handle IPv6 addresses with zone index, like "fe80::3%1" - Assert.Equal(new Uri(testUrl).ToString(), response); + // Filter out the scope id for IPv6, that's not sent over the wire. "fe80::3%1" + // See https://github.com/aspnet/Common/pull/369 + var uri = new Uri(testUrl); + if (uri.HostNameType == UriHostNameType.IPv6) + { + var builder = new UriBuilder(uri); + var ip = IPAddress.Parse(builder.Host); + builder.Host = new IPAddress(ip.GetAddressBytes()).ToString(); // Without the scope id. + uri = builder.Uri; + } + Assert.Equal(uri.ToString(), response); } } }