public void TestFirstInitialVersionSetToActiveOnPublishAndReadOnly() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); string newpolicyset = Guid.NewGuid().ToString(); IPolicySetCache set = cache.NewPolicySet(newpolicyset); IPolicySetVersionCache ver1 = set.NewVersion("ver1"); IPolicyCatalogueCache masterCat = ver1.NewMasterCatalogue("<cat>the master</cat>"); IPolicyLanguageTableCache master_eng = masterCat.NewLanguage("en", "<lang>english</lang>", true); IPolicyLanguageTableCache master_fr = masterCat.NewLanguage("fr", "<lang>french</lang>", true); ICompiledPolicySetCache cps_1 = ver1.NewCompiledPolicySet("stmp", "client", "<cps>stuff</cps>", "<obj>stuff</obj>"); ICompiledPolicySetCache cps_2 = ver1.NewCompiledPolicySet("stmp", "server", "<cps>stuff</cps>", "<obj>stuff</obj>"); IPolicyLanguageTableCache cps_1_eng = cps_1.NewLanguage("en", "<lang>english</lang>", true); IPolicyLanguageTableCache cps_1_fr = cps_1.NewLanguage("fr", "<lang>french</lang>", true); IPolicyLanguageTableCache cps_2_eng = cps_2.NewLanguage("en", "<lang>english</lang>", true); IPolicyLanguageTableCache cps_2_fr = cps_2.NewLanguage("fr", "<lang>french</lang>", true); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.InProgress); set.Save(SaveOption.Publish); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.Enabled); Assert.IsTrue(ver1.Latest); set.Save(SaveOption.SaveNew); CacheTestHelper.TestVersionIsReadOnly(ver1); IPolicySetVersionCache ver2 = set.LatestVersion; Assert.AreEqual(ver2.Status, PolicySetVersionStatus.InProgress); Assert.IsTrue(ver2.Latest); Assert.AreNotEqual(ver1.Version, ver2.Version); Assert.AreEqual(ver1.Content, ver2.Content); Assert.AreEqual(ver1.MasterCatalogue.Content, ver2.MasterCatalogue.Content); Assert.AreEqual(ver1.MasterCatalogue.Languages.Count, ver2.MasterCatalogue.Languages.Count); for (int i = 0; i < ver1.MasterCatalogue.Languages.Count; i++) Assert.AreEqual(ver1.MasterCatalogue.Languages[i].Content, ver2.MasterCatalogue.Languages[i].Content); Assert.AreEqual(ver1.CompiledPolicySets.Count, ver2.CompiledPolicySets.Count); for (int i = 0; i < ver1.CompiledPolicySets.Count; i++) { Assert.AreEqual(ver1.CompiledPolicySets[i].Channel, ver2.CompiledPolicySets[i].Channel); Assert.AreEqual(ver1.CompiledPolicySets[i].Target, ver2.CompiledPolicySets[i].Target); Assert.AreEqual(ver1.CompiledPolicySets[i].Content, ver2.CompiledPolicySets[i].Content); Assert.AreEqual(ver1.CompiledPolicySets[i].ObjectReferences, ver2.CompiledPolicySets[i].ObjectReferences); Assert.AreEqual(ver1.CompiledPolicySets[i].Languages.Count, ver2.CompiledPolicySets[i].Languages.Count); for (int j = 0; j < ver1.CompiledPolicySets[i].Languages.Count; j++) Assert.AreEqual(ver1.CompiledPolicySets[i].Languages[j].Content, ver2.CompiledPolicySets[i].Languages[j].Content); } }
public void TestFirstInitialVersionOfPolicySetIsInProgress() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); string newpolicyset = Guid.NewGuid().ToString(); IPolicySetCache set = cache.NewPolicySet(newpolicyset); IPolicySetVersionCache ver1 = set.NewVersion("ver1"); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.InProgress); set.Save(SaveOption.SaveOnly); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.InProgress); }
public void TestIDZeroedForCopiedObjects() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); LocalPolicySetCache set = cache.NewPolicySet("steve") as LocalPolicySetCache; LocalPolicySetVersionCache ver1 = set.LatestVersion as LocalPolicySetVersionCache; ver1.ID = 100; LocalPolicyCatalogueCache master = ver1.NewMasterCatalogue("hello") as LocalPolicyCatalogueCache; master.ID = 101; LocalPolicyLanguageTableCache lang = master.NewLanguage("en", "stuff", true) as LocalPolicyLanguageTableCache; lang.ID = 102; set.Save(SaveOption.Publish); set.Save(SaveOption.SaveNew); LocalPolicySetVersionCache ver2 = set.LatestVersion as LocalPolicySetVersionCache; Assert.AreEqual(ver2.ID, 0); LocalPolicyCatalogueCache master2 = ver2.MasterCatalogue as LocalPolicyCatalogueCache; Assert.AreEqual(master2.ID, 0); LocalPolicyLanguageTableCache lang2 = master2.Languages[0] as LocalPolicyLanguageTableCache; Assert.AreEqual(lang2.ID, 0); System.IO.File.Delete(m_testFiles.RootPath + "steve" + Definitions.PolicyFileExtension); }
public void TestReActivateDisabledPolicy() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); string newpolicyset = Guid.NewGuid().ToString(); IPolicySetCache set = cache.NewPolicySet(newpolicyset); IPolicySetVersionCache ver1 = set.NewVersion("ver1"); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.InProgress); set.Save(SaveOption.Disable); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.InProgress); set.Save(SaveOption.Publish); Assert.AreEqual(ver1.Status, PolicySetVersionStatus.Enabled); }
public void TestCreateDefaultPolicyPack() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); LocalPolicySetCache set = cache.NewPolicySet("P5-default") as LocalPolicySetCache; Assert.IsNotNull(set); string policy = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5-policy.xml"); string catalogue = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5-cat.xml"); string language = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5-en.xml"); string smtp_client_policy = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_client_rules.xml"); string smtp_client_objects = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_client_objects.xml"); string smtp_server_policy = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_server_smtp_rules.xml"); string smtp_server_objects = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_server_smtp_objects.xml"); string http_server_policy = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_server_http_rules.xml"); string http_server_objects = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_server_http_objects.xml"); string file_client_policy = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_client_activecontent_rules.xml"); string file_client_objects = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_client_activecontent_objects.xml"); string smart_tag_policy = m_testFiles.GetXmlFromResource(this.GetType(), "Workshare.Policy.ClientCache.Tests.TestFiles.Default.p5_beta_client_smarttag_policy.xml"); LocalPolicySetVersionCache version = set.LatestVersion as LocalPolicySetVersionCache; version.Content = policy; LocalPolicyCatalogueCache masterCat = version.NewMasterCatalogue(catalogue) as LocalPolicyCatalogueCache; masterCat.NewLanguage("en", language, true); version.NewCompiledPolicySet("SMTP", "Client", smtp_client_policy, smtp_client_objects); version.NewCompiledPolicySet("SMTP", "Server", smtp_server_policy, smtp_server_objects); version.NewCompiledPolicySet("HTTP", "Server", http_server_policy, http_server_objects); version.NewCompiledPolicySet("ActiveContent", "Client", file_client_policy, file_client_objects); version.NewCompiledPolicySet("SmartTagActiveContent", "Client", smart_tag_policy, string.Empty); string p5policyfile = System.IO.Path.GetTempFileName(); set.ExportCompiledPolicySet(p5policyfile); LocalPolicySetCache newset = cache.GetPolicySet("P5-default") as LocalPolicySetCache; Assert.IsNotNull(newset); //System.IO.File.Copy(p5policyfile, Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\Policies\p5default.policy"), true); System.IO.File.Delete(p5policyfile); System.IO.File.Delete(m_testFiles.RootPath + "P5-default" + Definitions.PolicyFileExtension); }
public void TestNewSetAddedToList() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); Assert.AreEqual(cache.PolicySets.Count, 2); cache.NewPolicySet("steve"); Assert.AreEqual(cache.PolicySets.Count, 3); }
public void TestAutomaticallyCreateNewVersionOnNewPolicySet() { LocalPolicyCache cache = new LocalPolicyCache(m_testFiles.RootPath, false); LocalPolicySetCache set = cache.NewPolicySet("steve") as LocalPolicySetCache; Assert.IsNotNull(set); Assert.IsNotNull(set.LatestVersion); Assert.AreEqual(set.LatestVersion.Content, ""); }
public void TestCreateNewCompiledPolicySetLanguages() { LocalPolicyCache lpc = new LocalPolicyCache(m_testFiles.RootPath, false); Assert.IsNotNull(lpc); IPolicySetCache lps = lpc.NewPolicySet("policyset4"); Assert.IsNotNull(lps); IPolicySetVersionCache lpsv = lps.NewVersion("<policysetxml>this is the content of the policy set for v1.0</policysetxml>"); Assert.IsNotNull(lpsv); ICompiledPolicySetCache cpsc = lpsv.NewCompiledPolicySet("SMTP", "Client", "<Policy>this is the compiled policy</Policy>", "<Objects>the is the compiled policy objects</Objects>"); Assert.IsNotNull(cpsc); IPolicyLanguageTableCache cpsc_eng = cpsc.NewLanguage("en", "<language>this is the language content for english for compiled policy set</language>", true); Assert.IsNotNull(cpsc_eng); IPolicyLanguageTableCache cpsc_jp = cpsc.NewLanguage("jp", "<language>this is the language content for japanese for compiled policy set</language>", false); Assert.IsNotNull(cpsc_jp); lps.Save(SaveOption.SaveOnly); IPolicySetCache lps2 = new LocalPolicySetCache(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); Assert.IsNotNull(lps2); Assert.AreEqual(1, lps2.PolicySetVersions.Count); IPolicySetVersionCache lpsv2 = lps2.PolicySetVersions[0]; Assert.IsNotNull(lpsv2); ICompiledPolicySetCache cps = lpsv2.GetCompiledPolicySet("SMTP", "Client"); Assert.IsNotNull(cps); IPolicyLanguageTableCache pl_eng = cps.Languages[0]; Assert.IsNotNull(pl_eng); Assert.AreEqual(pl_eng.Content, "<language>this is the language content for english for compiled policy set</language>"); Assert.AreEqual(pl_eng.Language.Code, "en"); IPolicyLanguageTableCache pl_jp = cps.Languages[1]; Assert.IsNotNull(pl_jp); Assert.AreEqual(pl_jp.Content, "<language>this is the language content for japanese for compiled policy set</language>"); Assert.AreEqual(pl_jp.Language.Code, "jp"); System.IO.File.Delete(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); }
public void TestCreateNewCompiledPolicySets() { LocalPolicyCache lpc = new LocalPolicyCache(m_testFiles.RootPath, false); Assert.IsNotNull(lpc); IPolicySetCache lps = lpc.NewPolicySet("policyset4"); Assert.IsNotNull(lps); IPolicySetVersionCache lpsv = lps.NewVersion("<policysetxml>this is the content of the policy set for v1.0</policysetxml>"); Assert.IsNotNull(lpsv); ICompiledPolicySetCache cpsc = lpsv.NewCompiledPolicySet("SMTP", "Client", "<Policy>this is the compiled policy</Policy>", "<Objects>the is the compiled policy objects</Objects>"); Assert.IsNotNull(cpsc); lps.Save(SaveOption.SaveOnly); IPolicySetCache lps2 = new LocalPolicySetCache(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); Assert.IsNotNull(lps2); Assert.AreEqual(1, lps2.PolicySetVersions.Count); IPolicySetVersionCache lpsv2 = lps2.PolicySetVersions[0]; Assert.IsNotNull(lpsv2); ICompiledPolicySetCache cps = lpsv2.GetCompiledPolicySet("SMTP", "Client"); Assert.IsNotNull(cps); Assert.AreEqual(cps.Channel, "SMTP"); Assert.AreEqual(cps.Target, "Client"); Assert.AreEqual(cps.Content, "<Policy>this is the compiled policy</Policy>"); Assert.AreEqual(cps.ObjectReferences, "<Objects>the is the compiled policy objects</Objects>"); System.IO.File.Delete(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); }
public void TestCreateNewCatalogueLanguages() { LocalPolicyCache lpc = new LocalPolicyCache(m_testFiles.RootPath, false); Assert.IsNotNull(lpc); IPolicySetCache lps = lpc.NewPolicySet("policyset4"); Assert.IsNotNull(lps); IPolicySetVersionCache lpsv = lps.NewVersion("<policysetxml>this is the content of the policy set for v1.0</policysetxml>"); Assert.IsNotNull(lpsv); IPolicyCatalogueCache mastercat = lpsv.NewMasterCatalogue("<mastercatalogue>this is the conent of the master catalogue</mastercatalogue>"); Assert.IsNotNull(mastercat); IPolicyLanguageTableCache engLang = mastercat.NewLanguage("en", "<language>this is the language content for english for master cat</language>", true); Assert.IsNotNull(engLang); IPolicyLanguageTableCache jpLang = mastercat.NewLanguage("jp", "<language>this is the language content for japanese for master cat</language>", false); Assert.IsNotNull(jpLang); lps.Save(SaveOption.SaveOnly); IPolicySetCache lps2 = new LocalPolicySetCache(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); Assert.IsNotNull(lps2); Assert.AreEqual(1, lps2.PolicySetVersions.Count); IPolicySetVersionCache lpsv2 = lps2.PolicySetVersions[0]; Assert.IsNotNull(lpsv2); IPolicyCatalogueCache pcm = lpsv2.MasterCatalogue; Assert.IsNotNull(pcm); IPolicyLanguageTableCache pl_eng = pcm.Languages[0]; Assert.IsNotNull(pl_eng); Assert.AreEqual(pl_eng.Content, "<language>this is the language content for english for master cat</language>"); Assert.AreEqual(pl_eng.Language.Code, "en"); IPolicyLanguageTableCache pl_jp = pcm.Languages[1]; Assert.IsNotNull(pl_jp); Assert.AreEqual(pl_jp.Content, "<language>this is the language content for japanese for master cat</language>"); Assert.AreEqual(pl_jp.Language.Code, "jp"); System.IO.File.Delete(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); }
public void TestCreateNewCatalogues() { LocalPolicyCache lpc = new LocalPolicyCache(m_testFiles.RootPath, false); Assert.IsNotNull(lpc); IPolicySetCache lps = lpc.NewPolicySet("policyset4"); Assert.IsNotNull(lps); IPolicySetVersionCache lpsv = lps.NewVersion("<policysetxml>this is the content of the policy set for v1.0</policysetxml>"); Assert.IsNotNull(lpsv); IPolicyCatalogueCache mastercat = lpsv.NewMasterCatalogue("<mastercatalogue>this is the conent of the master catalogue</mastercatalogue>"); Assert.IsNotNull(mastercat); IPolicyCatalogueCache refcat = lpsv.NewReferenceCatalgue("<refcatalogue>this is the conent of the reference catalogue</refcatalogue>"); Assert.IsNotNull(refcat); lps.Save(SaveOption.SaveOnly); IPolicySetCache lps2 = new LocalPolicySetCache(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); Assert.IsNotNull(lps2); Assert.AreEqual(1, lps2.PolicySetVersions.Count); IPolicySetVersionCache lpsv2 = lps2.PolicySetVersions[0]; Assert.IsNotNull(lpsv2); IPolicyCatalogueCache pcm = lpsv2.MasterCatalogue; Assert.IsNotNull(pcm); Assert.AreEqual(pcm.Content, "<mastercatalogue>this is the conent of the master catalogue</mastercatalogue>"); IPolicyCatalogueCache pcr = lpsv2.ReferenceCatalogues[0]; Assert.IsNotNull(pcr); Assert.AreEqual(pcr.Content, "<refcatalogue>this is the conent of the reference catalogue</refcatalogue>"); System.IO.File.Delete(m_testFiles.RootPath + "\\policyset4" + Definitions.PolicyFileExtension); }