public void TestFixtureSetUp() { // Create test content var db = Sitecore.Configuration.Factory.GetDatabase("master"); var home = db.GetItem("/sitecore/content/home"); using (new SecurityDisabler()) { home.Paste(File.ReadAllText(HttpContext.Current.Server.MapPath(@"~\test data\MetaBlog content.xml")), true, PasteMode.Overwrite); // Retrieve created content items m_testRoot = home.Axes.GetChild("test content"); m_blog1 = m_testRoot.Axes.GetChild("blog1"); m_blog2 = m_testRoot.Axes.GetChild("blog2"); m_blog3 = m_testRoot.Axes.GetChild("blog3"); // Ensure blog 1 entries. Current NewsMover has a bug which is removing them as they are created. // Remove the following section once the bug has been fixed // START: Workaround var template = m_blog1.Database.Templates[Settings.EntryTemplateID]; var entry11Check = m_blog1.Axes.GetDescendant("Entry11"); if (entry11Check == null) m_blog1.Add("Entry11", template); var entry12Check = m_blog1.Axes.GetDescendant("Entry12"); if (entry12Check == null) { System.Threading.Thread.Sleep(2000); m_blog1.Add("Entry12", template); } // END: Workaround // Create test users m_userAuthor = Sitecore.Security.Accounts.User.Create("sitecore\\user1", PASSWORD); m_userNothing = Sitecore.Security.Accounts.User.Create("sitecore\\user2", PASSWORD); // Add users to roles m_userAuthor.Roles.Add(Role.FromName("sitecore\\Sitecore Client Authoring")); var rules = new AccessRuleCollection(); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemWrite, PropagationType.Descendants, AccessPermission.Allow)); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemDelete, PropagationType.Descendants, AccessPermission.Allow)); m_blog1.Security.SetAccessRules(rules); m_blog2.Security.SetAccessRules(rules); ContentHelper.PublishItemAndRequiredAncestors(m_blog1, Sitecore.Configuration.Factory.GetDatabase("web")); var entry11 = m_blog1.Axes.GetDescendant("Entry11"); ContentHelper.PublishItemAndRequiredAncestors(entry11, Sitecore.Configuration.Factory.GetDatabase("web")); var entry12 = m_blog1.Axes.GetDescendant("Entry12"); ContentHelper.PublishItemAndRequiredAncestors(entry12, Sitecore.Configuration.Factory.GetDatabase("web")); // Rebuild the search index to ensure all manager calls work as expected var index = SearchManager.GetIndex(Settings.SearchIndexName); index.Rebuild(); } m_api = new Mod.MetaBlogApi(); }
public void TestFixtureSetUp() { // Create test content using (new SecurityDisabler()) { m_testContentRoot.Paste(File.ReadAllText(HttpContext.Current.Server.MapPath(@"~\test data\MetaBlog content.xml")), true, PasteMode.Overwrite); // Retrieve created content items m_testRoot = m_testContentRoot.Axes.GetChild("test content"); m_blog1 = m_testRoot.Axes.GetChild("blog1"); m_blog2 = m_testRoot.Axes.GetChild("blog2"); m_blog3 = m_testRoot.Axes.GetChild("blog3"); // Ensure blog 1 entries. Current NewsMover has a bug which is removing them as they are created. // Remove the following section once the bug has been fixed // START: Workaround var template = m_blog1.Database.Templates[Settings.EntryTemplateID]; var entry11Check = m_blog1.Axes.GetDescendant("Entry11"); if (entry11Check == null) { var entry = m_blog1.Add("Entry11", template); using (new EditContext(entry)) { entry["Entry Date"] = "20120105T233207"; } } var entry12Check = m_blog1.Axes.GetDescendant("Entry12"); if (entry12Check == null) { System.Threading.Thread.Sleep(2000); var entry = m_blog1.Add("Entry12", template); using (new EditContext(entry)) { entry["Entry Date"] = "20120106T233145"; } } // END: Workaround // Create test users // Use random usernames to ensure we're not trying to create users that might already exist m_userAuthor = Sitecore.Security.Accounts.User.Create("sitecore\\user" + m_random.Next(999999), PASSWORD); m_userNothing = Sitecore.Security.Accounts.User.Create("sitecore\\user" + m_random.Next(999999), PASSWORD); // Add users to roles m_userAuthor.Roles.Add(Role.FromName("sitecore\\Sitecore Client Authoring")); var rules = new AccessRuleCollection(); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemWrite, PropagationType.Any, AccessPermission.Allow)); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemDelete, PropagationType.Any, AccessPermission.Allow)); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemCreate, PropagationType.Any, AccessPermission.Allow)); m_blog1.Security.SetAccessRules(rules); m_blog2.Security.SetAccessRules(rules); ContentHelper.PublishItemAndRequiredAncestors(m_blog1, Sitecore.Configuration.Factory.GetDatabase("web")); var entry11 = m_blog1.Axes.GetDescendant("Entry11"); ContentHelper.PublishItemAndRequiredAncestors(entry11, Sitecore.Configuration.Factory.GetDatabase("web")); var entry12 = m_blog1.Axes.GetDescendant("Entry12"); ContentHelper.PublishItemAndRequiredAncestors(entry12, Sitecore.Configuration.Factory.GetDatabase("web")); // Rebuild the search index to ensure all manager calls work as expected #if FEATURE_CONTENT_SEARCH var index = ContentSearchManager.GetIndex(Settings.SearchIndexName); index.Rebuild(); #else var index = SearchManager.GetIndex(Settings.SearchIndexName); index.Rebuild(); #endif } m_api = new Mod.MetaBlogApi(); }
public void TestFixtureSetUp() { // Create test content var db = Sitecore.Configuration.Factory.GetDatabase("master"); var home = db.GetItem("/sitecore/content/home"); using (new SecurityDisabler()) { home.Paste(File.ReadAllText(HttpContext.Current.Server.MapPath(@"~\test data\MetaBlog content.xml")), true, PasteMode.Overwrite); // Retrieve created content items m_testRoot = home.Axes.GetChild("test content"); m_blog1 = m_testRoot.Axes.GetChild("blog1"); m_blog2 = m_testRoot.Axes.GetChild("blog2"); m_blog3 = m_testRoot.Axes.GetChild("blog3"); // Ensure blog 1 entries. Current NewsMover has a bug which is removing them as they are created. // Remove the following section once the bug has been fixed // START: Workaround var template = m_blog1.Database.Templates[Settings.EntryTemplateID]; var entry11Check = m_blog1.Axes.GetDescendant("Entry11"); if (entry11Check == null) { m_blog1.Add("Entry11", template); } var entry12Check = m_blog1.Axes.GetDescendant("Entry12"); if (entry12Check == null) { System.Threading.Thread.Sleep(2000); m_blog1.Add("Entry12", template); } // END: Workaround // Create test users m_userAuthor = Sitecore.Security.Accounts.User.Create("sitecore\\user1", PASSWORD); m_userNothing = Sitecore.Security.Accounts.User.Create("sitecore\\user2", PASSWORD); // Add users to roles m_userAuthor.Roles.Add(Role.FromName("sitecore\\Sitecore Client Authoring")); var rules = new AccessRuleCollection(); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemWrite, PropagationType.Descendants, AccessPermission.Allow)); rules.Add(AccessRule.Create(m_userAuthor, AccessRight.ItemDelete, PropagationType.Descendants, AccessPermission.Allow)); m_blog1.Security.SetAccessRules(rules); m_blog2.Security.SetAccessRules(rules); ContentHelper.PublishItemAndRequiredAncestors(m_blog1, Sitecore.Configuration.Factory.GetDatabase("web")); var entry11 = m_blog1.Axes.GetDescendant("Entry11"); ContentHelper.PublishItemAndRequiredAncestors(entry11, Sitecore.Configuration.Factory.GetDatabase("web")); var entry12 = m_blog1.Axes.GetDescendant("Entry12"); ContentHelper.PublishItemAndRequiredAncestors(entry12, Sitecore.Configuration.Factory.GetDatabase("web")); // Rebuild the search index to ensure all manager calls work as expected var index = SearchManager.GetIndex(Settings.SearchIndexName); index.Rebuild(); } m_api = new Mod.MetaBlogApi(); }