Exemple #1
0
        public void Can_Validate_Generated_Tokens()
        {
            using (var writer = new StringWriter())
            {
                HttpContext.Current = new HttpContext(new HttpRequest("test.html", "http://test/", ""), new HttpResponse(writer));

                string cookieToken, headerToken;
                AngularAntiForgeryHelper.GetTokens(out cookieToken, out headerToken);

                Assert.AreEqual(true, AngularAntiForgeryHelper.ValidateTokens(cookieToken, headerToken));
            }
        }
Exemple #2
0
        public void Can_Validate_Generated_Tokens_With_User()
        {
            using (var writer = new StringWriter())
            {
                HttpContext.Current = new HttpContext(new HttpRequest("test.html", "http://test/", ""), new HttpResponse(writer))
                {
                    User = new GenericPrincipal(new HttpListenerBasicIdentity("test", "test"), new string[] {})
                };

                string cookieToken, headerToken;
                AngularAntiForgeryHelper.GetTokens(out cookieToken, out headerToken);

                Assert.AreEqual(true, AngularAntiForgeryHelper.ValidateTokens(cookieToken, headerToken));
            }
        }