Inheritance: IStaticDomainCheck
        public void CheckIfStaticDomainTest(string domain, bool isStatic)
        {
            var logger = new FakeLogger();
            var serializer = new FakeDomainSerializer();

            var check = new StaticDomainCheck(logger, serializer);
            bool result = check.IsStaticDomain(domain);

            Assert.Equal(isStatic, result);
        }
Exemple #2
0
        public static MvcHtmlString GetAntiForgeryToken(this HtmlHelper helper, Uri url)
        {
            var logger = Log.Logger;
            var serializer = new ApprovedDomainSerializer();
            var check = new StaticDomainCheck(logger, serializer);
            var tokenizer = new AntiforgeryTokenizer(helper);
            string currentDomain = GetDomainName(url);

            var generator = new AntiforgeryTokenGenerator(check, tokenizer, currentDomain);
            return generator.GetAntiForgeryToken();
        }
        public void Test(string currentDomain, string expectedToken)
        {
            var logger = new FakeLogger();
            var serializer = new FakeDomainSerializer();
            var check = new StaticDomainCheck(logger, serializer);
            var tokenizer = new FakeTokenizer();

            var generator = new AntiforgeryTokenGenerator(check, tokenizer, currentDomain);
            var result = generator.GetAntiForgeryToken();
            var expected = new MvcHtmlString(expectedToken);

            Assert.Equal(expected.ToString(), result.ToString());
        }
Exemple #4
0
        public static bool IsStaticDomain(string domain = "")
        {
            if(string.IsNullOrWhiteSpace(domain))
            {
                domain = GetDomain();
            }

            var logger = Log.Logger;
            var serializer = GetSerializer();

            var check = new StaticDomainCheck(logger, serializer);

            return check.IsStaticDomain(domain);
        }