//[ExpectedException(typeof(ArgumentNullException), "Value cannot be null.")] public async Task AuthenticateAsync_ShouldSetPrincipal() { HttpRequestMessage request = new HttpRequestMessage(); HttpControllerContext controllerContext = new HttpControllerContext(); controllerContext.Request = request; HttpActionContext context = new HttpActionContext(); context.ControllerContext = controllerContext; HttpAuthenticationContext m = new HttpAuthenticationContext(context, null); HttpRequestHeaders headers = request.Headers; AuthenticationHeaderValue authorization = new AuthenticationHeaderValue("scheme"); headers.Authorization = null; CancellationToken token = new CancellationToken(); AnetMerchantAuthenticationAttribute merchantAuth = new AnetMerchantAuthenticationAttribute(); IPrincipal principal = await AuthenticateAsync("useofforce", "123abc", token); Assert.AreEqual(principal.Identity.IsAuthenticated, true); }
public async Task AuthenticateAsync_ShouldReturnForAuthenticationNull() { HttpRequestMessage request = new HttpRequestMessage(); HttpControllerContext controllerContext = new HttpControllerContext(); controllerContext.Request = request; HttpActionContext context = new HttpActionContext(); context.ControllerContext = controllerContext; HttpAuthenticationContext m = new HttpAuthenticationContext(context, null); HttpRequestHeaders headers = request.Headers; AuthenticationHeaderValue authorization = new AuthenticationHeaderValue("scheme"); headers.Authorization = null; CancellationToken token = new CancellationToken(); AnetMerchantAuthenticationAttribute merchantAuth = new AnetMerchantAuthenticationAttribute(); IPrincipal principal = await AuthenticateAsync("", "", token); Assert.IsNull(principal); }