public void TestAddPolicySetWindow()
        {
            //setup
            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.Reset();
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");
            languageStore.AddLanguage(language);
            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);
            IPolicyStore policyStore = new XmlStore();

            //try to add two policy sets with the same GUID. Should create two nodes in the tree, each with
            //unique GUIDs, and with the tree node GUIDs unequal to the policy set GUIDs. This proves we can load two .policy files
            //each with the same GUID without things screwing up.
            Guid policySetGuid = new Guid("{8D6C9D98-0B49-4dbe-9AE8-CEE5DC6535BF}");
            IPolicySet policySet1 = new PolicySet(policySetGuid, new TranslateableLanguageItem("PolicySet1"), policyStore, policyCatalogue, false);
            IPolicySet policySet2 = new PolicySet(policySetGuid, new TranslateableLanguageItem("PolicySet2"), policyStore, policyCatalogue, false);

            PolicySetExplorerForm policySetExplorerForm = new PolicySetExplorerForm();
            policySetExplorerForm.AddPolicySetWindow(policySet1, Workshare.Policy.Interfaces.PolicySetVersionStatus.Disabled, "1.0");
            policySetExplorerForm.AddPolicySetWindow(policySet2, Workshare.Policy.Interfaces.PolicySetVersionStatus.Disabled, "1.0");

            Assert.AreEqual(2, policySetExplorerForm.TreeView.Nodes.Count, "unexpected number of nodes in tree");
            Assert.AreNotEqual(((TreeObject)policySetExplorerForm.TreeView.Nodes[0]).Guid, ((TreeObject)policySetExplorerForm.TreeView.Nodes[1]).Guid, ("Treeview node GIUDs match"));
            Assert.AreNotEqual(policySetGuid, ((TreeObject)policySetExplorerForm.TreeView.Nodes[0]).Guid, ("Treeview node GIUD matches policy set GUID"));
            Assert.AreNotEqual(policySetGuid, ((TreeObject)policySetExplorerForm.TreeView.Nodes[1]).Guid, ("Treeview node GIUD matches policy set GUID"));
        }
예제 #2
0
 public PolicyCatalogue(PolicyCatalogue rhs, bool readOnly)
     : base(rhs, readOnly, false)
 {
     m_catalogueReader = rhs.m_catalogueReader;
     m_languageId = rhs.m_languageId;
     CopyInternals(this, rhs, readOnly, false);
 }
예제 #3
0
        public void TestAddConditionGroupWithChildren()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);
            Assert.AreEqual(0, policyCatalogue.ConditionGroups.Count);

            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{5823E98A-1F4D-44B9-BC0E-A538BD2C9262}"), new TranslateableLanguageItem("Test group"), ConditionLogic.AND, false);
            IConditionGroup subConditionGroup = new ConditionGroup(new Guid("{B87DF614-2400-4C1F-BEA8-3C2EB3964EAE}"), new TranslateableLanguageItem("Test sub group"), ConditionLogic.AND, false);
            ICondition condition = new Condition(new Guid("{98C73BC3-3E20-403C-8023-C91E2818355F}"), "TestClass", new TranslateableLanguageItem("This is a test"), OperatorType.Equals);
            subConditionGroup.Conditions.Add(condition);
            conditionGroup.Conditions.Add(subConditionGroup);

            policySetObserver.AddObject(conditionGroup);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count);
            Assert.AreEqual(2, policyCatalogue.ConditionGroups.Count);
        }
        public void TestWriteChannelAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test channel";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            Guid catalogueGuid = new Guid("{93634DD0-904C-435E-B282-4E650E55E90D}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            PolicyChannel channel = new PolicyChannel(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), ChannelType.SMTP);
            channel["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            channel["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteChannel(channel);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteChannelAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }
        public void TestWriteRuleAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test rule";
            language[new Guid("{305F5FFD-9C46-4BE7-896E-2ACE709E5D7E}")] = "Test policy";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            Guid catalogueGuid = new Guid("{BC626464-1524-407C-8CD4-2B2B9C5BFE87}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);
            XmlStore store = new XmlStore();

            ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{8FC9EB93-C376-4E96-B22E-71FAA848393D}"), new TranslateableLanguageItem("{305F5FFD-9C46-4BE7-896E-2ACE709E5D7E}"), store, policyCatalogue, false);
            P5Policy policy = new P5Policy(policySet, new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), PolicyStatus.Active);
            policy["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            policy["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IPolicyStoreWriter writer = store.Writer;
            writer.WritePolicySet(policySet);
            writer.WritePolicy(policySet, policy);
            writer.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteRuleAttributes.xml", store.StoreXML);
        }
예제 #6
0
 private IPolicySet CreatePolicySet()
 {
     IPolicyStore policyStore = new XmlStore();
     PolicyCatalogue policyCatalogue = new PolicyCatalogue(Guid.NewGuid(), language.Identifier, new TranslateableLanguageItem(""), catalogueStore);
     catalogueStore.AddPolicyCatalogue(policyCatalogue);
     return new PolicySet(Guid.NewGuid(), new TranslateableLanguageItem(""), policyStore, policyCatalogue, false);
 }
예제 #7
0
        public void SetUpTest()
        {

            m_stateMachine = new DynamicMock(typeof(IStateMachine));

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.Reset();
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");
            languageStore.AddLanguage(language);
            PolicyLanguageCache.Instance.ActiveLanguageId = language.Identifier;
            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);
            IPolicyStore policyStore = new XmlStore();
            m_policySet = new PolicySet(Guid.NewGuid(), new TranslateableLanguageItem("TestPolicySet"), policyStore, policyCatalogue, false);
        }
예제 #8
0
        public void TestAddChannel()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);

			IPolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            Assert.AreEqual(1, policyCatalogue.Channels.Count);
        }
예제 #9
0
        public void TestAddConditionGroup()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.ConditionGroups.Count);

            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{B87DF614-2400-4C1F-BEA8-3C2EB3964EAE}"), new TranslateableLanguageItem("Test group"), ConditionLogic.AND, false);
            policySetObserver.AddObject(conditionGroup);

            Assert.AreEqual(1, policyCatalogue.ConditionGroups.Count);
        }
