Ejemplo n.º 1
0
        public Task SuppressesTheAuthIfAlreadyAuthenticatedAndSuppressIsRequested()
        {
            //Arange
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(UserName), null);
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost");
            var suppressedCustomBasicAuthHandler = new SuppressedCustomBasicAuthHandler();

            //Act
            return(TestHelper.InvokeMessageHandler(request, suppressedCustomBasicAuthHandler)

                   .ContinueWith(task => {
                Assert.Equal(TaskStatus.RanToCompletion, task.Status);
                Assert.False(suppressedCustomBasicAuthHandler.IsAuthenticateUserCalled);
                Assert.Equal(HttpStatusCode.OK, task.Result.StatusCode);
            }));
        }
        public Task SuppressesTheAuthIfAlreadyAuthenticatedAndSuppressIsRequested()
        {
            //Arange
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(UserName), null);
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost");
            var suppressedCustomBasicAuthHandler = new SuppressedCustomBasicAuthHandler();

            //Act
            return TestHelper.InvokeMessageHandler(request, suppressedCustomBasicAuthHandler)

                .ContinueWith(task => {

                    Assert.Equal(TaskStatus.RanToCompletion, task.Status);
                    Assert.False(suppressedCustomBasicAuthHandler.IsAuthenticateUserCalled);
                    Assert.Equal(HttpStatusCode.OK, task.Result.StatusCode);
                });
        }