public void Disassociate_All_PolicyGroups_ByDomain_Test()
        {
            InitDomainRecords();
            InitCertPolicyRecords();
            InitCertPolicyGroupRecords();

            CertPolicyGroupManager groupMgr    = CreateManager();
            CertPolicyGroup        policyGroup = groupMgr.Get("PolicyGroup1");

            policyGroup.CertPolicies.Count.Should().Be(0);


            groupMgr.AssociateToOwner(policyGroup.Name, "domain1.test.com");
            groupMgr.AssociateToOwner(policyGroup.Name, "domain2.test.com");

            policyGroup = groupMgr.Get("PolicyGroup1");
            policyGroup.CertPolicyGroupDomainMaps.Count.Should().Be(2);

            //group2
            CertPolicyGroup policyGroup2 = groupMgr.Get("PolicyGroup2");

            policyGroup2.CertPolicies.Count.Should().Be(0);
            groupMgr.AssociateToOwner(policyGroup2.Name, "domain1.test.com");
            policyGroup2 = groupMgr.Get("PolicyGroup2");
            policyGroup2.CertPolicyGroupDomainMaps.Count.Should().Be(1);

            groupMgr.DisassociateFromDomain("domain1.test.com");

            policyGroup = groupMgr.Get("PolicyGroup1");
            policyGroup.CertPolicyGroupDomainMaps.Count.Should().Be(1);

            policyGroup = groupMgr.Get("PolicyGroup2");
            policyGroup.CertPolicyGroupDomainMaps.Count.Should().Be(0);
        }
Example #2
0
        public void AssociatePolicyGroupToDomain_Test()
        {
            InitDomainRecords();
            InitCertPolicyRecords();
            InitCertPolicyGroupRecords();

            CertPolicyGroupManager groupMgr    = CreateManager();
            CertPolicyGroup        policyGroup = groupMgr.Get("PolicyGroup1");

            policyGroup.CertPolicies.Count.Should().Be(0);

            groupMgr.AssociateToOwner(policyGroup.Name, "domain1.test.com");
            groupMgr.AssociateToOwner(policyGroup.Name, "domain2.test.com");

            policyGroup = groupMgr.Get("PolicyGroup1");
            policyGroup.CertPolicyGroupDomainMaps.Count.Should().Be(2);
        }
        public void GetPolicyGroupsByDomains()
        {
            InitDomainRecords();
            InitCertPolicyRecords();
            InitCertPolicyGroupRecords();

            CertPolicyGroupManager groupMgr     = CreateManager();
            CertPolicyGroup        policyGroup1 = groupMgr.Get("PolicyGroup1");

            policyGroup1.CertPolicies.Count.Should().Be(0);
            CertPolicyGroup policyGroup2 = groupMgr.Get("PolicyGroup2");

            policyGroup1.CertPolicies.Count.Should().Be(0);
            policyGroup2.CertPolicies.Count.Should().Be(0);

            //
            // Map cert policy group to domains
            //
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain1.test.com");
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain2.test.com");
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain3.test.com");
            groupMgr.AssociateToOwner(policyGroup2.Name, "domain2.test.com");

            CertPolicyGroup[] policyGroups = groupMgr.GetByDomains(new string[] { "domain1.test.com" });
            policyGroups.Length.Should().Be(1);
            policyGroups[0].CertPolicyGroupDomainMaps.Count.Should().Be(1);

            policyGroups = groupMgr.GetByDomains(new string[] { "domain2.test.com" });
            policyGroups.Length.Should().Be(2);
            policyGroups.Where(cpg => cpg.Name == "PolicyGroup1").Select(cpg => cpg.CertPolicyGroupDomainMaps).ToList().Count.Should().Be(1);
            policyGroups.Where(cpg => cpg.Name == "PolicyGroup2").Select(cpg => cpg.CertPolicyGroupDomainMaps).ToList().Count.Should().Be(1);

            policyGroups = groupMgr.GetByDomains(new string[] { "domain1.test.com", "domain2.test.com" });
            policyGroups.Length.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupDomainMaps.Count.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupDomainMaps.Count.Should().Be(1);

            policyGroups = groupMgr.GetByDomains(new string[] { "domain1.test.com", "domain2.test.com", "domain3.test.com" });
            policyGroups.Length.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupDomainMaps.Count.Should().Be(3);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupDomainMaps.Count.Should().Be(1);
        }
