public Task HonorsTheOverriddenHandleUnauthenticatedRequestAndCallsTheInnerHandler() { //Arange string usernameAndPassword = string.Format("{0}:{1}", UserName, Password); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost"); request.Headers.Authorization = new AuthenticationHeaderValue("Basic", EncodeToBase64(usernameAndPassword)); var customBasicAuthHandlerWithEmptyUnauthImpl = new CustomBasicAuthHandlerWithEmptyUnauthImpl(); //Act return TestHelper.InvokeMessageHandler(request, customBasicAuthHandlerWithEmptyUnauthImpl) .ContinueWith(task => { //Assert Assert.Equal(TaskStatus.RanToCompletion, task.Status); Assert.Equal(HttpStatusCode.OK, task.Result.StatusCode); Assert.False(Thread.CurrentPrincipal.Identity.IsAuthenticated); }); }
public Task HonorsTheOverriddenHandleUnauthenticatedRequestAndCallsTheInnerHandler() { //Arange string usernameAndPassword = string.Format("{0}:{1}", UserName, Password); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost"); request.Headers.Authorization = new AuthenticationHeaderValue("Basic", EncodeToBase64(usernameAndPassword)); var customBasicAuthHandlerWithEmptyUnauthImpl = new CustomBasicAuthHandlerWithEmptyUnauthImpl(); //Act return(TestHelper.InvokeMessageHandler(request, customBasicAuthHandlerWithEmptyUnauthImpl) .ContinueWith(task => { //Assert Assert.Equal(TaskStatus.RanToCompletion, task.Status); Assert.Equal(HttpStatusCode.OK, task.Result.StatusCode); Assert.False(Thread.CurrentPrincipal.Identity.IsAuthenticated); })); }