public void Create_WithMapping_ConstructsWordListRetriever()
        {
            CustomWordListFactory.Configure((s) => s);
            var result = CustomWordListFactory.Create();

            Assert.IsInstanceOf <CustomWordListRetriever>(result);
        }
        public static void Reset()
        {
            Type t      = typeof(PasswordValidatorRegistration);
            var  pi     = t.GetProperty("IsRegistered", BindingFlags.NonPublic | BindingFlags.Static, null, typeof(bool), new Type[0], null);
            var  setter = pi.GetSetMethod(true);

            setter.Invoke(null, new object[] { false });
            CustomWordListFactory.Configure(null);
        }
Exemple #3
0
        public override bool Validate(string password)
        {
            var regex       = GetRegexForPassword(password);
            var customWords = CustomWordListFactory.Create();

            foreach (string fileName in Settings.CustomWordLists)
            {
                string wordList = customWords.Retrieve(fileName);
                if (regex.IsMatch(wordList))
                {
                    return(false);
                }
            }
            return(true);
        }
 /// <summary>
 /// Registers the <see cref="PasswordValidationAttribute"/> with the web
 /// application allowing it to map the virtual path specified in custom word
 /// list settings on the web server to the physical file path.
 /// </summary>
 public static void Register()
 {
     CustomWordListFactory.Configure(ServerPathMapper.MapPath);
     IsRegistered = true;
 }
 public void ResetTest()
 {
     CustomWordListFactory.Configure(null);
 }