예제 #10
0
        public void TestAddCondition()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);

            ICondition condition = new Condition(new Guid("{98C73BC3-3E20-403C-8023-C91E2818355F}"), "TestClass", new TranslateableLanguageItem("This is a test"), OperatorType.Equals);
            policySetObserver.AddObject(condition);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count);
        }
예제 #11
0
        public IPolicySet ApplyFilter(IPolicySet policySet)
        {
            if (null == policySet)
                return null;

            // Lets create a dummy catalgue store.
            Store.XMLPolicyCatalogueStore catalogueStore = new Store.XMLPolicyCatalogueStore();
            IPolicyCatalogue reducedCatalogue = new PolicyCatalogue(Guid.NewGuid(), policySet.MasterCatalogue.LanguageId, catalogueStore);

            Store.XmlStore store = new Store.XmlStore();

            m_reducedPolicySet = new PolicySet(policySet.Identifier, policySet.Name, store, reducedCatalogue, policySet.ReadOnly);

            Dictionary<string, IPolicyLanguageItem>.Enumerator enumerator = policySet.GetAttributeEnumerator();
            while (enumerator.MoveNext())
            {
                m_reducedPolicySet[enumerator.Current.Key] = enumerator.Current.Value;
            }

            FilterPolicies(policySet);
            return m_reducedPolicySet;
        }
예제 #12
0
        public void TestAddRoutingPostAddToChannel()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);
            Assert.AreEqual(0, policyCatalogue.RoutingTables.Count);
            Assert.AreEqual(0, policyCatalogue.LocationsCollection.Count);
            Assert.AreEqual(0, policyCatalogue.Locations.Count);

            PolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "Test sources");
            senders.Add(new RoutingItem(new Guid("{D41A47E2-CC13-46FF-BE83-829625792576}"), "James Brown", "*****@*****.**"));
            senders.Add(new RoutingItem(new Guid("{B031DFE9-54E7-482B-8955-18CFB8F06A40}"), "Nat King Cole", "*****@*****.**"));
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "Test destinations");
            recipients.Add(new RoutingItem(new Guid("{9E26C6A2-ABE2-427D-9D78-5B8547ADA8D2}"), "Jet Li", "*****@*****.**"));

            RoutingTable routingTable = new RoutingTable(new Guid("{CDF0252C-3D5D-4AFB-98C2-89CF00FE2175}"), new TranslateableLanguageItem("Test routing table"), ChannelType.SMTP);

            routingTable.Sources.Add(senders);
            routingTable.Destinations.Add(recipients);

            channel.Routing = routingTable;

            IRoutingItemCollection recipients2 = new RoutingItemCollection(new Guid("{4E17A792-0CBC-4362-8A82-A1A7FF3C71B0}"), "More test destinations");
            recipients2.Add(new RoutingItem(new Guid("{98CE8CF9-6CF1-4F32-BE4F-C2D381E6C972}"), "why you", "*****@*****.**"));

            routingTable.Destinations.Add(recipients2);

            Assert.AreEqual(1, policyCatalogue.Channels.Count, "Expected one channel");
            Assert.AreEqual(1, policyCatalogue.RoutingTables.Count, "Expected one routing table");
            Assert.AreEqual(3, policyCatalogue.LocationsCollection.Count, "Expected two location groups");
            Assert.AreEqual(4, policyCatalogue.Locations.Count, "Expected three locations");
        }
예제 #13
0
        private void AddActionPostAddToChannel(out PolicyChannel channel, out PolicyCatalogue policyCatalogue)
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);
            Assert.AreEqual(0, policyCatalogue.ActionGroups.Count);
            Assert.AreEqual(0, policyCatalogue.Actions.Count);
            Assert.AreEqual(0, policyCatalogue.LocationsCollection.Count);
            Assert.AreEqual(0, policyCatalogue.Locations.Count);

            channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "Test sources");
            senders.Add(new RoutingItem(new Guid("{D41A47E2-CC13-46FF-BE83-829625792576}"), "James Brown", "*****@*****.**"));
            senders.Add(new RoutingItem(new Guid("{B031DFE9-54E7-482B-8955-18CFB8F06A40}"), "Nat King Cole", "*****@*****.**"));
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "Test destinations");
            recipients.Add(new RoutingItem(new Guid("{9E26C6A2-ABE2-427D-9D78-5B8547ADA8D2}"), "Jet Li", "*****@*****.**"));
            ActionMatrix actionMatrix = new ActionMatrix();
            ActionMatrixCell actionMatrixCell = new ActionMatrixCell(senders, recipients);

            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{9D065722-1106-4FC1-8D48-58733661B929}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false);
            ActionGroup actionGroup = new ActionGroup(new Guid("{E2A16C4D-E112-4249-92B9-612732117809}"), new TranslateableLanguageItem("Test action group"), 1);
            Action action = new Action(new Guid("{A5FAA63E-4F25-456F-92F9-9BB465C18F1F}"), "Test.dll", "Do.It", RunAt.Client, false, 1); //TODO JE
            ActionConditionGroup actionConditionGroup = new ActionConditionGroup(conditionGroup, actionGroup, false);

            actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup);
            actionGroup.Actions.Add(action);

            actionMatrix[senders, recipients] = actionMatrixCell;

            channel.Actions = actionMatrix;
        }
예제 #14
0
        public void TestAddActionPreAddToChannel()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);
            Assert.AreEqual(0, policyCatalogue.ActionGroups.Count);
            Assert.AreEqual(0, policyCatalogue.Actions.Count);
            Assert.AreEqual(0, policyCatalogue.LocationsCollection.Count);
            Assert.AreEqual(0, policyCatalogue.Locations.Count);

            PolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "Test sources");
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "Test destinations");
            ActionMatrix actionMatrix = new ActionMatrix();
            channel.Actions = actionMatrix;

            ActionMatrixCell actionMatrixCell = new ActionMatrixCell(senders, recipients);
            actionMatrix[senders, recipients] = actionMatrixCell;          

            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{9D065722-1106-4FC1-8D48-58733661B929}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false);
            ActionGroup actionGroup = new ActionGroup(new Guid("{E2A16C4D-E112-4249-92B9-612732117809}"), new TranslateableLanguageItem("Test action group"), 1);
            Action action = new Action(new Guid("{A5FAA63E-4F25-456F-92F9-9BB465C18F1F}"), "Test.dll", "Do.It", RunAt.Client, false, 1); //TODO JE
            ActionConditionGroup actionConditionGroup = new ActionConditionGroup(conditionGroup, actionGroup, false);
            
            actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup);
            actionGroup.Actions.Add(action);

            Assert.AreEqual(1, policyCatalogue.Channels.Count, "Expected one channel");
            Assert.AreEqual(1, policyCatalogue.ActionGroups.Count, "Expected one action group");
            Assert.AreEqual(1, policyCatalogue.Actions.Count, "Expected one action");
            Assert.AreEqual(2, policyCatalogue.LocationsCollection.Count, "Expected two location groups");
            Assert.AreEqual(0, policyCatalogue.Locations.Count, "Expected no locations");
        }
