Minimum password length is configurable with the min_password_length site setting. FIX: reset password needs to validate password length.

This commit is contained in:
Neil Lalonde
2013-12-19 16:15:36 -05:00
parent 33c6997ded
commit 854d9c8fc6
7 changed files with 43 additions and 24 deletions

View File

@ -8,28 +8,42 @@ describe PasswordValidator do
context "password required" do
let(:record) { u = Fabricate.build(:user, password: @password); u.password_required!; u }
it "doesn't add an error when password is good" do
@password = "weron235alsfn234"
validate
record.errors[:password].should_not be_present
context "min password length is 8" do
before { SiteSetting.stubs(:min_password_length).returns(8) }
it "doesn't add an error when password is good" do
@password = "weron235alsfn234"
validate
record.errors[:password].should_not be_present
end
it "adds an error when password is too short" do
@password = "p"
validate
record.errors[:password].should be_present
end
it "adds an error when password is blank" do
@password = ''
validate
record.errors[:password].should be_present
end
it "adds an error when password is nil" do
@password = nil
validate
record.errors[:password].should be_present
end
end
it "adds an error when password is too short" do
@password = "p"
validate
record.errors[:password].should be_present
end
context "min password length is 12" do
before { SiteSetting.stubs(:min_password_length).returns(12) }
it "adds an error when password is blank" do
@password = ''
validate
record.errors[:password].should be_present
end
it "adds an error when password is nil" do
@password = nil
validate
record.errors[:password].should be_present
it "adds an error when password length is 11" do
@password = "gt38sdt92bv"
validate
record.errors[:password].should be_present
end
end
end