public void TestProcessFile_BigFile() { string rulesxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\rules-en-GB.xml")); string objectsxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\PolicyObjects.xml")); Workshare.Policy.Engine.UroPolicyEngine engineU = 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; engineU.PolicyCache = cache; UniversalRequestObject uro = GetUro3(false); uro.Properties[MailMessagePropertyKeys.Body] = "This is a safe email"; TestHelpers.AddAttachment(uro, new Workshare.Policy.Engine.File(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\Big_Test.doc"), "AppSpec")); engineU.Monitor(RunAt.Client, uro, !true); PolicyResponseObject upi = engineU.Upi as PolicyResponseObject; ContentItem content = upi.ContentCollection[0] as ContentItem; PolicySetResponse policySet = content.PolicySetCollection[0] as PolicySetResponse; Assert.IsTrue(policySet.PolicyReportCollection[0].Name == "Classified Information Disclosure"); Assert.IsTrue(policySet.PolicyReportCollection[0].Triggered == false); Assert.IsTrue(policySet.PolicyReportCollection[1].Name == "Hidden Information Disclosure"); Assert.IsTrue(policySet.PolicyReportCollection[1].Triggered == false); Assert.IsTrue(policySet.PolicyReportCollection[2].Name == "Private Information Disclosure"); Assert.IsTrue(policySet.PolicyReportCollection[2].Triggered == false); Assert.IsTrue(policySet.PolicyReportCollection[3].Name == "Profane Language"); Assert.IsTrue(policySet.PolicyReportCollection[3].Triggered == false); Assert.IsTrue(policySet.PolicyReportCollection[4].Name == "Discriminatory Language"); Assert.IsTrue(policySet.PolicyReportCollection[4].Triggered == false); Assert.IsTrue(policySet.PolicyReportCollection[5].Name == "Metadata/Security Disclosure"); Assert.IsTrue(policySet.PolicyReportCollection[5].Triggered == true); }
public void TestProcessMessageContent_Monitor() { string rulesxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestProcessMessageContentRulesU.xml")); string objectsxml = System.IO.File.ReadAllText(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestProcessMessageContentObjectsU.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; // MockUroPolicyAuditor auditor = new MockUroPolicyAuditor(); // engine.SetPolicyAuditor(auditor); UniversalRequestObject uro = TestHelpers.GetUro(true); engine.Monitor(RunAt.Client, uro, true); PolicyResponseObject pui = engine.Upi; ContentItem content = pui.ContentCollection[3] as ContentItem; PolicySetResponse policySet = content.PolicySetCollection[0] as PolicySetResponse; IPolicyResponse pi = policySet.PolicyReportCollection[0]; Assert.IsTrue(pi.Name == "Privacy"); Assert.IsTrue(pi.Triggered == true); Assert.IsTrue(pi.ExpressionCollection[0].Name == "Possible Social Security Number"); Assert.IsTrue(pi.ExpressionCollection[0].Triggered == false); Assert.IsTrue(pi.ExpressionCollection[1].Name == "Possible Credit Card Number"); Assert.IsTrue(pi.ExpressionCollection[1].Triggered == true); Assert.IsTrue(pi.ExpressionCollection[1].ExpressionDetailCollection[0].Name == "Body"); Assert.IsTrue(pi.ExpressionCollection[1].ExpressionDetailCollection[0].Value == "4408 0412 3456 7890"); Assert.IsTrue(pi.Routing.Name == "Privacy"); RoutingResponse routing = pi.Routing as RoutingResponse; Assert.IsTrue(routing.RoutingId == "Privacy_Routing"); content = pui.ContentCollection[3] as ContentItem; policySet = content.PolicySetCollection[0] as PolicySetResponse; IPolicyResponse pi3 = policySet.PolicyReportCollection[1]; Assert.IsTrue(pi3.Name == "Profanity"); Assert.IsTrue(pi3.Triggered == false); content = pui.ContentCollection[1] as ContentItem; policySet = content.PolicySetCollection[0] as PolicySetResponse; IPolicyResponse pi1 = policySet.PolicyReportCollection[1]; Assert.IsTrue(pi1.Routing.Name == "Profanity"); routing = pi1.Routing as RoutingResponse; Assert.IsTrue(routing.RoutingId == "Profanity_Routing"); //ExpressionResponse expression = pi1.ExpressionCollection[1] as ExpressionResponse; RoutingResponse routingResponse = pi1.Routing as RoutingResponse; Assert.IsTrue(routingResponse.ActionSetId == "Profanity_bad"); //Assert.IsTrue(expression.ActionSetId == "Profanity_bad"); content = pui.ContentCollection[3] as ContentItem; policySet = content.PolicySetCollection[0] as PolicySetResponse; pi3 = policySet.PolicyReportCollection[0]; //expression = pi3.ExpressionCollection[2] as ExpressionResponse; routingResponse = pi3.Routing as RoutingResponse; Assert.IsTrue(routingResponse.ActionSetId == "Privacy_Privileged_NonTrusted_Actions"); // Assert.IsTrue(expression.Type == "ROUTING"); }