예제 #15
0
        public void TestAddDataElementPreAddToCondition()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);
            Assert.AreEqual(0, policyCatalogue.DataElements.Count);

            DataElement dataElementLeft = new DataElement(new Guid("{AC48B709-8DED-467D-8778-BB0A1520FDDC}"), new TranslateableLanguageItem("Data left test"), new TranslateableLanguageItem("This is the data to the left"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("Test"), DataType.String, "This is some data"));
            DataElement dataElementRight = new DataElement(new Guid("{697DAD36-021C-451A-A67C-08D892CFC23A}"), new TranslateableLanguageItem("Data right test"), new TranslateableLanguageItem("This is the data to the right"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("Test"), DataType.String, "This is some data"));
            Condition condition = new Condition(new Guid("{79F9C52C-8F04-473B-8487-8CB241DBED31}"), "Myclass", new TranslateableLanguageItem("Test condition"), OperatorType.Equals);
            condition.DataLeft = dataElementLeft;
            condition.DataRight = dataElementRight;

            policySetObserver.AddObject(condition);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count, "Expected one condition");
            Assert.AreEqual(2, policyCatalogue.DataElements.Count, "Expected two data elements");
        }
        public void TestWriteActionMatrixAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test condition";
            language[new Guid("{5570ABC5-188E-4893-92E4-6930802F9C05}")] = "Test policy";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;

            Guid catalogueGuid = new Guid("{751AEC6C-C164-4E6A-8581-A9ECCED87013}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            IDataItem dataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item"), DataType.Long, 10);
            ObjectModel.IAction action = new ObjectModel.Action(new Guid("{26BCFA7E-3605-4EE7-ACC6-0AFB4D5EBB71}"), "CustomAction.dll", "Test.Clean", RunAt.Client, false, 1); //TODO JE
            action.DataElements.Add(new DataElement(new Guid("{EB56B397-954D-45C2-ADBA-263372A8B59F}"), new TranslateableLanguageItem("Test data item stored in data element"), new NonTranslateableLanguageItem(""), DataType.Long, dataItem));

            ActionGroup actionGroup = new ObjectModel.ActionGroup(new Guid("{987B7C8B-5ADD-4696-8456-DDE11D95CE0B}"), new TranslateableLanguageItem("Test action group"), 1);
            actionGroup.Actions.Add(action);

            ActionMatrix actionMatrix = new ObjectModel.ActionMatrix();

            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("Profanity"), ConditionLogic.OR, false);
            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{79C512E8-3912-4709-B7D7-E91EFA3BD9FD}"), "Test sources");
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{FDC166E4-EBE5-4285-8F09-6A145D88C707}"), "Test destinations");

            ActionMatrixCell actionMatrixCell = new ObjectModel.ActionMatrixCell(senders, recipients);
            actionMatrixCell.AddActionCondition(conditionGroup, actionGroup, false);
            actionMatrix["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{D23F36C4-953F-4ED9-B1EB-8921BD50562B}"] = actionMatrixCell;
            actionMatrix["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            actionMatrix["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IPolicyObjectCollection<IActionMatrix> actions = new PolicyObjectCollection<IActionMatrix>();
            actions.Add(actionMatrix);

            PolicyChannel channel = new PolicyChannel(new Guid("{390F589A-24B0-4DF0-B750-D47EDD1FF0BE}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            channel.Actions = actionMatrix;

            IPolicyObjectCollection<IPolicyObject> channels = new PolicyObjectCollection<IPolicyObject>();
            channels.Add(channel);

            XmlStore store = new XmlStore();

            ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{8FC9EB93-C376-4E96-B22E-71FAA848393D}"), new TranslateableLanguageItem("{5570ABC5-188E-4893-92E4-6930802F9C05}"), store, policyCatalogue, false);
            P5Policy policy = new P5Policy(store, policySet, new Guid("{C0F6D4BB-CBF1-41FC-8A28-616D6FC1DC73}"), new TranslateableLanguageItem("Test policy"), PolicyStatus.Active);
            IPolicyStoreWriter writer = store.Writer;
            writer.WritePolicySet(policySet);
            writer.WritePolicy(policySet, policy);
            writer.WriteConditionGroup(policySet, policy, conditionGroup);
            writer.WriteChildCollection(policySet, policy, policy.Name.Value, channels);
            writer.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteActionMatrixAttributes.xml", store.StoreXML);
        }
        public void TestWriteActionAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test condition";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";
            language[new Guid("{6B37988A-2D68-4249-BB26-CBDE39091E7A}")] = "This is test action";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();

            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            ObjectModel.Action action = new ObjectModel.Action(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), new TranslateableLanguageItem("{6B37988A-2D68-4249-BB26-CBDE39091E7A}"), "TestMe.dll", "Test.DoNothing", RunAt.Client, false, 1); //TODO JE
            DataElement dataElem = new DataElement(new Guid("{C2342D29-2B5A-490F-9B3F-5834EBA8047B}"), new TranslateableLanguageItem("Jill"), new TranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("whatever"), DataType.String, "nag nag nag"));
            action.DataElements.Add(dataElem);

            action["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            action["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteAction(action);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteActionAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }
        public void TestWritePolicies()
        {
            Guid languageGuid = new Guid("{054846D4-6540-4C78-BA7D-141C91EE6A4C}");
            IPolicyLanguage language = new PolicyLanguage(languageGuid, "en");
            language[new Guid("{84DCA455-723A-4F30-8B5A-26A20E0CBE45}")] = "Test policy";
            language[new Guid("{31060488-7C3C-41BF-BD08-188796288AE0}")] = "Test rule";
            language[new Guid("{6AD791C1-5403-488F-8AD9-D6CEAE79DC3E}")] = "Test rule 2";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            XmlStore store = new XmlStore();

            Guid catalogueId = new Guid("{B496E117-29DA-4770-87E9-62573B28BB4F}");
            IPolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueId, language.Identifier, catalogueStore);
            XmlPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(catalogueId, languageGuid) as XmlPolicyCatalogueWriter;
            Assert.IsNotNull(catalogueWriter, "Expected a valid [IPolicyStoreWriter] writer");

            catalogueWriter.WriteName("{D0FE23B8-B8A0-4DD6-A0F1-A7836DC0417E}");

            ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{0A62F323-CB79-47ED-A83D-67A9B2E032D7}"), new TranslateableLanguageItem("{84DCA455-723A-4F30-8B5A-26A20E0CBE45}"), store, policyCatalogue, false);
            string ruleGuid = "{8E915159-5F01-41B3-9FFF-20731544ADFA}";
            P5Policy policy = new P5Policy(store, policySet, new Guid(ruleGuid), new TranslateableLanguageItem("{31060488-7C3C-41BF-BD08-188796288AE0}"), PolicyStatus.Active);

            catalogueWriter.WriteCataloguePolicy(policy);

            ruleGuid = "{33AF2331-C69D-44EE-85F7-56188938BD9B}";
            policy = new P5Policy(store, policySet, new Guid(ruleGuid), new TranslateableLanguageItem("{6AD791C1-5403-488F-8AD9-D6CEAE79DC3E}"), PolicyStatus.Active);
            catalogueWriter.WriteCataloguePolicy(policy);

            catalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteRules.xml", catalogueStore.GetStoreXML(catalogueId));
        }
