diff --git a/src/Microsoft.AspNet.Server.WebListener/AuthenticationHandler.cs b/src/Microsoft.AspNet.Server.WebListener/AuthenticationHandler.cs index 833561b30a..bbaa799bca 100644 --- a/src/Microsoft.AspNet.Server.WebListener/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Server.WebListener/AuthenticationHandler.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNet.Server.WebListener foreach (var authType in ListEnabledAuthSchemes()) { string authScheme = authType.ToString(); - if (context.AuthenticationSchemes.Contains(authScheme, StringComparer.Ordinal)) + if (string.Equals(authScheme, context.AuthenticationScheme, StringComparison.Ordinal)) { if (identity != null && identity.IsAuthenticated && string.Equals(authScheme, identity.AuthenticationType, StringComparison.Ordinal)) @@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Server.WebListener } else { - context.NotAuthenticated(authScheme, properties: null, description: GetDescription(authScheme)); + context.NotAuthenticated(); } } } diff --git a/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/AuthenticationTests.cs b/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/AuthenticationTests.cs index e96b810101..e78cb247be 100644 --- a/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/AuthenticationTests.cs +++ b/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/AuthenticationTests.cs @@ -262,8 +262,11 @@ namespace Microsoft.AspNet.Server.WebListener var context = new DefaultHttpContext((IFeatureCollection)env); Assert.NotNull(context.User); Assert.False(context.User.Identity.IsAuthenticated); - var authResults = context.Authenticate(authTypeList); - Assert.False(authResults.Any()); + foreach (var scheme in authTypeList) + { + var authResults = context.Authenticate(scheme); + Assert.Null(authResults.Principal); + } return Task.FromResult(0); })) { @@ -289,8 +292,16 @@ namespace Microsoft.AspNet.Server.WebListener var context = new DefaultHttpContext((IFeatureCollection)env); Assert.NotNull(context.User); Assert.True(context.User.Identity.IsAuthenticated); - var authResults = context.Authenticate(authTypeList); - Assert.Equal(1, authResults.Count()); + var count = 0; + foreach (var scheme in authTypeList) + { + var authResults = context.Authenticate(scheme); + if (authResults.Principal != null) + { + count++; + } + } + Assert.Equal(1, count); return Task.FromResult(0); })) {