public async Task Invoke_WithoutAuthenticatedUser_ContinuesPipeline() { var httpContext = new DefaultHttpContext(); var handler = new Mock <IGraphApiClaimsHandler>(); var nextExecuted = false; var middleware = new GraphApiClaimsMiddleware(_ => { nextExecuted = true; return(Task.CompletedTask); }); await middleware.Invoke(httpContext, handler.Object); nextExecuted.Should().BeTrue(); }
public async Task Invoke_WithInsufficientlyAuthenticatedUser_ContinuesPipeline() { var httpContext = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity("test")) }; var handler = new Mock <IGraphApiClaimsHandler>(); handler.Setup(x => x.AddClaimsAsync(httpContext, It.IsAny <CancellationToken>())) .ReturnsAsync(false); var nextExecuted = false; var middleware = new GraphApiClaimsMiddleware(_ => { nextExecuted = true; return(Task.CompletedTask); }); await middleware.Invoke(httpContext, handler.Object); nextExecuted.Should().BeFalse(); }