예제 #19
0
        public void TestAddDataElement()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.DataElements.Count);

            // Create data elements
            DataMethod dataMethod = new DataMethod("ThisIsATest");
            DataItem parameterDataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item to the left"), DataType.String, "Lets go dynamo");

            DataElement parameterDataElement = new DataElement(new Guid("{015035B7-1793-464D-AF69-030E9DC7151E}"), new TranslateableLanguageItem("Test parameter data element"), new TranslateableLanguageItem(""), DataType.String, parameterDataItem);
            dataMethod.Parameters.Add(new Parameter("somethingTerrible", parameterDataElement));
            IDataSource dataSource = new DataSource("ThisIsADodgyAssembly.dll", "ItWantsToTakeOverYourComputer", dataMethod);

            DataElement leftDataElement = new DataElement(new Guid("{454672AC-BCED-4DAB-813F-6CF14E6289C5}"), new TranslateableLanguageItem("Test data left"), new TranslateableLanguageItem(""), DataType.Object, dataSource);
            policySetObserver.AddObject(leftDataElement);

            IDataItem dataRightDataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item to the right"), DataType.String, "This is a test");
            DataElement rightDataElement = new DataElement(new Guid("{4E2F50C5-D310-47A1-AE3A-621F5C77FA68}"), new TranslateableLanguageItem("Test data right"), new TranslateableLanguageItem(""), DataType.String, dataRightDataItem);

            policySetObserver.AddObject(rightDataElement);

            Assert.AreEqual(2, policyCatalogue.DataElements.Count);
        }
        public void TestWriteConditionAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test condition";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";
            language[new Guid("{6B37988A-2D68-4249-BB26-CBDE39091E7A}")] = "This is test condition";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            Condition condition = new Condition(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), "{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}", new TranslateableLanguageItem("{6B37988A-2D68-4249-BB26-CBDE39091E7A}"), OperatorType.Equals);
            condition.DataLeft = new DataElement(new Guid("{A4BCB713-B1E8-42BA-8B70-3C8814D03D0C}"), new TranslateableLanguageItem("DataLeft"), new TranslateableLanguageItem("DataLeft"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("StringItem"), DataType.String, "StringData"));
            condition.DataRight = new DataElement(new Guid("{FCF77B46-B6C9-4E5C-BA15-4B5AE31FF4E7}"), new TranslateableLanguageItem("DataRight"), new TranslateableLanguageItem("DataRight"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("StringItem"), DataType.String, "StringData"));

            condition["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            condition["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteCondition(condition);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteConditionAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }
        public void TestWriteRoutingMatrixCellAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Custom routing";
            language[new Guid("{8809EBFF-D902-4C91-BE56-1ABD13C054A1}")] = "Test policy";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;

            Guid catalogueGuid = new Guid("{751AEC6C-C164-4E6A-8581-A9ECCED87013}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            IRoutingItemCollection senders1 = new RoutingItemCollection(new Guid("{79C512E8-3912-4709-B7D7-E91EFA3BD9FD}"), "Test sources");
            IRoutingItemCollection recipients1 = new RoutingItemCollection(new Guid("{FDC166E4-EBE5-4285-8F09-6A145D88C707}"), "Test destinations");
            
            IRoutingMatrixCell cell1 = new RoutingMatrixCell(new TranslateableLanguageItem("C1"), new TranslateableLanguageItem("Description of the blue cell"), new TranslateableLanguageItem("blue"), 1, senders1, recipients1);
            cell1["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            cell1["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IRoutingMatrixCell cell2 = new RoutingMatrixCell(new TranslateableLanguageItem("C2"), new TranslateableLanguageItem("Description of the red cell"), new TranslateableLanguageItem("red"), 2, senders1, recipients1);
            IRoutingMatrixCell cell3 = new RoutingMatrixCell(new TranslateableLanguageItem("C3"), new TranslateableLanguageItem("Description of the green cell"), new TranslateableLanguageItem("green"), 3, senders1, recipients1);

            RoutingTable routingTable = new RoutingTable(new Guid("{AF6E5D89-0C6F-4B10-9A6C-658D13CD3EA8}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), ChannelType.SMTP);

            routingTable["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{D23F36C4-953F-4ED9-B1EB-8921BD50562B}"] = cell1;
            routingTable["{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}", "{4E1B9EAB-E892-4E47-BBE6-9D70B2438333}"] = cell2;
            routingTable["{3AD507B6-5E1E-44BB-9ABF-C27A31603C1B}", "{D23F36C4-953F-4ED9-B1EB-8921BD50562B}"] = cell3;

            XmlStore store = new XmlStore();

            ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{8FC9EB93-C376-4E96-B22E-71FAA848393D}"), new TranslateableLanguageItem("{8809EBFF-D902-4C91-BE56-1ABD13C054A1}"), store, policyCatalogue, false);
            P5Policy policy = new P5Policy(store, policySet, new Guid("{C0F6D4BB-CBF1-41FC-8A28-616D6FC1DC73}"), new TranslateableLanguageItem("Test rule"), PolicyStatus.Active);

            IPolicyObjectCollection<IPolicyObject> channels = new PolicyObjectCollection<IPolicyObject>();
            PolicyChannel channel = new PolicyChannel(new Guid("{390F589A-24B0-4DF0-B750-D47EDD1FF0BE}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            channel.Routing = routingTable;
            channels.Add(channel);

            Store.IPolicyStoreWriter writer = store.Writer;
            Assert.IsNotNull(writer, "Expected a valid [IPolicyStoreWriter] writer");
            writer.WritePolicySet(policySet);
            writer.WritePolicy(policySet, policy);
            writer.WriteChildCollection(policySet, policy, policy.Name.Value, channels);
            writer.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteRoutingMatrixCellAttributes.xml", store.StoreXML);
        }
        public void TestWriteActionGroupAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test action group";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();

            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            ActionGroup actionGroup = new ObjectModel.ActionGroup(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), 1);
            actionGroup["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            actionGroup["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteActionGroup(actionGroup);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteActionGroupAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }
        public void TestWriteAddressAttributes()
        {
            Guid languageId = new Guid("{A2F11E75-7E10-4668-9FB5-FCB8E3841C8F}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{A2A6EA49-8CB2-4578-8BD5-EBCD57A1B424}")] = "Test sources";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            RoutingItemCollection addressCollection = new RoutingItemCollection(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), "{A2A6EA49-8CB2-4578-8BD5-EBCD57A1B424}");
            RoutingItem address = new RoutingItem(new Guid("{625C4BDE-907F-4751-BDA1-0E59EDBBCE5C}"), "James", "[email protected]");
            address["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            address["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");
            addressCollection.Add(address);

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteLocation(address);
            policyCatalogueWriter.WriteLocationCollection(addressCollection);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteAddressAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }
예제 #24
0
        public void TestWriteRuleHttpRouting()
        {
            string testLanguage = m_testPath + "TestHttpRoutingLanguage.xml";

            Guid languageId = XmlPolicyLanguageStore.Instance.AddLanguage(System.IO.File.ReadAllText(testLanguage));

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{E4C8224A-4CBC-4BFF-B50E-A7E60AAABCFD}"), languageId, catalogueStore);
            policyCatalogue.Name = new TranslateableLanguageItem("{3DDE25D7-E892-430D-A85C-075EBA5535AC}");
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            XmlStore store = new XmlStore();

            ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{8FC9EB93-C376-4E96-B22E-71FAA848393D}"), new TranslateableLanguageItem("{D803727B-5C81-44CC-8BFC-9B68797AC6EB}"), store, policyCatalogue, false);
            P5Policy policy = new P5Policy(store, policySet, new Guid("{C0F6D4BB-CBF1-41FC-8A28-616D6FC1DC73}"), new TranslateableLanguageItem("{F0DD86A0-5D21-4784-88AF-C5321B5998F6}"), PolicyStatus.Active);

            IPolicyObjectCollection<IPolicyChannel> channels = new PolicyObjectCollection<IPolicyChannel>();
            PolicyChannel channel = new PolicyChannel(new Guid("{390F589A-24B0-4DF0-B750-D47EDD1FF0BE}"), new TranslateableLanguageItem("{463A0FAF-CE8C-470E-8077-A093B9350719}"), ChannelType.HTTP);

            RoutingTable routing = RoutingTableFactory.Instance.Create(ChannelType.HTTP, new Guid("{8B097CCF-02C8-40C4-9866-AD6EC09C5AB2}"), new NonTranslateableLanguageItem("Test active content routing"), false) as RoutingTable;
            Assert.IsNotNull(routing);
            IRoutingItemCollection defaultRecipient = routing.DefaultDestination;
            Assert.IsNotNull(defaultRecipient);
            IRoutingItemCollection defaultSender = routing.DefaultSource;
            Assert.IsNotNull(defaultSender);
            IRoutingMatrixCell routingCell = routing[defaultSender, defaultRecipient];
            Assert.IsNotNull(routingCell);

            channel.Routing = routing;
            channels.Add(channel);

            policy.Channels = channels;

            Store.IPolicyStoreWriter writer = store.Writer;
            Assert.IsNotNull(writer, "Expected a valid [IPolicyStoreWriter] writer");
            writer.WritePolicySet(policySet);
            writer.WritePolicy(policySet, policy);
            writer.WriteChildCollection(policySet, policy, policy.Name.Value, CollectionConverter.Convert<IPolicyChannel, IPolicyObject>(channels));
            writer.Close();

            TestHelpers.CompareXml(m_testPath + "TestHttpRoutingPolicySet.xml", store.StoreXML);

            string expectedCatalogue = System.IO.File.ReadAllText(m_testPath + "TestHttpRoutingCatalogue.xml");
            expectedCatalogue = expectedCatalogue.Replace("{A176A59A-8AFB-4820-B7D4-4074B64C9F14}", defaultSender.Identifier.ToString("B").ToUpper());
            expectedCatalogue = expectedCatalogue.Replace("{14C8BE82-D52D-4CE3-9131-FBEA60C88731}", defaultRecipient.Identifier.ToString("B").ToUpper());
            expectedCatalogue = expectedCatalogue.Replace("{6ACC2C34-071A-445E-88A2-4C5B94452E5B}", routingCell.Name.Identifier.ToString("B").ToUpper());
            expectedCatalogue = expectedCatalogue.Replace("{ABBFAC23-846B-42D8-BA14-84CB9E5A095A}", routingCell.Description.Identifier.ToString("B").ToUpper());
            expectedCatalogue = expectedCatalogue.Replace("{6D82D228-A194-4F00-BEE1-DF01368E572F}", defaultSender.Name.Identifier.ToString("B").ToUpper());
            expectedCatalogue = expectedCatalogue.Replace("{7EC9EBD4-67B3-42C3-A750-12CFC9B4DFD0}", defaultRecipient.Name.Identifier.ToString("B").ToUpper());

            string catalogueFile = m_testPath + "TestHttpRoutingCatalogue.xml.tmp";
            System.IO.File.WriteAllText(catalogueFile, expectedCatalogue);

            // Persist the changes to the catalogue.
            IPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(policyCatalogue.Identifier, languageId);
            catalogueWriter.WriteName(policyCatalogue.Name.Identifier.ToString("B").ToUpper());
            catalogueWriter.WriteCatalogue(policyCatalogue);
            catalogueWriter.Close();

            TestHelpers.CompareXml(catalogueFile, catalogueStore.GetStoreXML(policyCatalogue.Identifier));
        }
예제 #25
0
        public void TestCreatePolicySetConditionsMasterCatalogue()
        {
            string testCatalogue = m_testPath + "TestCreatePolicySetConditionsMasterCatalogue.xml";
            string languageFilename = m_testPath + "TestCreatePolicySetConditionsMasterCatalogueLanguage.xml";
            string policySetFilename = m_testPath + "TestCreatePolicySetConditionsMasterCataloguePolicySet.xml";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.Reset();

            Guid languageId = new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}");
            IPolicyLanguage language = new PolicyLanguage(languageId, "en");
            language.DefaultLanguage = true;
            languageStore.AddLanguage(language);

            PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance;
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), "New catalogue");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), "New policy set");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), "New policy");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            IPolicyStore policyStore = new XmlStore();
            IPolicySet policySet = new PolicySet(new Guid("{29EC30A5-1271-4306-89C8-5811172D901A}"), new TranslateableLanguageItem("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), policyStore, policyCatalogue, false);
            IPolicy newPolicy = new P5Policy(policySet, new Guid("{D257D4DC-4A12-438F-A32A-CF1CE4474441}"), new TranslateableLanguageItem("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), PolicyStatus.Active);
            policySet.Policies.Add(newPolicy);

            // Create a condition group for the policy.
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{8EB7FF08-1DC8-4F11-9D55-AF47F83F843A}"), "Test condition group");
            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{B87DF614-2400-4C1F-BEA8-3C2EB3964EAE}"), new TranslateableLanguageItem("{8EB7FF08-1DC8-4F11-9D55-AF47F83F843A}"), ConditionLogic.AND, false);
            newPolicy.Conditions.Add(conditionGroup);

            // Create a condition for the condition group.
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{EC8E1E63-7097-4330-8130-5776D4FDF1ED}"), "Test condition");
            ICondition condition = new Condition(new Guid("{98C73BC3-3E20-403C-8023-C91E2818355F}"), "TestClass", new TranslateableLanguageItem("{EC8E1E63-7097-4330-8130-5776D4FDF1ED}"), OperatorType.Equals);
            conditionGroup.Conditions.Add(condition);

            // Create the data left for the condition data.
            DataMethod dataMethod = new DataMethod("ThisIsATest");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{BA56AB4C-43D0-465A-BE67-D8A569A1894C}"), "Test data item to the left");

            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{AB454A4B-1A0F-4864-9F46-3AAC8A34ACA5}"), "Test parameter data element");
            DataElement parameterDataElement = new DataElement(new Guid("{015035B7-1793-464D-AF69-030E9DC7151E}"), new TranslateableLanguageItem("{AB454A4B-1A0F-4864-9F46-3AAC8A34ACA5}"), new NonTranslateableLanguageItem(""), DataType.String, "Lets go dynamo");
            dataMethod.Parameters.Add(new Parameter("somethingTerrible", parameterDataElement));
            IDataSource dataSource = new DataSource("ThisIsADodgyAssembly.dll", "ItWantsToTakeOverYourComputer", dataMethod);

            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{79784B11-5FCC-47A8-A35E-C8399BE71C05}"), "Test data left");
            condition.DataLeft = new DataElement(new Guid("{454672AC-BCED-4DAB-813F-6CF14E6289C5}"), new TranslateableLanguageItem("{79784B11-5FCC-47A8-A35E-C8399BE71C05}"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);

            // Create the data right for the condition data.
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{BD40DDEE-B045-4D3B-8092-D596329230FE}"), "Test data item to the right");
            IDataItem dataRightDataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("{BD40DDEE-B045-4D3B-8092-D596329230FE}"), DataType.String, "This is a test");

            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{8549333F-0A4D-4939-8A36-36FB0FF1C89A}"), "Test data right");
            condition.DataRight = new DataElement(new Guid("{4E2F50C5-D310-47A1-AE3A-621F5C77FA68}"), new TranslateableLanguageItem("{8549333F-0A4D-4939-8A36-36FB0FF1C89A}"), new NonTranslateableLanguageItem(""), DataType.String, dataRightDataItem);

            // Save everything
            IPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(policyCatalogue.Identifier, language.Identifier);
            catalogueWriter.WriteCatalogue(policyCatalogue);
            catalogueWriter.Close();

            policySet.Save();

            TestHelpers.CompareXml(policySetFilename, policyStore.XMLRepresentation);
            TestHelpers.CompareXml(testCatalogue, catalogueStore.GetStoreXML(policySet.MasterCatalogue.Identifier));
            TestHelpers.CompareXml(languageFilename, languageStore.GetXMLRepresentation(language.Identifier, language.Name.Value));
        }
        public void TestWriteDataItemAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test data element";
            language[new Guid("{559C2D0E-B26C-4B8A-BE9E-820358F1D5C7}")] = "Test data item";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();

            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            DataItem dataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("{559C2D0E-B26C-4B8A-BE9E-820358F1D5C7}"), DataType.String, "10");
            dataItem["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            dataItem["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");
            DataElement dataElement = new DataElement(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), new NonTranslateableLanguageItem(""), DataType.String, dataItem);

            XmlStore store = new XmlStore();

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteDataElement(dataElement);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteDataItemAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }
예제 #27
0
        public void TestCreateNewPolicySet()
        {
            string testCatalogue = m_testPath + "TestCreateNewPolicyCatalogue.xml";
            string languageFilename = m_testPath + "TestCreateNewPolicySetLanguage.xml";
            string policySetFilename = m_testPath + "TestCreateNewPolicySet.xml";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.Reset();

            Guid languageId = new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}");
            IPolicyLanguage language = new PolicyLanguage(languageId, "en");
            language.DefaultLanguage = true;
            languageStore.AddLanguage(language);

            PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance;
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), "New catalogue");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), "New policy set");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), "New policy");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            IPolicyStore policyStore = new XmlStore();
            IPolicySet policySet = new PolicySet(new Guid("{29EC30A5-1271-4306-89C8-5811172D901A}"), new TranslateableLanguageItem("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), policyStore, policyCatalogue, false);
            IPolicy newPolicy = new P5Policy(policySet, new Guid("{D257D4DC-4A12-438F-A32A-CF1CE4474441}"), new TranslateableLanguageItem("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), PolicyStatus.Active);
            policySet.Policies.Add(newPolicy);

            // Save everything
            IPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(policyCatalogue.Identifier, language.Identifier);
            catalogueWriter.WriteCatalogue(policyCatalogue);
            catalogueWriter.Close();

            policySet.Save();

            TestHelpers.CompareXml(testCatalogue, catalogueStore.GetStoreXML(policyCatalogue.Identifier));
            TestHelpers.CompareXml(policySetFilename, policyStore.XMLRepresentation);
            TestHelpers.CompareXml(languageFilename, languageStore.GetXMLRepresentation(language.Identifier, language.Name.Value));

            policySet.Save();

            TestHelpers.CompareXml(testCatalogue, catalogueStore.GetStoreXML(policyCatalogue.Identifier));
            TestHelpers.CompareXml(policySetFilename, policyStore.XMLRepresentation);
            TestHelpers.CompareXml(languageFilename, languageStore.GetXMLRepresentation(language.Identifier, language.Name.Value));
        }
        public void TestWriteCatalogueTwice()
        {
            Guid languageId = new Guid("{054846D4-6540-4C78-BA7D-141C91EE6A4C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{D0FE23B8-B8A0-4DD6-A0F1-A7836DC0417E}")] = "Test catalogue";
            language[new Guid("{A77E610D-9E96-47EE-ADB5-8ECF609BE16D}")] = "Test action";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();

            Guid catalogueId = new Guid("{B496E117-29DA-4770-87E9-62573B28BB4F}");
            IPolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueId, languageId, new TranslateableLanguageItem("{D0FE23B8-B8A0-4DD6-A0F1-A7836DC0417E}"), catalogueStore);

            Guid actionId = new Guid("{26BCFA7E-3605-4EE7-ACC6-0AFB4D5EBB71}");
            ObjectModel.Action action = new ObjectModel.Action(actionId, new TranslateableLanguageItem("{A77E610D-9E96-47EE-ADB5-8ECF609BE16D}"), "CustomAction.dll", "Workshare.Clean", RunAt.Client, false, 1); //TODO JE
            DataElement dataElem = new DataElement(new Guid("{C2342D29-2B5A-490F-9B3F-5834EBA8047B}"), new TranslateableLanguageItem("Jill"), new NonTranslateableLanguageItem(""), DataType.String, "nag nag nag");
            action.DataElements.Add(dataElem);
            policyCatalogue.Actions.Add(action);

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueId, languageId);
            policyCatalogueWriter.WriteName(policyCatalogue.Name.Identifier.ToString("B").ToUpper());
            policyCatalogueWriter.WriteCatalogue(policyCatalogue);
            policyCatalogueWriter.Close();

            policyCatalogueWriter.WriteName(policyCatalogue.Name.Identifier.ToString("B").ToUpper());
            policyCatalogueWriter.WriteCatalogue(policyCatalogue);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteCatalogue.xml", catalogueStore.GetStoreXML(catalogueId));
        }
