Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 4bd7ab9

Browse files
committed
Fixed tests
1 parent a985920 commit 4bd7ab9

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationHandler.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Security.Claims;
6-
using System.Security.Principal;
76
using System.Threading.Tasks;
87
using Microsoft.AspNetCore.Authentication;
98
using Microsoft.AspNetCore.Http;
@@ -19,12 +18,12 @@ internal class AuthenticationHandler : IAuthenticationHandler
1918

2019
public Task<AuthenticateResult> AuthenticateAsync(AuthenticateContext context)
2120
{
22-
var identity = (ClaimsIdentity)_requestContext.User?.Identity;
21+
var identity = _requestContext.User?.Identity;
2322
var success = identity != null
2423
&& identity.IsAuthenticated
2524
&& string.Equals(context.AuthenticationScheme, identity.AuthenticationType, StringComparison.Ordinal);
2625
return Task.FromResult(success
27-
? AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(identity), properties: null, authenticationScheme: context.AuthenticationScheme))
26+
? AuthenticateResult.Success(new AuthenticationTicket(_requestContext.User, properties: null, authenticationScheme: context.AuthenticationScheme))
2827
: AuthenticateResult.None());
2928
}
3029

test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,6 @@ public class AuthenticationTests
1717
private static bool AllowAnoymous = true;
1818
private static bool DenyAnoymous = false;
1919

20-
[ConditionalTheory]
21-
[InlineData(AuthenticationSchemes.Negotiate)]
22-
[InlineData(AuthenticationSchemes.NTLM)]
23-
[InlineData(AuthenticationSchemes.Basic)]
24-
[InlineData(AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic)]
25-
public async Task CanAuthenticate(AuthenticationSchemes authType)
26-
{
27-
var authTypeList = authType.ToString().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
28-
using (var server = Utilities.CreateDynamicHost(string.Empty, authType, AllowAnoymous, out var address, out var baseAddress, async httpContext =>
29-
{
30-
foreach (var scheme in authTypeList)
31-
{
32-
var result = await httpContext.AuthenticateAsync(scheme);
33-
Assert.True(result.Succeeded);
34-
}
35-
httpContext.Response.StatusCode = 200;
36-
}))
37-
{
38-
var response = await SendRequestAsync(address);
39-
Assert.NotNull(response);
40-
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
41-
}
42-
}
43-
4420
[ConditionalTheory]
4521
[InlineData(AuthenticationSchemes.None)]
4622
[InlineData(AuthenticationSchemes.Negotiate)]
@@ -176,7 +152,7 @@ public async Task AuthTypes_AllowAnonymousButSpecify401_Success(AuthenticationSc
176152
[InlineData(AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /* AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic)]
177153
public async Task AuthTypes_RequireAuth_Success(AuthenticationSchemes authType)
178154
{
179-
using (var server = Utilities.CreateDynamicHost(string.Empty, authType, AllowAnoymous, out var address, out var baseAddress, httpContext =>
155+
using (var server = Utilities.CreateDynamicHost(string.Empty, authType, DenyAnoymous, out var address, out var baseAddress, httpContext =>
180156
{
181157
Assert.NotNull(httpContext.User);
182158
Assert.NotNull(httpContext.User.Identity);

0 commit comments

Comments
 (0)