public void AuthenticationMessageHandler_ShouldSetNonAuthIdentity() { var context = GetContext(); var messageHandler = new AuthenticationMessageHandler(context); var cookie = new CookieHeaderValue("task-manager-token", "11111111-8B86-D011-B42D-00CF4FC964FF"); messageHandler.Authenticate(cookie); Assert.IsFalse(Thread.CurrentPrincipal.Identity.IsAuthenticated); }
public void AMH_ShouldSetRightIdentity() { var context = GetContext(); var messageHandler = new AuthenticationMessageHandler(context); var cookie = new CookieHeaderValue("task-manager-token", "6F9619FF-8B86-D011-B42D-00CF4FC964FF"); messageHandler.Authenticate(cookie); Assert.IsTrue(Thread.CurrentPrincipal.Identity.IsAuthenticated); Assert.AreEqual(Thread.CurrentPrincipal.Identity.Name, "ivan"); Assert.IsTrue(Thread.CurrentPrincipal.IsInRole("role1")); Assert.IsFalse(Thread.CurrentPrincipal.IsInRole("role2")); }