예제 #29
0
        public void TestCreatePolicySetChannelsMasterCataloguePrepopulateRouting()
        {
            string testCatalogue = m_testPath + "TestCreatePolicySetChannelsMasterCatalogue.xml";
            string languageFilename = m_testPath + "TestCreatePolicySetChannelsMasterCatalogueLanguage.xml";
            string policySetFilename = m_testPath + "TestCreatePolicySetChannelsMasterCataloguePolicySet.xml";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.Reset();

            Guid languageId = new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}");
            PolicyLanguageCache.Instance.ActiveLanguageId = languageId;
            IPolicyLanguage language = new PolicyLanguage(languageId, "en");
            language.DefaultLanguage = true;
            languageStore.AddLanguage(language);

            PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance;
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), "New catalogue");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), "New policy set");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), "New policy");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{39C06E29-074C-46C8-BE3D-F1CD92BB8D66}"), "Test channel");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{03005F4E-04FC-4287-B2A6-25F877D9C31B}"), "Test sources");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{3BF2C1D6-0F40-4A32-A311-6F65A5D271BD}"), "Test destinations");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{A8CEBEDF-92EA-4DCC-8053-08E5245ED84D}"), "Test routing table");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{86D8056D-BA38-44FA-B9BD-100CFB7113F8}"), "Test condition group");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{040C4E16-EE88-4B91-833F-8F30A536DAC6}"), "Test action group");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{F03E6CD1-98C0-4590-B789-907ECF90BEBF}"), "Test data element");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{6197CDBE-9F42-4A61-9369-238355BAB404}"), "Test data element display");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{E5C29C65-9600-42D9-8CD6-6638F40F9341}"), "Test data item");
            policyLanguageCache.SetLanguageItemText(languageId, new Guid("{463295F1-A5A2-4BB1-B029-7917AC75E9E6}"), "Test action");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            IPolicyStore policyStore = new XmlStore();
            IPolicySet policySet = new PolicySet(new Guid("{29EC30A5-1271-4306-89C8-5811172D901A}"), new TranslateableLanguageItem("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), policyStore, policyCatalogue, false);
            IPolicy newPolicy = new P5Policy(policySet, new Guid("{D257D4DC-4A12-438F-A32A-CF1CE4474441}"), new TranslateableLanguageItem("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), PolicyStatus.Active);
            policySet.Policies.Add(newPolicy);

            // Create policy set channel
            PolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("{39C06E29-074C-46C8-BE3D-F1CD92BB8D66}"), ChannelType.SMTP);           

            // Create routing table
            RoutingTable routingTable = new RoutingTable(new Guid("{CDF0252C-3D5D-4AFB-98C2-89CF00FE2175}"), new TranslateableLanguageItem("{A8CEBEDF-92EA-4DCC-8053-08E5245ED84D}"), ChannelType.SMTP);
            
            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "{03005F4E-04FC-4287-B2A6-25F877D9C31B}");
            senders.Add(new RoutingItem(new Guid("{D41A47E2-CC13-46FF-BE83-829625792576}"), "James Brown", "*****@*****.**"));
            senders.Add(new RoutingItem(new Guid("{B031DFE9-54E7-482B-8955-18CFB8F06A40}"), "Nat King Cole", "*****@*****.**"));
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "{3BF2C1D6-0F40-4A32-A311-6F65A5D271BD}");
            recipients.Add(new RoutingItem(new Guid("{9E26C6A2-ABE2-427D-9D78-5B8547ADA8D2}"), "Jet Li", "*****@*****.**"));
            
            routingTable.Sources.Add(senders);
            routingTable.Destinations.Add(recipients);

            // Assign routing table to channel
            channel.Routing = routingTable;

            // Create action matrix
            ActionMatrix actionMatrix = new ObjectModel.ActionMatrix(false);

            // Create an action matrix cell
            ActionMatrixCell actionMatrixCell = new ObjectModel.ActionMatrixCell(senders, recipients);

            // Populate the action matrix cell
            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("{86D8056D-BA38-44FA-B9BD-100CFB7113F8}"), ConditionLogic.AND, false);
            ActionGroup actionGroup = new ObjectModel.ActionGroup(new Guid("{32D97853-2680-4B02-A391-22CAEE87B017}"), new TranslateableLanguageItem("{040C4E16-EE88-4B91-833F-8F30A536DAC6}"), 1);
            IActionConditionGroup actionConditionGroup = new ObjectModel.ActionConditionGroup(conditionGroup, actionGroup, false);

            ObjectModel.Action action = new ObjectModel.Action(new Guid("{5153B00E-7D30-4D37-90F9-75E55AA1B32B}"), new TranslateableLanguageItem("{463295F1-A5A2-4BB1-B029-7917AC75E9E6}"), "TestAction.dll", "Test.Action", RunAt.Client, false, 1); //TODO JE

            DataItem dataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("{E5C29C65-9600-42D9-8CD6-6638F40F9341}"), DataType.String, "Not again, when will it ever end!");
            DataElement dataElement = new DataElement(new Guid("{39500989-0B41-4C4E-85DF-CCB4FBD5BEB8}"), new TranslateableLanguageItem("{F03E6CD1-98C0-4590-B789-907ECF90BEBF}"), new TranslateableLanguageItem("{6197CDBE-9F42-4A61-9369-238355BAB404}"), DataType.String, dataItem);
            action.DataElements.Add(dataElement);
            actionConditionGroup.ActionGroup.Actions.Add(action);

            // Assign the action condition group to the matrix cell
            actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup);

            // Assign the action matrix cell to the action matrix
            actionMatrix[senders, recipients] = actionMatrixCell;

            // Assign action matrix to channel
            channel.Actions = actionMatrix;

            // Assign channel to policy
            newPolicy.Channels.Add(channel);

            // Save everything
            IPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(policyCatalogue.Identifier, language.Identifier);
            catalogueWriter.WriteCatalogue(policyCatalogue);
            catalogueWriter.Close();

            policySet.Save();

            TestHelpers.CompareXml(policySetFilename, policyStore.XMLRepresentation);

            IRoutingMatrixCell routingMatrixCell = routingTable[senders, recipients];

            string expectedCatalogueXml = System.IO.File.ReadAllText(testCatalogue);
            expectedCatalogueXml = expectedCatalogueXml.Replace("{0}", routingMatrixCell.Name.Identifier.ToString("B").ToUpper());
            expectedCatalogueXml = expectedCatalogueXml.Replace("{1}", routingMatrixCell.Description.Identifier.ToString("B").ToUpper());
            testCatalogue += ".tmp";

            System.IO.File.WriteAllText(testCatalogue, expectedCatalogueXml);

            TestHelpers.CompareXml(testCatalogue, catalogueStore.GetStoreXML(policySet.MasterCatalogue.Identifier));

            string expectedLanguageXml = System.IO.File.ReadAllText(languageFilename);
            expectedLanguageXml = expectedLanguageXml.Replace("{0}", routingMatrixCell.Name.Identifier.ToString("B").ToUpper());
            expectedLanguageXml = expectedLanguageXml.Replace("{1}", routingMatrixCell.Description.Identifier.ToString("B").ToUpper());
            languageFilename += ".tmp";
            System.IO.File.WriteAllText(languageFilename, expectedLanguageXml);

            TestHelpers.CompareXml(languageFilename, languageStore.GetXMLRepresentation(language.Identifier, language.Name.Value));
        }
