示例#1
0
        public void DeletePolicyTest()
        {
            CertPolicyManager mgr    = CreateManager();
            CertPolicy        policy = mgr.Get("Policy2");

            mgr.Remove(policy.ID);

            mgr.Get("Policy2").Should().BeNull();
        }
示例#2
0
        public void GetPolicyByName()
        {
            CertPolicyManager mgr    = CreateManager();
            CertPolicy        policy = mgr.Get("Policy1");

            policy.Name.Should().BeEquivalentTo("Policy1");
        }
示例#3
0
        public void UpdatePolicyDescriptionTest()
        {
            CertPolicyManager mgr = CreateManager();

            CertPolicy newCertPolicy = new CertPolicy("UnitTestPolicy", "UnitTest Policy Description", "1 = 1".ToBytesUtf8());

            mgr.Add(newCertPolicy);
            CertPolicy actualCertPolicy = mgr.Get("UnitTestPolicy");

            actualCertPolicy.Should().NotBeNull();

            actualCertPolicy.Description = "blank";
            mgr.Update(actualCertPolicy);

            CertPolicy updatedCertPolicy = mgr.Get("UnitTestPolicy");

            updatedCertPolicy.Description.ShouldBeEquivalentTo("blank");
        }
示例#4
0
        public void UpdatePolicyDataTest()
        {
            CertPolicyManager mgr = CreateManager();

            CertPolicy newCertPolicy = new CertPolicy("UnitTestPolicy", "UnitTest Policy Description", "1 = 1".ToBytesUtf8());

            mgr.Add(newCertPolicy);
            CertPolicy actualCertPolicy = mgr.Get("UnitTestPolicy");

            actualCertPolicy.Should().NotBeNull();

            actualCertPolicy.Data = "1 != 1".ToBytesUtf8();
            mgr.Update(actualCertPolicy);

            CertPolicy updatedCertPolicy = mgr.Get("UnitTestPolicy");

            updatedCertPolicy.Data.ToUtf8String().ShouldAllBeEquivalentTo("1 != 1");
        }
示例#5
0
        public void DeletePolicyWithAssociations()
        {
            CertPolicyGroupManager groupMgr    = CreatePolicyGroupManager();
            CertPolicyGroup        policyGroup = groupMgr.Get("PolicyGroup1");

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

            CertPolicyManager policyMgr = CreateManager();

            policyMgr.Get("Policy1").Should().NotBeNull();

            groupMgr.AddPolicyUse("Policy1", "PolicyGroup1", CertPolicyUse.PRIVATE_RESOLVER, true, true);

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

            CertPolicyManager mgr    = CreateManager();
            CertPolicy        policy = mgr.Get("Policy1");

            mgr.Remove(policy.ID);
            policyMgr.Get("Policy1").Should().BeNull();
        }
示例#6
0
        public void AddPolicy()
        {
            CertPolicyManager mgr = CreateManager();

            CertPolicy expectedPolicy = new CertPolicy("UnitTestPolicy", "", "1 = 1".ToBytesUtf8());

            mgr.Add(expectedPolicy);

            CertPolicy actualCertPolicy = mgr.Get("UnitTestPolicy");

            expectedPolicy.Name.Should().BeEquivalentTo("UnitTestPolicy");
            expectedPolicy.CreateDate.Should().BeCloseTo(actualCertPolicy.CreateDate);
        }
        public void AssociatePolicyToGroupSessionTest()
        {
            InitCertPolicyRecords();
            InitCertPolicyGroupRecords();

            using (ConfigDatabase db = CreateConfigDatabase(CertPolicyGroupManager.DataLoadOptions))
            {
                CertPolicyGroupManager mgr         = CreateManager();
                CertPolicyGroup        policyGroup = mgr.Get(db, "PolicyGroup1");
                policyGroup.CertPolicies.Count.Should().Be(0);
                CertPolicyManager policyMgr  = CreatePolicyManager();
                CertPolicy        certPolicy = policyMgr.Get("Policy1");

                policyGroup.CertPolicies.Add(certPolicy);
                db.SubmitChanges();
                policyGroup = mgr.Get("PolicyGroup1");
                policyGroup.CertPolicies.Count.Should().Be(1);
            }
        }