void TestEncryptedStatusByContentName(string contentName) { Workshare.Policy.Engine.UroPolicyEngine engine = new Workshare.Policy.Engine.UroPolicyEngine(); engine.PolicyCache = new MockPolicyCache(0); UniversalRequestObject uro = TestHelpers.GetUro(Attachments.NoAttachments); TestHelpers.AddAttachment(uro, "Doc", _testFilePath + contentName, contentName); IPolicyResponseObject response = engine.ProcessPolicies(RunAt.Client, uro, ProcessLevel.Actions); IXPathNavigable report = response.XMLReport; SaveReport(report, "TestReportAgainstPasswordProtectedWordDocument"); XPathNavigator navigator = report.CreateNavigator(); string contentItemsXPath = "/PolicyResponse/ContentList/ContentPolicyList/ContentItem"; XPathNodeIterator iterator = navigator.Select(contentItemsXPath); Assert.AreEqual(response.ContentCollection.Count, iterator.Count, "There should be a ContentItem node for each entry in the PRO ContentCollection."); foreach (IContentItem item in response.ContentCollection) { // There will be a better way to do this (rather than repeatedly provide XPaths all the way from the root). iterator = navigator.Select(contentItemsXPath + "[@Name='" + item.Name + "']"); Assert.AreEqual(1, iterator.Count, "The report doesn't contain a ContentItem for " + item.Name + "."); iterator.MoveNext(); Assert.AreEqual(XmlConvert.ToBoolean(iterator.Current.GetAttribute("Encrypted", "")), item.Encrypted, item.Name + " Encrypted status does not match that of the report."); } }
public void TestReportAgainstZeroPolicies() { Workshare.Policy.Engine.UroPolicyEngine engine = new Workshare.Policy.Engine.UroPolicyEngine(); engine.PolicyCache = new MockPolicyCache(0); UniversalRequestObject uro = TestHelpers.GetUro(Attachments.NoAttachments); IPolicyResponseObject response = engine.ProcessPolicies(RunAt.Client, uro, ProcessLevel.Actions); IXPathNavigable report = response.XMLReport; SaveReport(report, "TestReportAgainstZeroPolicies"); }
public void TestBlankUroDoesntCrashSmtp_OnlyWithSubject() { string rulesxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\Default_policy_rules_sept_2006.xml")); string objectsxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\Default_policy_objects_sept_2006.xml")); UniversalRequestObject uro = new UniversalRequestObject(); uro.Properties.Add(MailMessagePropertyKeys.FileHeader, "Stuff"); uro.Properties.Add(MailMessagePropertyKeys.Subject, "subject line"); uro.PolicyType = PolicyType.ClientEmail; uro.DataTimeStamp = System.DateTime.Now; Workshare.Policy.Engine.UroPolicyEngine engine = new Workshare.Policy.Engine.UroPolicyEngine(); IPolicyCache cache = new MockPolicyCache(); cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").Content = rulesxml; cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").ObjectReferences = objectsxml; engine.PolicyCache = cache; IPolicyResponseObject pro = engine.ProcessPolicies(RunAt.Client, uro, ProcessLevel.Actions); //Assert.IsTrue(pro.ChannelType == ChannelType.SMTP); Assert.IsTrue(pro.ContentCollection.Count == 1); Assert.IsTrue(pro.ContentCollection[0].Encrypted == false); Assert.IsTrue(pro.ContentCollection[0].Name == "message subject/body"); Assert.IsTrue(pro.ContentCollection[0].Type == "Email"); Assert.IsTrue(pro.ContentCollection[0].Properties[MailMessagePropertyKeys.Subject] == "subject line"); }
public void TestPolicyResponseObject_ResolvedActionList_NoActions() { string rulesxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\ResolvedActionsRulesNoActions.xml")); string objectsxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\ResolvedActionsObjectsNoActions.xml")); UroPolicyEngine engine = new UroPolicyEngine(); IPolicyCache cache = new MockPolicyCache(); cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").Content = rulesxml; cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").ObjectReferences = objectsxml; engine.PolicyCache = cache; UniversalRequestObject uro = TestHelpers.GetUro(false); TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestProfanity.doc"), "TestProfanity.doc"); TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestPrivacy.doc"), "TestPrivacy.doc"); IPolicyResponseObject pro = engine.ProcessPolicies(RunAt.Client, uro, ProcessLevel.Actions); // There are no actions. Assert.IsTrue(pro.ResolvedActionCollection.Count == 0); }
public void TestPolicyResponseObject_ResolvedActionList_TwoActionsWithDuplicateFileNamesDoesntGetConfused() { string rulesxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\ResolvedActionsRules01.xml")); string objectsxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\ResolvedActionsObjects01.xml")); UroPolicyEngine engine = new UroPolicyEngine(); IPolicyCache cache = new MockPolicyCache(); cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").Content = rulesxml; cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").ObjectReferences = objectsxml; engine.PolicyCache = cache; UniversalRequestObject uro = TestHelpers.GetUro(false); TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestProfanity.doc"), "TestProfanity.doc"); TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestProfanity.doc"), "TestProfanity.doc"); IPolicyResponseObject pro = engine.ProcessPolicies(RunAt.Client, uro, ProcessLevel.Actions); Assert.AreEqual(2, pro.ResolvedActionCollection.Count); IResolvedAction resolvedAction = pro.ResolvedActionCollection[0]; Assert.AreEqual("Client_Block", resolvedAction.ResponseAction.Name); Assert.AreEqual(1, resolvedAction.ContentCollection.Count); Assert.AreEqual("message subject/body", resolvedAction.ContentCollection[0].Name); resolvedAction = pro.ResolvedActionCollection[1]; Assert.AreEqual("HD_Remove", resolvedAction.ResponseAction.Name); Assert.AreEqual(2, resolvedAction.ContentCollection.Count); Assert.AreEqual("TestProfanity.doc", Path.GetFileName(resolvedAction.ContentCollection[0].Name)); Assert.AreEqual("TestProfanity.doc", Path.GetFileName(resolvedAction.ContentCollection[1].Name)); }
static IXPathNavigable GenerateTypicalReport() { string rulesxml = System.IO.File.ReadAllText(_testFilePath + "ResolvedActionsRules01.xml"); string objectsxml = System.IO.File.ReadAllText(_testFilePath + "ResolvedActionsObjects01.xml"); Workshare.Policy.Engine.UroPolicyEngine engine = new Workshare.Policy.Engine.UroPolicyEngine(); IPolicyCache cache = new MockPolicyCache(); cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").Content = rulesxml; cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("SMTP", "Client").ObjectReferences = objectsxml; engine.PolicyCache = cache; UniversalRequestObject uro = TestHelpers.GetUro(Attachments.NoAttachments); TestHelpers.AddAttachment(uro, "Doc", _testFilePath + "TestPrivacy.doc", "TestPrivacy.doc"); TestHelpers.AddAttachment(uro, "Doc", _testFilePath + "TestProfanity.doc", "TestProfanity.doc"); IPolicyResponseObject response = engine.ProcessPolicies(RunAt.Client, uro, ProcessLevel.Actions); return response.XMLReport; }