From a5e04db4c44a5dec87f7a6954b08c9bc8fac3fda Mon Sep 17 00:00:00 2001 From: David Shulman Date: Fri, 15 Mar 2019 18:21:24 -0700 Subject: [PATCH] Fix and re-enable some HttpListener authentication tests (dotnet/corefx#36084) The Negotiate and NTLM HttpListener tests were disabled due to a behavior of running them on loopback using an HttpClient with WinHttpHandler. But now the default handler for HttpClient is SocketsHttpHandler. And it doesn't have this problem with loopback authentication. Closes dotnet/corefx#20604 Commit migrated from https://github.com/dotnet/corefx/commit/decd797ca84aca0f4b8ca4b6e5f9c7b818bd2967 --- .../tests/HttpListenerAuthenticationTests.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Net.HttpListener/tests/HttpListenerAuthenticationTests.cs b/src/libraries/System.Net.HttpListener/tests/HttpListenerAuthenticationTests.cs index 8e19345..a86a372 100644 --- a/src/libraries/System.Net.HttpListener/tests/HttpListenerAuthenticationTests.cs +++ b/src/libraries/System.Net.HttpListener/tests/HttpListenerAuthenticationTests.cs @@ -166,7 +166,6 @@ namespace System.Net.Tests } [ConditionalFact(nameof(Helpers) + "." + nameof(Helpers.IsWindowsImplementation))] // [PlatformSpecific(TestPlatforms.Windows, "Managed impl doesn't support NTLM")] - [ActiveIssue(20604)] public async Task NtlmAuthentication_Conversation_ReturnsExpectedType2Message() { _listener.AuthenticationSchemes = AuthenticationSchemes.Ntlm; @@ -188,8 +187,7 @@ namespace System.Net.Tests yield return new object[] { "abcd", HttpStatusCode.BadRequest }; } - [ConditionalFact(nameof(Helpers) + "." + nameof(Helpers.IsWindowsImplementation))] // [PlatformSpecific(TestPlatforms.Windows, "Managed impl doesn't support NTLM")] - [ActiveIssue(20604)] + [ConditionalTheory(nameof(Helpers) + "." + nameof(Helpers.IsWindowsImplementation))] // [PlatformSpecific(TestPlatforms.Windows, "Managed impl doesn't support NTLM")] [MemberData(nameof(InvalidNtlmNegotiateAuthentication_TestData))] public async Task NtlmAuthentication_InvalidRequestHeaders_ReturnsExpectedStatusCode(string header, HttpStatusCode statusCode) { @@ -212,7 +210,6 @@ namespace System.Net.Tests } [ConditionalFact(nameof(Helpers) + "." + nameof(Helpers.IsWindowsImplementation))] // [PlatformSpecific(TestPlatforms.Windows, "Managed impl doesn't support Negotiate")] - [ActiveIssue(20604)] public async Task NegotiateAuthentication_Conversation_ReturnsExpectedType2Message() { _listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate; @@ -226,8 +223,7 @@ namespace System.Net.Tests } } - [ConditionalFact(nameof(Helpers) + "." + nameof(Helpers.IsWindowsImplementation))] // [PlatformSpecific(TestPlatforms.Windows, "Managed impl doesn't support Negotiate")] - [ActiveIssue(20604)] + [ConditionalTheory(nameof(Helpers) + "." + nameof(Helpers.IsWindowsImplementation))] // [PlatformSpecific(TestPlatforms.Windows, "Managed impl doesn't support Negotiate")] [MemberData(nameof(InvalidNtlmNegotiateAuthentication_TestData))] public async Task NegotiateAuthentication_InvalidRequestHeaders_ReturnsExpectedStatusCode(string header, HttpStatusCode statusCode) { @@ -238,7 +234,14 @@ namespace System.Net.Tests client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Negotiate", header); HttpResponseMessage message = await AuthenticationFailure(client, statusCode); - Assert.Empty(message.Headers.WwwAuthenticate); + if (statusCode == HttpStatusCode.Unauthorized) + { + Assert.NotEmpty(message.Headers.WwwAuthenticate); + } + else + { + Assert.Empty(message.Headers.WwwAuthenticate); + } } } -- 2.7.4