OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/spec/lib/open_project/passwords_spec.rb

31 lines
1.3 KiB

require 'spec_helper'
require 'open_project/passwords'
describe OpenProject::Passwords::Generator do
describe :random_password do
it "should create a valid password" do
with_settings :password_active_rules => ['lowercase', 'uppercase', 'numeric', 'special'],
:password_min_adhered_rules => 3,
:password_min_length => 4 do
pwd = OpenProject::Passwords::Generator.random_password
OpenProject::Passwords::Evaluator.conforming?(pwd).should == true
end
end
end
end
describe OpenProject::Passwords::Evaluator do
it "should correctly evaluate passwords" do
with_settings :password_active_rules => ['lowercase', 'uppercase', 'numeric'],
:password_min_adhered_rules => 3,
:password_min_length => 4 do
OpenProject::Passwords::Evaluator.conforming?('abCD').should == false
OpenProject::Passwords::Evaluator.conforming?('ab12').should == false
OpenProject::Passwords::Evaluator.conforming?('12CD').should == false
OpenProject::Passwords::Evaluator.conforming?('12CD*').should == false
OpenProject::Passwords::Evaluator.conforming?('aB1').should == false
OpenProject::Passwords::Evaluator.conforming?('abCD12').should == true
OpenProject::Passwords::Evaluator.conforming?('aB123').should == true
end
end
end