コード例 #1
0
        public void SetStatusTest1()
        {
            using (ConfigDatabase db = CreateConfigDatabase())
            {
                foreach (string domain in TestDomainNames)
                {
                    string        subject = "CN=" + domain;
                    AnchorManager target  = CreateManager();
                    Anchor[]      actual  = target.Get(subject);
                    Dump(string.Format("SetStatusTest1 Subject[{0}] which has [{1}] related certs.", subject, actual?.Length ?? -1));
                    Assert.NotNull(actual);
                    Assert.Equal(MAXCERTPEROWNER, actual.Length);
                    foreach (Anchor cert in actual)
                    {
                        Assert.Equal(EntityStatus.New, cert.Status);
                    }

                    target.SetStatus(db, subject, EntityStatus.Enabled);
                    db.SubmitChanges();
                    actual = target.Get(subject);
                    Assert.NotNull(actual);
                    Assert.Equal(MAXCERTPEROWNER, actual.Length);
                    foreach (Anchor cert in actual)
                    {
                        Assert.Equal(EntityStatus.Enabled, cert.Status);
                    }
                }
            }
        }
コード例 #2
0
        public void AddTest1()
        {
            //----------------------------------------------------------------------------------------------------
            //---only init the domain records which will force a cleaning of the mx records
            InitDomainRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            //----------------------------------------------------------------------------------------------------
            //---make sure there are no mx records that exist
            Assert.Equal(0, mgr.Count());

            long   domainId  = 1; //--we always have domain id of 1 (unless someone changed testing values in base)
            string SMTPName  = BuildSMTPDomainName(1, 1);
            int    preferece = 1;

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                mgr.Add(db, domainId
                        , SMTPName
                        , preferece);
                db.SubmitChanges();
                Assert.Equal(1, mgr.Count());
            }
            MX mx = mgr.Get(SMTPName);

            Assert.Equal(domainId, mx.DomainID);
            Assert.Equal(SMTPName, mx.SMTPDomainName);
            Assert.Equal(preferece, mx.Preference);
        }
コード例 #3
0
 public void RemoveTest2()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         AnchorManager target = CreateManager();
         Assert.Equal(MAXDOMAINCOUNT * MAXCERTPEROWNER, target.Get(-1, MAXDOMAINCOUNT * MAXCERTPEROWNER + 1).Count());
         string ownerName = string.Format("CN={0}", BuildDomainName(GetRndDomainID()));
         target.Remove(db, ownerName);
         db.SubmitChanges();
         Assert.Equal(MAXDOMAINCOUNT * MAXCERTPEROWNER - MAXCERTPEROWNER, target.Get(-1, MAXDOMAINCOUNT * MAXCERTPEROWNER + 1).Count());
     }
 }
コード例 #4
0
 public void AddTest3()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         DomainManager target = CreateManager();
         target.RemoveAll();
         Assert.Equal(0, target.Count());
         string name = BuildDomainName(GetRndDomainID());
         target.Add(db, name);
         db.SubmitChanges();
         Assert.NotNull(target.Get(name));
     }
 }
コード例 #5
0
        /// <summary>
        /// This method will clean, load and verify MDN records in the DB for testing purposes
        /// </summary>
        /// <param name="mgr">MdnManager instance used for controlling the Mdn records</param>
        /// <param name="db">ConfigDatabase instance used as the target storage mechanism for the records</param>
        protected void InitOldMdnRecords(MdnManager mgr, ConfigDatabase db)
        {
            mgr.RemoveAll();
            mgr.Start(db, TestOldMdns.ToArray());

            //----------------------------------------------------------------------------------------------------
            //---submit changes to db and verify existence of records
            db.SubmitChanges();
            foreach (KeyValuePair <long, KeyValuePair <int, string> > kp in TestAddressNames)
            {
                //Assert.NotNull(mgr.Get(kp.Value.Value));
            }
        }
コード例 #6
0
        public void RemoveTest()
        {
            InitDomainRecords();
            DomainManager target = CreateManager();
            string        name   = BuildDomainName(GetRndDomainID());

            Assert.NotNull(target.Get(name));
            using (ConfigDatabase db = CreateConfigDatabase())
            {
                target.Remove(name);
                db.SubmitChanges();
            }
            Assert.Null(target.Get(name));
        }
コード例 #7
0
 public void AddTest(Certificate cert)
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         CertificateManager target = CreateManager();
         target.RemoveAll();
         target.Add(db, cert);
         db.SubmitChanges();
         Certificate certNew = target.Get(1); //---should always be 1 (table was truncated above);
         Assert.NotNull(cert);
         Assert.Equal(cert.Owner, certNew.Owner);
         Assert.Equal(cert.Thumbprint, certNew.Thumbprint);
     }
 }
