Beispiel #1
0
        public void ChangeAppName()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", _connStrName);
            config.Add("applicationName", _applicationName);
            config.Add("requiresUniqueEmail", "false");
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", "Clear");
            provider.Initialize(null, config);
            MembershipCreateStatus status;

            provider.CreateUser("foo", "bar!bar", null, null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            MongoProviders.MembershipProvider provider2 = new MongoProviders.MembershipProvider();
            NameValueCollection config2 = new NameValueCollection();

            config2.Add("connectionStringName", _connStrName);
            config2.Add("applicationName", _appName2);
            config2.Add("requiresUniqueEmail", "false");
            config2.Add("passwordStrengthRegularExpression", "foo.*");
            config2.Add("passwordFormat", "Clear");
            provider2.Initialize(null, config2);
            provider2.CreateUser("foo2", "foo!foo", null, null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            provider.ApplicationName = "/myapp";
            Assert.IsFalse(provider.ValidateUser("foo", "bar!bar"));
            Assert.IsTrue(provider.ValidateUser("foo2", "foo!foo"));
        }
Beispiel #2
0
        public void CrossAppLogin()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", _connStrName);
            config.Add("applicationName", _applicationName);
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", "Clear");
            provider.Initialize(null, config);
            MembershipCreateStatus status;

            provider.CreateUser("foo", "bar!bar", null, null, null, true, null, out status);

            MongoProviders.MembershipProvider provider2 = new MongoProviders.MembershipProvider();
            NameValueCollection config2 = new NameValueCollection();

            config2.Add("connectionStringName", _connStrName);
            config2.Add("applicationName", _appName2);
            config2.Add("passwordStrengthRegularExpression", ".*");
            config2.Add("passwordFormat", "Clear");
            provider2.Initialize(null, config2);

            bool worked = provider2.ValidateUser("foo", "bar!bar");

            Assert.AreEqual(false, worked);

            _db.DropCollection(provider2.CollectionName);
        }
Beispiel #3
0
        public void GetPasswordWithWrongAnswer()
        {
            MembershipCreateStatus status;
            NameValueCollection    config = new NameValueCollection();

            config.Add("connectionStringName", _connStrName);
            config.Add("requiresQuestionAndAnswer", "true");
            config.Add("enablePasswordRetrieval", "true");
            config.Add("passwordFormat", "Encrypted");
            config.Add("applicationName", _applicationName);
            provider.Initialize(null, config);
            provider.CreateUser("foo", "barbar!", "*****@*****.**", "color", "blue", true, null, out status);

            MongoProviders.MembershipProvider provider2 = new MongoProviders.MembershipProvider();
            NameValueCollection config2 = new NameValueCollection();

            config2.Add("connectionStringName", _connStrName);
            config2.Add("requiresQuestionAndAnswer", "true");
            config2.Add("enablePasswordRetrieval", "true");
            config2.Add("passwordFormat", "Encrypted");
            config2.Add("applicationName", _applicationName);
            provider2.Initialize(null, config2);

            try
            {
                string pw = provider2.GetPassword("foo", "wrong");
                Assert.Fail("Should have  failed");
            }
            catch (MembershipPasswordException)
            {
            }
        }
        public void ChangeAppName()
        {
            NameValueCollection config = new NameValueCollection();
            config.Add("connectionStringName", _connStrName);
            config.Add("applicationName", _applicationName);
            config.Add("requiresUniqueEmail", "false");
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", "Clear");
            provider.Initialize(null, config);
            MembershipCreateStatus status;
            provider.CreateUser("foo", "bar!bar", null, null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            MongoProviders.MembershipProvider provider2 = new MongoProviders.MembershipProvider();
            NameValueCollection config2 = new NameValueCollection();
            config2.Add("connectionStringName", _connStrName);
            config2.Add("applicationName", _appName2);
            config2.Add("requiresUniqueEmail", "false");
            config2.Add("passwordStrengthRegularExpression", "foo.*");
            config2.Add("passwordFormat", "Clear");
            provider2.Initialize(null, config2);
            provider2.CreateUser("foo2", "foo!foo", null, null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            provider.ApplicationName = "/myapp";
            Assert.IsFalse(provider.ValidateUser("foo", "bar!bar"));
            Assert.IsTrue(provider.ValidateUser("foo2", "foo!foo"));
        }
        public void GetPasswordWithWrongAnswer()
        {
            MembershipCreateStatus status;
            NameValueCollection config = new NameValueCollection();
            config.Add("connectionStringName", _connStrName);
            config.Add("requiresQuestionAndAnswer", "true");
            config.Add("enablePasswordRetrieval", "true");
            config.Add("passwordFormat", "Encrypted");
            config.Add("applicationName", _applicationName);
            provider.Initialize(null, config);
            provider.CreateUser("foo", "barbar!", "*****@*****.**", "color", "blue", true, null, out status);

            MongoProviders.MembershipProvider provider2 = new MongoProviders.MembershipProvider();
            NameValueCollection config2 = new NameValueCollection();
            config2.Add("connectionStringName", _connStrName);
            config2.Add("requiresQuestionAndAnswer", "true");
            config2.Add("enablePasswordRetrieval", "true");
            config2.Add("passwordFormat", "Encrypted");
            config2.Add("applicationName", _applicationName);
            provider2.Initialize(null, config2);

            try
            {
                string pw = provider2.GetPassword("foo", "wrong");
                Assert.Fail("Should have  failed");
            }
            catch (MembershipPasswordException)
            {
            }
        }
        public void CrossAppLogin()
        {
            NameValueCollection config = new NameValueCollection();
            config.Add("connectionStringName", _connStrName);
            config.Add("applicationName", _applicationName);
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", "Clear");
            provider.Initialize(null, config);
            MembershipCreateStatus status;
            provider.CreateUser("foo", "bar!bar", null, null, null, true, null, out status);

            MongoProviders.MembershipProvider provider2 = new MongoProviders.MembershipProvider();
            NameValueCollection config2 = new NameValueCollection();
            config2.Add("connectionStringName", _connStrName);
            config2.Add("applicationName", _appName2);
            config2.Add("passwordStrengthRegularExpression", ".*");
            config2.Add("passwordFormat", "Clear");
            provider2.Initialize(null, config2);

            bool worked = provider2.ValidateUser("foo", "bar!bar");
            Assert.AreEqual(false, worked);

            _db.DropCollection(provider2.CollectionName);
        }