예제 #30
0
        public void Test08_GetDefaultAddressCollectionName()
        {
            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.Reset();
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");
            languageStore.AddLanguage(language);
            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);
            IPolicyStore policyStore = new XmlStore();
            IPolicySet policySet = new PolicySet(Guid.NewGuid(), new TranslateableLanguageItem("TestPolicySet"), policyStore, policyCatalogue, false);
            IPolicy policy = PolicyFactory.CreatePolicy("TestPolicy", policySet, PolicyStatus.Active, "None");

            IRoutingTable routingTable = policy.Channels[3].Routing;
            Assert.IsNotNull(routingTable, "Expected the routing table type to be SMTP");

            string defaultName = AddressSearchHelper.Instance.GetDefaultAddressCollectionName();
            Assert.AreEqual(Properties.Resources.IDS_DEFAULT_ADDRESSGROUPNAME + Convert.ToString(1), defaultName);

            RoutingItemCollection addressCollection = new RoutingItemCollection(Guid.NewGuid(), defaultName);
            RoutingHelper.AddCollectionToAddressGroup(policy.Channels[3].Routing, routingTable.Destinations, addressCollection);

            defaultName = AddressSearchHelper.Instance.GetDefaultAddressCollectionName();
            Assert.AreEqual(Properties.Resources.IDS_DEFAULT_ADDRESSGROUPNAME + Convert.ToString(2), defaultName);
        }