mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user