public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            base.Initialize(name, config);
            try
            {
                _requiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));
                _enablePasswordRetrival = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"));
                _enablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
                _requiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "true"));
                _maxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "10"));
                _passwordStrengthRegualrExpression = GetConfigValue(config["passwordStrengthRegularExpression"],String.Empty);
                _minRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredAlphaNumericCharacters"],"1"));
                _minrequiredPasswordLength = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "2"));
                _passwordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "1"));
              
            }
            catch (Exception e  )
            {

                throw new ConfigurationErrorsException("Membership Provider Configuration wrong");
            }
            
            
            sb = DependencyInjectionHelper.GetSecurityBusinessComponent();
     
        }
        public void TestGetUserById()
        {
            SecurityBusinessComponent service = new SecurityBusinessComponent(this.context);
            User user = new User() {UserId = 123};

            Expect.Once.On(context).Method("GetUserById").Will(Return.Value(user));
            User resultUser = service.GetUserById(123);
            Assert.AreEqual<decimal>(user.UserId, resultUser.UserId);
            mockBuilder.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 3
0
        public CustomPrincipal(IIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            _identity = identity;

            sb = DependencyInjectionHelper.GetSecurityBusinessComponent();
            this._user = sb.GetUserByName(identity.Name);

            if (_user == null)
            {
                throw new Exception("unknown user");
            }
        }
        public void TestGetUserByCriteria()
        {
            SecurityBusinessComponent service = new SecurityBusinessComponent(this.context);
            Role role = new Role() {RoleId = 12345, RoleName = "FakeRoleName"};
            User user = new User {UserId = 456, UserName = "******", Roles = new List<Role> {role}.AsQueryable()};
            IList<User> users = new List<User>();
            users.Add(user);

            foreach (UserSearchType type in Enum.GetValues(typeof (UserSearchType)))
            {
                Expect.Once.On(context).Method("GetAllUsers").Will(Return.Value(users.AsQueryable()));
                IQueryable<User> resultUsers = service.GetUsersByCriteria(type, "FakeUserName", "FakeRoleName");
                Assert.AreEqual<decimal>(1, resultUsers.Count());
                Assert.AreEqual<decimal>(user.UserId, resultUsers.First().UserId);
            }

            mockBuilder.VerifyAllExpectationsHaveBeenMet();
        }
        public void TestStoreUser()
        {
            int userId = 123;
            SecurityBusinessComponent service = new SecurityBusinessComponent(this.context);
            User user = new User() {UserId = userId};
            List<ChangeItem> changeItems = new List<ChangeItem>
                                               {
                                                   new ChangeItem(ChangeType.ChildInsert, new Role()),
                                                   new ChangeItem(ChangeType.ChildUpate, new Role()),
                                                   new ChangeItem(ChangeType.ChildDelete, new Role())
                                               };

            Expect.Once.On(context).Method("SaveUser").Will(Return.Value(userId));
            Expect.Once.On(context).Method("AddUserToRole");
            Expect.Once.On(context).Method("AddUserToRole");
            Expect.Once.On(context).Method("RemoveUserFromRole");
            int resultUserId = service.StoreUser(user, changeItems);
            Assert.AreEqual<int>(userId, resultUserId);

            mockBuilder.VerifyAllExpectationsHaveBeenMet();
        }
 public HsrOrderAppRoleProvider()
 {
     _sb = DependencyInjectionHelper.GetSecurityBusinessComponent();
 }
 public void TestDeleteUser()
 {
     SecurityBusinessComponent service = new SecurityBusinessComponent(this.context);
     Expect.Once.On(context).Method("DeleteUser").With(1);
     service.DeleteUser(1);
     mockBuilder.VerifyAllExpectationsHaveBeenMet();
 }