diff --git a/src/Mvc/Mvc.Core/src/SignInResult.cs b/src/Mvc/Mvc.Core/src/SignInResult.cs index c6cf63ffe8..d558706158 100644 --- a/src/Mvc/Mvc.Core/src/SignInResult.cs +++ b/src/Mvc/Mvc.Core/src/SignInResult.cs @@ -85,14 +85,6 @@ namespace Microsoft.AspNetCore.Mvc throw new ArgumentNullException(nameof(context)); } - if (AuthenticationScheme == null) - { - throw new InvalidOperationException( - Resources.FormatPropertyOfTypeCannotBeNull( - /* property: */ nameof(AuthenticationScheme), - /* type: */ nameof(SignInResult))); - } - var loggerFactory = context.HttpContext.RequestServices.GetRequiredService(); var logger = loggerFactory.CreateLogger(); diff --git a/src/Mvc/Mvc.Core/test/SignInResultTest.cs b/src/Mvc/Mvc.Core/test/SignInResultTest.cs index 1b3246ccb0..15f895bd5b 100644 --- a/src/Mvc/Mvc.Core/test/SignInResultTest.cs +++ b/src/Mvc/Mvc.Core/test/SignInResultTest.cs @@ -45,6 +45,33 @@ namespace Microsoft.AspNetCore.Mvc auth.Verify(); } + [Fact] + public async Task ExecuteResultAsync_InvokesSignInAsyncOnAuthenticationManagerWithDefaultScheme() + { + // Arrange + var principal = new ClaimsPrincipal(); + var httpContext = new Mock(); + var auth = new Mock(); + auth + .Setup(c => c.SignInAsync(httpContext.Object, null, principal, null)) + .Returns(Task.CompletedTask) + .Verifiable(); + httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); + var result = new SignInResult(principal); + var routeData = new RouteData(); + + var actionContext = new ActionContext( + httpContext.Object, + routeData, + new ActionDescriptor()); + + // Act + await result.ExecuteResultAsync(actionContext); + + // Assert + auth.Verify(); + } + [Fact] public async Task ExecuteResultAsync_InvokesSignInAsyncOnConfiguredScheme() { @@ -81,4 +108,4 @@ namespace Microsoft.AspNetCore.Mvc .BuildServiceProvider(); } } -} \ No newline at end of file +}