Exemplo n.º 1
0
        public async Task ExecuteResultAsync_InvokesForbidAsyncWithAuthProperties(AuthenticationProperties expected)
        {
            // Arrange
            var auth = new Mock <IAuthenticationService>();

            auth
            .Setup(c => c.ForbidAsync(It.IsAny <HttpContext>(), null, expected))
            .Returns(Task.CompletedTask)
            .Verifiable();
            var result      = new ForbidResult(expected);
            var httpContext = GetHttpContext(auth.Object);

            // Act
            await result.ExecuteAsync(httpContext);

            // Assert
            auth.Verify();
        }
Exemplo n.º 2
0
        public async Task ExecuteResultAsync_InvokesForbidAsyncOnAllConfiguredSchemes()
        {
            // Arrange
            var authProperties = new AuthenticationProperties();
            var auth           = new Mock <IAuthenticationService>();

            auth
            .Setup(c => c.ForbidAsync(It.IsAny <HttpContext>(), "Scheme1", authProperties))
            .Returns(Task.CompletedTask)
            .Verifiable();
            auth
            .Setup(c => c.ForbidAsync(It.IsAny <HttpContext>(), "Scheme2", authProperties))
            .Returns(Task.CompletedTask)
            .Verifiable();
            var httpContext = GetHttpContext(auth.Object);
            var result      = new ForbidResult(new[] { "Scheme1", "Scheme2" }, authProperties);
            var routeData   = new RouteData();

            // Act
            await result.ExecuteAsync(httpContext);

            // Assert
            auth.Verify();
        }