Example #4
0
        public void GetIncomingAndOutgoingCertPolicieByOwnerAndUsage_Test()
        {
            CertPolicyGroupManager groupMgr     = CreatePolicyGroupManager();
            CertPolicyGroup        policyGroup1 = groupMgr.Get("PolicyGroup1");

            policyGroup1.CertPolicies.Count.Should().Be(0);
            CertPolicyGroup policyGroup2 = groupMgr.Get("PolicyGroup2");

            policyGroup1.CertPolicies.Count.Should().Be(0);
            policyGroup2.CertPolicies.Count.Should().Be(0);



            //
            // Map cert policy group to domains
            //
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain1.test.com");
            groupMgr.AssociateToOwner(policyGroup2.Name, "domain2.test.com");
            //
            // Map cert policy group to policy
            //
            groupMgr.AddPolicyUse("Policy1", "PolicyGroup1", CertPolicyUse.TRUST, true, true);
            groupMgr.AddPolicyUse("Policy2", "PolicyGroup1", CertPolicyUse.PRIVATE_RESOLVER, true, false);


            CertPolicyManager policyMgr = CreateManager();

            CertPolicy[] policies = policyMgr.GetIncomingByOwner("domain1.test.com", CertPolicyUse.TRUST);
            policies.Length.Should().Be(1);
            policies = policyMgr.GetIncomingByOwner("domain1.test.com", CertPolicyUse.PUBLIC_RESOLVER);
            policies.Length.Should().Be(0);
            policies = policyMgr.GetOutgoingByOwner("domain1.test.com", CertPolicyUse.TRUST);
            policies.Length.Should().Be(1);
            policies = policyMgr.GetOutgoingByOwner("domain1.test.com", CertPolicyUse.PRIVATE_RESOLVER);
            policies.Length.Should().Be(0);

            policies = policyMgr.GetIncomingByOwner("domain2.test.com", CertPolicyUse.PRIVATE_RESOLVER);
            policies.Length.Should().Be(0);

            policies = policyMgr.GetIncomingByOwner("domain3.test.com", CertPolicyUse.PRIVATE_RESOLVER);
            policies.Length.Should().Be(0);
        }
        public void GetPolicyGroupsByDomainsWithPoliciesTest()
        {
            InitDomainRecords();
            InitCertPolicyRecords();
            InitCertPolicyGroupRecords();

            CertPolicyGroupManager groupMgr     = CreateManager();
            CertPolicyGroup        policyGroup1 = groupMgr.Get("PolicyGroup1");

            policyGroup1.CertPolicies.Count.Should().Be(0);
            CertPolicyGroup policyGroup2 = groupMgr.Get("PolicyGroup2");

            policyGroup1.CertPolicies.Count.Should().Be(0);
            policyGroup2.CertPolicies.Count.Should().Be(0);



            //
            // Map cert policy group to domains
            //
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain1.test.com");
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain2.test.com");
            groupMgr.AssociateToOwner(policyGroup1.Name, "domain3.test.com");
            groupMgr.AssociateToOwner(policyGroup2.Name, "domain2.test.com");
            //
            // Map cert policy group to policy
            //
            groupMgr.AddPolicyUse("Policy1", "PolicyGroup1", CertPolicyUse.PUBLIC_RESOLVER, true, true);
            groupMgr.AddPolicyUse("Policy2", "PolicyGroup1", CertPolicyUse.PUBLIC_RESOLVER, true, true);
            groupMgr.AddPolicyUse("Policy2", "PolicyGroup2", CertPolicyUse.PUBLIC_RESOLVER, true, true);

            CertPolicyGroup[] policyGroups = groupMgr.GetByDomains(new string[] { "domain1.test.com" });
            policyGroups.Length.Should().Be(1);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupDomainMaps.Count.Should().Be(1);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupMaps.Count.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicies.Count.Should().Be(2);
            foreach (var policy in policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicies)
            {
                Console.WriteLine(policy.Name);
                Console.WriteLine(policy.Data.ToUtf8String());
            }

            policyGroups = groupMgr.GetByDomains(new string[] { "domain2.test.com" });
            policyGroups.Length.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupDomainMaps.Count.Should().Be(1);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupMaps.Count.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupDomainMaps.Count.Should().Be(1);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupMaps.Count.Should().Be(1);

            policyGroups = groupMgr.GetByDomains(new string[] { "domain1.test.com", "domain2.test.com" });
            policyGroups.Length.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupDomainMaps.Count.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupMaps.Count.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupDomainMaps.Count.Should().Be(1);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupMaps.Count.Should().Be(1);

            policyGroups = groupMgr.GetByDomains(new string[] { "domain1.test.com", "domain2.test.com", "domain3.test.com" });
            policyGroups.Length.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupDomainMaps.Count.Should().Be(3);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup1").CertPolicyGroupMaps.Count.Should().Be(2);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupDomainMaps.Count.Should().Be(1);
            policyGroups.Single(cpg => cpg.Name == "PolicyGroup2").CertPolicyGroupMaps.Count.Should().Be(1);
        }