コード例 #8
0
        public void AddTest(Anchor anc)
        {
            AnchorManager target = CreateManager();

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                target.RemoveAll();
                target.Add(db, anc);
                db.SubmitChanges();
                Anchor certNew = target.Get(anc.Owner, anc.Thumbprint); //---should always be 1 (table was truncated above);
                Assert.NotNull(anc);
                Assert.Equal(anc.Owner, certNew.Owner);
                Assert.Equal(anc.Thumbprint, certNew.Thumbprint);
            }
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        public void RemoveTest1()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            string name = BuildSMTPDomainName(1, 1);

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX obj = db.MXs.Get(name);
                Assert.NotNull(obj);
                mgr.Remove(db, name);
                db.SubmitChanges();
                obj = db.MXs.Get(name);
                Assert.Null(obj);
            }
        }
コード例 #11
0
        /// <summary>
        /// This method will clean, load and verify Domain records in the DB for testing purposes
        /// </summary>
        /// <param name="mgr">DomainManager instance used for controlling the Domain records</param>
        /// <param name="db">ConfigDatabase instance used as the target storage mechanism for the records</param>
        /// <remarks>
        /// this approach goes out to db each time it is called, however it ensures that clean records
        /// are present for every test that is execute, if it is taking too long, simply cut down on the
        /// number of items using the consts above
        /// </remarks>
        protected void InitDomainRecords(DomainManager mgr
                                         , ConfigDatabase db)
        {
            //----------------------------------------------------------------------------------------------------
            //---clean all existing records
            mgr.RemoveAll();
            foreach (string val in TestDomainNames)
            {
                mgr.Add(db, new Domain(val));
            }

            //----------------------------------------------------------------------------------------------------
            //---submit changes to db and verify existence of records
            db.SubmitChanges();
            foreach (string val in TestDomainNames)
            {
                Assert.NotNull(mgr.Get(val));
            }
        }
コード例 #12
0
        /// <summary>
        /// This method will clean, load and verify address records in the DB for testing purposes
        /// </summary>
        /// <param name="mgr">AddressManager instance used for controlling the Address records</param>
        /// <param name="db">ConfigDatabase instance used as the target storage mechanism for the records</param>
        /// <remarks>
        /// this approach goes out to db each time it is called, however it ensures that clean records
        /// are present for every test that is execute, if it is taking too long, simply cut down on the
        /// number of items using the consts above
        /// </remarks>
        protected void InitAddressRecords(AddressManager mgr
                                          , ConfigDatabase db)
        {
            //----------------------------------------------------------------------------------------------------
            //---init domain records as well we want them fresh too
            InitDomainRecords(new DomainManager(CreateConfigStore()), db);
            foreach (KeyValuePair <long, KeyValuePair <int, string> > kp in TestAddressNames)
            {
                //----------------------------------------------------------------------------------------------------
                //---create new address entry with the domain id (kp.key) and the address
                mgr.Add(db, new Address(kp.Key, kp.Value.Value, BuildEmailAddressDisplayName(kp.Key, kp.Value.Key))
                {
                    Type = "SMTP"
                });
            }

            //----------------------------------------------------------------------------------------------------
            //---submit changes to db and verify existence of records
            db.SubmitChanges();
            foreach (KeyValuePair <long, KeyValuePair <int, string> > kp in TestAddressNames)
            {
                Assert.NotNull(mgr.Get(kp.Value.Value));
            }
        }
コード例 #13
0
ファイル: MXManagerFacts.cs プロジェクト: DM-TOR/nhin-d
        public void AddTest1()
        {

            //----------------------------------------------------------------------------------------------------
            //---only init the domain records which will force a cleaning of the mx records
            InitDomainRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            //----------------------------------------------------------------------------------------------------
            //---make sure there are no mx records that exist
            Assert.Equal(0, mgr.Count());

            long domainId = 1; //--we always have domain id of 1 (unless someone changed testing values in base)
            string SMTPName = BuildSMTPDomainName(1, 1);
            int preferece = 1;
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                mgr.Add(db,domainId
                        , SMTPName
                        , preferece);
                db.SubmitChanges();
                Assert.Equal(1, mgr.Count());
               

            }
            MX mx = mgr.Get(SMTPName);
            Assert.Equal(domainId, mx.DomainID);
            Assert.Equal(SMTPName, mx.SMTPDomainName);
            Assert.Equal(preferece, mx.Preference);
            
        }
コード例 #14
0
ファイル: MXManagerFacts.cs プロジェクト: DM-TOR/nhin-d
        public void RemoveTest1()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            string name = BuildSMTPDomainName(1, 1);

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX obj = db.MXs.Get(name);
                Assert.NotNull(obj);
                mgr.Remove(db, name);
                db.SubmitChanges();
                obj = db.MXs.Get(name);
                Assert.Null(obj);
            }
            
            
        }