public void AdvancedUrlProvider_PageExtension(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", "PageExtension"); string pageExtensionUsageType = testFields.GetValue("PageExtensionUsageType"); string pageExtension = testFields.GetValue("PageExtension"); if (!String.IsNullOrEmpty(pageExtension)) { settings.PageExtension = pageExtension; } switch (pageExtensionUsageType) { case "AlwaysUse": settings.PageExtensionUsageType = PageExtensionUsageType.AlwaysUse; break; case "PageOnly": settings.PageExtensionUsageType = PageExtensionUsageType.PageOnly; break; case "Never": settings.PageExtensionUsageType = PageExtensionUsageType.Never; break; } ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlRewriter_VanityUrl(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); settings.DeletedTabHandlingType = DeletedTabHandlingType.Do301RedirectToPortalHome; var vanityUrl = testFields.GetValue("VanityUrl", string.Empty); var userName = testFields.GetValue("UserName", string.Empty); var redirectOld = testFields.GetValue("RedirectOldProfileUrl", string.Empty); if (!string.IsNullOrEmpty(userName)) { var user = UserController.GetUserByName(this.PortalId, userName); if (user != null) { user.VanityUrl = vanityUrl; UserController.UpdateUser(this.PortalId, user); } } if (!string.IsNullOrEmpty(redirectOld)) { settings.RedirectOldProfileUrl = Convert.ToBoolean(redirectOld); } this.ExecuteTest(settings, testFields, true); }
public void AdvancedUrlRewriter_JiraTests(Dictionary <string, string> testFields) { var testName = testFields.GetValue("Test File", string.Empty); var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", "Jira_Tests", testName + ".csv", this.PortalId); var dictionary = UrlTestFactoryClass.GetDictionary("UrlRewrite", "Jira_Tests", testName + "_dic.csv"); var homeTabId = -1; foreach (var keyValuePair in dictionary) { switch (keyValuePair.Key) { case "HomeTabId": homeTabId = this.UpdateHomeTab(int.Parse(keyValuePair.Value)); break; default: break; } } this.ExecuteTest(settings, testFields, true); if (homeTabId != -1) { this.UpdateHomeTab(homeTabId); } }
public void AdvancedUrlProvider_VanityUrl(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", testFields["TestName"], this.PortalId); var vanityUrl = testFields.GetValue("VanityUrl", string.Empty); var userName = testFields.GetValue("UserName", string.Empty); var vanityUrlPrefix = testFields.GetValue("VanityUrlPrefix", string.Empty); if (!string.IsNullOrEmpty(vanityUrlPrefix)) { settings.VanityUrlPrefix = vanityUrlPrefix; } if (!string.IsNullOrEmpty(userName)) { var user = UserController.GetUserByName(this.PortalId, userName); if (user != null) { user.VanityUrl = vanityUrl; UserController.UpdateUser(this.PortalId, user); } } this.ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlRewriter_SecureRedirect(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"]); var isClient = Convert.ToBoolean(testFields["Client"]); _securePageName = testFields["Page Name"].Trim(); PortalController.UpdatePortalSetting(PortalId, "SSLEnforced", testFields["Enforced"].Trim()); PortalController.UpdatePortalSetting(PortalId, "SSLEnabled", testFields["Enabled"].Trim()); var isSecure = Convert.ToBoolean(testFields["IsSecure"].Trim()); if (isSecure) { var tc = new TabController(); var tab = tc.GetTabByName(_securePageName, PortalId); tab.IsSecure = true; UpdateTab(tab); } settings.SSLClientRedirect = isClient; ExecuteTest(settings, testFields, true); }
public void AdvancedUrlProvider_ReplaceChars(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", testFields["TestName"]); string testPageName = testFields.GetValue("TestPageName"); TabInfo tab = null; if (!String.IsNullOrEmpty(testPageName)) { var tabName = testFields["Page Name"]; var tc = new TabController(); tab = tc.GetTabByName(tabName, PortalId); tab.TabName = testPageName; tc.UpdateTab(tab); //Refetch tab from DB tab = tc.GetTab(tab.TabID, tab.PortalID, false); } string autoAscii = testFields.GetValue("AutoAscii"); if (!String.IsNullOrEmpty(autoAscii)) { settings.AutoAsciiConvert = Convert.ToBoolean(autoAscii); } TestUtil.GetReplaceCharDictionary(testFields, settings.ReplaceCharacterDictionary); ExecuteTestForTab("Improved", tab, settings, testFields); }
public void AdvancedUrlRewriter_ReplaceChars(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); var testPageName = testFields.GetValue("TestPageName"); TabInfo tab = null; if (!string.IsNullOrEmpty(testPageName)) { var tabName = testFields["Page Name"]; tab = TabController.Instance.GetTabByName(tabName, this.PortalId); tab.TabName = testPageName; TabController.Instance.UpdateTab(tab); // Refetch tab from DB tab = TabController.Instance.GetTab(tab.TabID, tab.PortalID, false); } var autoAscii = testFields.GetValue("AutoAscii"); if (!string.IsNullOrEmpty(autoAscii)) { settings.AutoAsciiConvert = Convert.ToBoolean(autoAscii); } TestUtil.GetReplaceCharDictionary(testFields, settings.ReplaceCharacterDictionary); this.SetDefaultAlias(testFields); this.ExecuteTestForTab(tab, settings, testFields); }
public void AdvancedUrlRewriter_BasicTest(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"]); settings.PortalId = PortalId; ExecuteTest(settings, testFields, true); }
private void ExecuteTest(string test, Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", testFields["TestName"], PortalId); SetDefaultAlias(testFields); ExecuteTest(test, settings, testFields); }
public void AdvancedUrlProvider_Regex(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", testFields["TestName"]); string regexSetting = testFields["Setting"]; string regexValue = testFields["Value"]; if (!String.IsNullOrEmpty(regexValue)) { switch (regexSetting) { case "IgnoreRegex": settings.IgnoreRegex = regexValue; break; case "DoNotRewriteRegex": settings.DoNotRewriteRegex = regexValue; break; case "UseSiteUrlsRegex": settings.UseSiteUrlsRegex = regexValue; break; case "DoNotRedirectRegex": settings.DoNotRedirectRegex = regexValue; break; case "DoNotRedirectSecureRegex": settings.DoNotRedirectSecureRegex = regexValue; break; case "ForceLowerCaseRegex": settings.ForceLowerCaseRegex = regexValue; break; case "NoFriendlyUrlRegex": settings.NoFriendlyUrlRegex = regexValue; break; case "DoNotIncludeInPathRegex": settings.DoNotIncludeInPathRegex = regexValue; break; case "ValidExtensionlessUrlsRegex": settings.ValidExtensionlessUrlsRegex = regexValue; break; case "RegexMatch": settings.RegexMatch = regexValue; break; } } ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlRewriter_ForwardExternalUrls(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); var tab = TabController.Instance.GetTabByName(TestPage, this.PortalId); tab.Url = testFields["ExternalUrl"]; TabController.Instance.UpdateTab(tab); this.ExecuteTest(settings, testFields, true); }
public void AdvancedUrlRewriter_PrimaryPortalAlias(Dictionary <string, string> testFields) { string defaultAlias = testFields["DefaultAlias"]; var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"]); settings.PortalId = PortalId; string language = testFields["Language"].Trim(); string skin = testFields["Skin"].Trim(); if (!String.IsNullOrEmpty(language)) { _customLocale = new Locale { Code = language, Fallback = "en-US" }; _customLocale.Text = CultureInfo.CreateSpecificCulture(_customLocale.Code).NativeName; Localization.SaveLanguage(_customLocale); Localization.AddLanguageToPortals(_customLocale.LanguageId); } if (testFields.ContainsKey("Final Url")) { testFields["Final Url"] = testFields["Final Url"].Replace("{useAlias}", defaultAlias); } PortalController.UpdatePortalSetting(PortalId, "PortalAliasMapping", "REDIRECT"); var alias = PortalAliasController.Instance.GetPortalAlias(defaultAlias, PortalId); if (alias == null) { alias = new PortalAliasInfo { HTTPAlias = defaultAlias, PortalID = PortalId, IsPrimary = true }; if (!(String.IsNullOrEmpty(language) && String.IsNullOrEmpty(skin))) { alias.CultureCode = language; alias.Skin = skin; } PortalAliasController.Instance.AddPortalAlias(alias); } SetDefaultAlias(defaultAlias); ExecuteTest(settings, testFields, false); alias = PortalAliasController.Instance.GetPortalAlias(defaultAlias, PortalId); if (alias != null) { PortalAliasController.Instance.DeletePortalAlias(alias); } }
public void AdvancedUrlRewriter_0_PrimaryPortalAlias(Dictionary <string, string> testFields) { var defaultAlias = testFields["DefaultAlias"]; var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); var language = testFields["Language"].Trim(); var skin = testFields["Skin"].Trim(); if (!string.IsNullOrEmpty(language)) { this.customLocale = new Locale { Code = language, Fallback = "en-US" }; this.customLocale.Text = CultureInfo.GetCultureInfo(this.customLocale.Code).NativeName; Localization.SaveLanguage(this.customLocale); Localization.AddLanguageToPortals(this.customLocale.LanguageId); } if (testFields.ContainsKey("Final Url")) { testFields["Final Url"] = testFields["Final Url"].Replace("{useAlias}", defaultAlias); } PortalController.UpdatePortalSetting(this.PortalId, "PortalAliasMapping", "REDIRECT", true, "en-us"); var portalAliasService = Globals.DependencyProvider.GetRequiredService <IPortalAliasService>(); var alias = portalAliasService.GetPortalAlias(defaultAlias, this.PortalId); if (alias == null) { alias = new PortalAliasInfo(); alias.HttpAlias = defaultAlias; alias.PortalId = this.PortalId; alias.IsPrimary = true; if (!(string.IsNullOrEmpty(language) && string.IsNullOrEmpty(skin))) { alias.CultureCode = language; alias.Skin = skin; } portalAliasService.AddPortalAlias(alias); } this.SetDefaultAlias(defaultAlias); this.ExecuteTest(settings, testFields, false); alias = portalAliasService.GetPortalAlias(defaultAlias, this.PortalId); if (alias != null) { portalAliasService.DeletePortalAlias(alias); } }
public void AdvancedUrlRewriter_ReplaceSpace(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); var replaceSpaceWith = testFields.GetValue("ReplaceSpaceWith"); if (!string.IsNullOrEmpty(replaceSpaceWith)) { settings.ReplaceSpaceWith = replaceSpaceWith; } this.ExecuteTest(settings, testFields, true); }
public void AdvancedUrlRewriter_ForceLowerCase(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); var forceLowerCaseRegex = testFields.GetValue("ForceLowerCaseRegex"); if (!string.IsNullOrEmpty(forceLowerCaseRegex)) { settings.ForceLowerCaseRegex = forceLowerCaseRegex; } this.ExecuteTest(settings, testFields, true); }
public void AdvancedUrlProvider_ForceLowerCase(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", testFields["TestName"]); string forceLowerCaseRegex = testFields.GetValue("ForceLowerCaseRegex"); if (!String.IsNullOrEmpty(forceLowerCaseRegex)) { settings.ForceLowerCaseRegex = forceLowerCaseRegex; } ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlProvider_ReplaceSpace(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", testFields["TestName"]); string replaceSpaceWith = testFields.GetValue("ReplaceSpaceWith"); if (!String.IsNullOrEmpty(replaceSpaceWith)) { settings.ReplaceSpaceWith = replaceSpaceWith; } ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlProvider_SpaceEncoding(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", "SpaceEncoding"); string spaceEncoding = testFields.GetValue("SpaceEncoding"); if (!String.IsNullOrEmpty(spaceEncoding)) { settings.SpaceEncodingValue = spaceEncoding; } ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlRewriter_ForwardExternalUrls(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"]); settings.PortalId = PortalId; var tc = new TabController(); var tab = tc.GetTabByName(_testPage, PortalId); tab.Url = testFields["ExternalUrl"]; tc.UpdateTab(tab); ExecuteTest(settings, testFields, true); }
public void AdvancedUrlRewriter_DoNotRedirect(Dictionary <string, string> testFields) { var tabName = testFields["Page Name"]; var doNotRedirect = testFields["DoNotRedirect"]; var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"], this.PortalId); this.UpdateTabSetting(tabName, "DoNotRedirect", doNotRedirect); settings.UseBaseFriendlyUrls = testFields["UseBaseFriendlyUrls"]; this.ExecuteTest(settings, testFields, true); this.UpdateTabSetting(tabName, "DoNotRedirect", "False"); }
public void AdvancedUrlRewriter_SiteRootRedirect(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", "SiteRootRedirect", this.PortalId); var scheme = testFields["Scheme"]; this.ExecuteTest(settings, testFields, true); if (testFields["TestName"].Contains("Resubmit")) { var httpAlias = testFields["Alias"]; settings.DoNotRedirectRegex = scheme + httpAlias; this.ExecuteTest(settings, testFields, true); } }
public void AdvancedUrlRewriter_PrimaryPortalAlias(Dictionary <string, string> testFields) { string defaultAlias = testFields["DefaultAlias"]; var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"]); settings.PortalId = PortalId; string language = testFields["Language"].Trim(); string skin = testFields["Skin"].Trim(); if (!String.IsNullOrEmpty(language)) { _customLocale = new Locale { Code = language, Fallback = "en-US" }; _customLocale.Text = CultureInfo.CreateSpecificCulture(_customLocale.Code).NativeName; Localization.SaveLanguage(_customLocale); Localization.AddLanguageToPortals(_customLocale.LanguageId); } if (testFields.ContainsKey("Final Url")) { testFields["Final Url"] = testFields["Final Url"].Replace("{useAlias}", defaultAlias); } if (!(String.IsNullOrEmpty(language) && String.IsNullOrEmpty(skin))) { //add new primary alias _primaryAlias = new PortalAliasInfo { PortalID = PortalId, HTTPAlias = defaultAlias, CultureCode = language, Skin = skin, IsPrimary = true }; _primaryAlias.PortalAliasID = TestablePortalAliasController.Instance.AddPortalAlias(_primaryAlias); ExecuteTest(settings, testFields, true); } else { SetDefaultAlias(defaultAlias); ExecuteTest(settings, testFields, false); } }
public void AdvancedUrlRewriter_DeletedTabHandling(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", testFields["TestName"]); settings.PortalId = PortalId; var tc = new TabController(); var tab = tc.GetTabByName(_testPage, PortalId); if (Convert.ToBoolean(testFields["HardDeleted"])) { DeleteTab(_testPage); CacheController.FlushPageIndexFromCache(); } else { tab.IsDeleted = Convert.ToBoolean(testFields["SoftDeleted"]); tab.DisableLink = Convert.ToBoolean(testFields["Disabled"]); if (Convert.ToBoolean(testFields["Expired"])) { tab.EndDate = DateTime.Now - TimeSpan.FromDays(1); } UpdateTab(tab); } string deletedTabHandling = testFields.GetValue("DeletedTabHandling"); if (!String.IsNullOrEmpty(deletedTabHandling)) { switch (deletedTabHandling) { case "Do404Error": settings.DeletedTabHandlingType = DeletedTabHandlingType.Do404Error; break; default: settings.DeletedTabHandlingType = DeletedTabHandlingType.Do301RedirectToPortalHome; break; } } SetDefaultAlias(testFields); ExecuteTest(settings, testFields, true); }
public void AdvancedUrlProvider_PrimaryPortalAlias(Dictionary <string, string> testFields) { string defaultAlias = testFields["DefaultAlias"]; string redirectMode = testFields["RedirectMode"]; var settings = UrlTestFactoryClass.GetSettings("FriendlyUrl", "PrimaryPortalAlias"); string language = testFields["Language"].Trim(); if (!String.IsNullOrEmpty(language)) { _customLocale = new Locale { Code = language, Fallback = "en-US" }; _customLocale.Text = CultureInfo.CreateSpecificCulture(_customLocale.Code).NativeName; Localization.SaveLanguage(_customLocale); Localization.AddLanguageToPortals(_customLocale.LanguageId); //add new primary alias _primaryAlias = new PortalAliasInfo { PortalID = PortalId, HTTPAlias = defaultAlias, CultureCode = language, IsPrimary = true }; _primaryAlias.PortalAliasID = TestablePortalAliasController.Instance.AddPortalAlias(_primaryAlias); } else { SetDefaultAlias(defaultAlias); } PortalController.UpdatePortalSetting(PortalId, "PortalAliasMapping", redirectMode); ExecuteTest("Improved", settings, testFields); }
public void AdvancedUrlRewriter_GeminiTests(Dictionary <string, string> testFields) { var settings = UrlTestFactoryClass.GetSettings("UrlRewrite", "GeminiTests", testFields["SettingsFile"]); ExecuteTest(settings, testFields, true); }