示例#1
0
        public void SetADDefaults_Works()
        {
            LdapConfig a = new LdapConfig();

            a.SetActiveDirectoryDefaults();

            // Store off some of the values:
            string exGroupFilter = a.GroupFilter;
            string exGroupAttr   = a.GroupAttr;
            string exUserAttr    = a.UserAttr;

            // Validate the AD fields are set.
            Assert.IsNotEmpty(exGroupAttr, "A10:  Expected the GroupAttr property to be set.");
            Assert.IsNotEmpty(exGroupFilter, "A20:  Expected the GroupFilter property to be set.");
            Assert.IsNotEmpty(exUserAttr, "A30:  Expected the UserAttr property to be set.");
        }
示例#2
0
        // Validate we can load the config from a JSON file.
        // Called as part of the Setup Process.
        public void SetLDAPConfig(string backend, LdapConfig config)
        {
            TestContext.WriteLine("LDAP Backend Name = " + backend);


            config.SetActiveDirectoryDefaults();
            //config.UserDN = "oldUserDN";
            //config.GroupDN = "oldgroupDN";



            // Store off some of the values:
            string exGroupFilter = config.GroupFilter;
            string exGroupAttr   = config.GroupAttr;
            string exUserAttr    = config.UserAttr;


            // Validate the AD fields are set.
            Assert.IsNotEmpty(exGroupAttr, "A10:  Expected the GroupAttr property to be set.");
            Assert.IsNotEmpty(exGroupAttr, "A20:  Expected the GroupFilter property to be set.");
            Assert.IsNotEmpty(exGroupAttr, "A30:  Expected the UserAttr property to be set.");

            // TODO Delete or uncomment

            // Read a JSON Config file containing LDAP Credentials from a JSON file into the class.
            JsonSerializer jsonSerializer = new JsonSerializer();
            string         json           = File.ReadAllText(@"C:\A_Dev\Configs\ClientLoginCredentials.json");

            // Append JSON to existing objects values.
            jsonSerializer.Populate(new StringReader(json), config);


            // Validate the AD fields are still set to their original values.
            Assert.AreEqual(exGroupAttr, config.GroupAttr, "A50:  GroupAttr was changed during the reading of the LDAP config file.");
            Assert.AreEqual(exGroupFilter, config.GroupFilter, "A60:  GroupFilter was changed during the reading of the LDAP config file.");
            Assert.AreEqual(exUserAttr, config.UserAttr, "A70:  UserAttr was changed during the reading of the LDAP config file.");
        }