Challenge now always checks for accept
This commit is contained in:
parent
4576481a32
commit
67803d2f41
|
|
@ -72,8 +72,7 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
await handler.ChallengeAsync(challengeContext);
|
||||
}
|
||||
|
||||
// The default Challenge with no scheme is always accepted
|
||||
if (!challengeContext.Accepted && !string.IsNullOrEmpty(authenticationScheme))
|
||||
if (!challengeContext.Accepted)
|
||||
{
|
||||
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
|
||||
}
|
||||
|
|
@ -105,7 +104,7 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
await handler.SignOutAsync(signOutContext);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(authenticationScheme) && !signOutContext.Accepted)
|
||||
if (!signOutContext.Accepted)
|
||||
{
|
||||
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
|||
await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Authentication.AuthenticateAsync("Foo"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ChallengeWithNoAuthMiddlewareMayThrow()
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
[InlineData("Foo")]
|
||||
public async Task ChallengeWithNoAuthMiddlewareMayThrow(string scheme)
|
||||
{
|
||||
var context = CreateContext();
|
||||
await context.Authentication.ChallengeAsync();
|
||||
Assert.Equal(200, context.Response.StatusCode);
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync("Foo"));
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync(scheme));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in New Issue