Пример #1
0
        public void Should_Allow_External_Urls()
        {
            var service = new DefaultUrlService(null, null);

            validInternalUrls.ToList().ForEach(url => Assert.IsTrue(service.ValidateExternalUrl(url), string.Format("URL must be valid: '{0}'", url)));
            validExternalUrls.ToList().ForEach(url => Assert.IsTrue(service.ValidateExternalUrl(url), string.Format("URL must be valid: '{0}'", url)));
        }
Пример #2
0
        private DefaultBlogMLService GetBlogService(IRepository repository, IBlogService blogService, IRedirectService redirectService = null)
        {
            if (redirectService == null)
            {
                redirectService = new Mock <IRedirectService>().Object;
            }
            var unitOfWork          = new Mock <IUnitOfWork>().Object;
            var pageService         = new Mock <IPageService>().Object;
            var cmsConfiguration    = new Mock <ICmsConfiguration>().Object;
            var httpContextAccessor = new Mock <IHttpContextAccessor>().Object;
            var urlService          = new DefaultUrlService(unitOfWork, new CmsConfigurationSection());

            var importService = new DefaultBlogMLService(repository, urlService, blogService, unitOfWork, redirectService, pageService, cmsConfiguration, httpContextAccessor);

            return(importService);
        }
Пример #3
0
        public void Should_Deny_Urls()
        {
            var service = new DefaultUrlService(null, null);

            var invalidUrls = new[]
            {
                @"//",
                @"a//a",
                @"b//a/",
                @"c/a/a/a/a/a/a/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1/a",
                @"dsdasd\asdasdasdas",
                @"esdas$asdasdasdasd",
            }.ToList();

            invalidUrls.ForEach(url => Assert.IsFalse(service.ValidateUrl(url), string.Format("URL must be invalid: '{0}'", url)));
        }
Пример #4
0
        public void Should_Allow_Urls()
        {
            var service = new DefaultUrlService(null, null);

            var validUrls = new[]
            {
                @"/",
                @"/a/",
                @"bsd-asd",
                @"c/a",
                @"d/a/a/a/a/a/a/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/a",
                @"e/a/a/a/a/a/a/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaa/a",
                @"/fasd/aasd/aasd/aasdasdad/aasdasd/asdasda/žaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/a",
                @"gsad/aa",
                @"/hasd",
                @"/j",
                @"/ksdasdasd/",
                @"/شسیللانتلان/",
                @"/уцкевапрнгш-енгшен/",
            }.ToList();

            validUrls.ForEach(url => Assert.IsTrue(service.ValidateUrl(url), string.Format("URL must be valid: '{0}'", url)));
        }
Пример #5
0
        public void Should_Deny_Internal_Urls()
        {
            var service = new DefaultUrlService(null, null);

            invalidInternalUrls.ToList().ForEach(url => Assert.IsFalse(service.ValidateInternalUrl(url), string.Format("URL must be invalid: '{0}'", url)));
        }
Пример #6
0
        public void Should_Allow_InternalUrlsWithQueryString()
        {
            var service = new DefaultUrlService(null, null);

            validInternalUrlsWithQueryString.ForEach(url => Assert.IsTrue(service.ValidateInternalUrlWithQueryString(url), string.Format("URL must be valid: '{0}'", url)));
        }