Use 8+ characters long passwords in tests.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10886 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
14e56006a1
commit
e43448f6ca
|
@ -119,8 +119,8 @@ class AccountControllerTest < ActionController::TestCase
|
||||||
assert_difference 'User.count' do
|
assert_difference 'User.count' do
|
||||||
post :register, :user => {
|
post :register, :user => {
|
||||||
:login => 'register',
|
:login => 'register',
|
||||||
:password => 'test',
|
:password => 'secret123',
|
||||||
:password_confirmation => 'test',
|
:password_confirmation => 'secret123',
|
||||||
:firstname => 'John',
|
:firstname => 'John',
|
||||||
:lastname => 'Doe',
|
:lastname => 'Doe',
|
||||||
:mail => 'register@example.com'
|
:mail => 'register@example.com'
|
||||||
|
@ -132,7 +132,7 @@ class AccountControllerTest < ActionController::TestCase
|
||||||
assert_equal 'John', user.firstname
|
assert_equal 'John', user.firstname
|
||||||
assert_equal 'Doe', user.lastname
|
assert_equal 'Doe', user.lastname
|
||||||
assert_equal 'register@example.com', user.mail
|
assert_equal 'register@example.com', user.mail
|
||||||
assert user.check_password?('test')
|
assert user.check_password?('secret123')
|
||||||
assert user.active?
|
assert user.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -218,10 +218,10 @@ class AccountControllerTest < ActionController::TestCase
|
||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
|
post :lost_password, :token => token.value, :new_password => 'newpass123', :new_password_confirmation => 'newpass123'
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
user.reload
|
user.reload
|
||||||
assert user.check_password?('newpass')
|
assert user.check_password?('newpass123')
|
||||||
assert_nil Token.find_by_id(token.id), "Token was not deleted"
|
assert_nil Token.find_by_id(token.id), "Token was not deleted"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -230,9 +230,9 @@ class AccountControllerTest < ActionController::TestCase
|
||||||
token = Token.create!(:action => 'recovery', :user => user)
|
token = Token.create!(:action => 'recovery', :user => user)
|
||||||
user.lock!
|
user.lock!
|
||||||
|
|
||||||
post :lost_password, :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
|
post :lost_password, :token => token.value, :new_password => 'newpass123', :new_password_confirmation => 'newpass123'
|
||||||
assert_redirected_to '/'
|
assert_redirected_to '/'
|
||||||
assert ! user.check_password?('newpass')
|
assert ! user.check_password?('newpass123')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_lost_password_with_token_and_password_confirmation_failure_should_redisplay_the_form
|
def test_post_lost_password_with_token_and_password_confirmation_failure_should_redisplay_the_form
|
||||||
|
|
|
@ -145,26 +145,26 @@ class MyControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# non matching password confirmation
|
# non matching password confirmation
|
||||||
post :password, :password => 'jsmith',
|
post :password, :password => 'jsmith',
|
||||||
:new_password => 'hello',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'hello2'
|
:new_password_confirmation => 'secret1234'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'password'
|
assert_template 'password'
|
||||||
assert_error_tag :content => /Password doesn't match confirmation/
|
assert_error_tag :content => /Password doesn't match confirmation/
|
||||||
|
|
||||||
# wrong password
|
# wrong password
|
||||||
post :password, :password => 'wrongpassword',
|
post :password, :password => 'wrongpassword',
|
||||||
:new_password => 'hello',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'hello'
|
:new_password_confirmation => 'secret123'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'password'
|
assert_template 'password'
|
||||||
assert_equal 'Wrong password', flash[:error]
|
assert_equal 'Wrong password', flash[:error]
|
||||||
|
|
||||||
# good password
|
# good password
|
||||||
post :password, :password => 'jsmith',
|
post :password, :password => 'jsmith',
|
||||||
:new_password => 'hello',
|
:new_password => 'secret123',
|
||||||
:new_password_confirmation => 'hello'
|
:new_password_confirmation => 'secret123'
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
assert User.try_to_login('jsmith', 'hello')
|
assert User.try_to_login('jsmith', 'secret123')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_change_password_should_redirect_if_user_cannot_change_its_password
|
def test_change_password_should_redirect_if_user_cannot_change_its_password
|
||||||
|
|
|
@ -173,8 +173,8 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
:firstname => 'John',
|
:firstname => 'John',
|
||||||
:lastname => 'Doe',
|
:lastname => 'Doe',
|
||||||
:login => 'jdoe',
|
:login => 'jdoe',
|
||||||
:password => 'secret',
|
:password => 'secret123',
|
||||||
:password_confirmation => 'secret',
|
:password_confirmation => 'secret123',
|
||||||
:mail => 'jdoe@gmail.com',
|
:mail => 'jdoe@gmail.com',
|
||||||
:mail_notification => 'none'
|
:mail_notification => 'none'
|
||||||
},
|
},
|
||||||
|
@ -190,7 +190,7 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
assert_equal 'jdoe', user.login
|
assert_equal 'jdoe', user.login
|
||||||
assert_equal 'jdoe@gmail.com', user.mail
|
assert_equal 'jdoe@gmail.com', user.mail
|
||||||
assert_equal 'none', user.mail_notification
|
assert_equal 'none', user.mail_notification
|
||||||
assert user.check_password?('secret')
|
assert user.check_password?('secret123')
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert_not_nil mail
|
assert_not_nil mail
|
||||||
|
@ -205,8 +205,8 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
:firstname => 'John',
|
:firstname => 'John',
|
||||||
:lastname => 'Doe',
|
:lastname => 'Doe',
|
||||||
:login => 'jdoe',
|
:login => 'jdoe',
|
||||||
:password => 'secret',
|
:password => 'secret123',
|
||||||
:password_confirmation => 'secret',
|
:password_confirmation => 'secret123',
|
||||||
:mail => 'jdoe@gmail.com',
|
:mail => 'jdoe@gmail.com',
|
||||||
:mail_notification => 'none'
|
:mail_notification => 'none'
|
||||||
},
|
},
|
||||||
|
@ -287,14 +287,14 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
Setting.bcc_recipients = '1'
|
Setting.bcc_recipients = '1'
|
||||||
|
|
||||||
put :update, :id => 2, :user => {:password => 'newpass', :password_confirmation => 'newpass'}, :send_information => '1'
|
put :update, :id => 2, :user => {:password => 'newpass123', :password_confirmation => 'newpass123'}, :send_information => '1'
|
||||||
u = User.find(2)
|
u = User.find(2)
|
||||||
assert u.check_password?('newpass')
|
assert u.check_password?('newpass123')
|
||||||
|
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert_not_nil mail
|
assert_not_nil mail
|
||||||
assert_equal [u.mail], mail.bcc
|
assert_equal [u.mail], mail.bcc
|
||||||
assert_mail_body_match 'newpass', mail
|
assert_mail_body_match 'newpass123', mail
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_user_switchin_from_auth_source_to_password_authentication
|
def test_update_user_switchin_from_auth_source_to_password_authentication
|
||||||
|
@ -303,10 +303,10 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
u.auth_source = AuthSource.find(1)
|
u.auth_source = AuthSource.find(1)
|
||||||
u.save!
|
u.save!
|
||||||
|
|
||||||
put :update, :id => u.id, :user => {:auth_source_id => '', :password => 'newpass', :password_confirmation => 'newpass'}
|
put :update, :id => u.id, :user => {:auth_source_id => '', :password => 'newpass123', :password_confirmation => 'newpass123'}
|
||||||
|
|
||||||
assert_equal nil, u.reload.auth_source
|
assert_equal nil, u.reload.auth_source
|
||||||
assert u.check_password?('newpass')
|
assert u.check_password?('newpass123')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_notified_project
|
def test_update_notified_project
|
||||||
|
|
|
@ -91,11 +91,11 @@ class AccountTest < ActionController::IntegrationTest
|
||||||
assert_select 'input[name=new_password]'
|
assert_select 'input[name=new_password]'
|
||||||
assert_select 'input[name=new_password_confirmation]'
|
assert_select 'input[name=new_password_confirmation]'
|
||||||
|
|
||||||
post "account/lost_password", :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
|
post "account/lost_password", :token => token.value, :new_password => 'newpass123', :new_password_confirmation => 'newpass123'
|
||||||
assert_redirected_to "/login"
|
assert_redirected_to "/login"
|
||||||
assert_equal 'Password was successfully updated.', flash[:notice]
|
assert_equal 'Password was successfully updated.', flash[:notice]
|
||||||
|
|
||||||
log_user('jsmith', 'newpass')
|
log_user('jsmith', 'newpass123')
|
||||||
assert_equal 0, Token.count
|
assert_equal 0, Token.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class AccountTest < ActionController::IntegrationTest
|
||||||
assert_template 'account/register'
|
assert_template 'account/register'
|
||||||
|
|
||||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
|
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
|
||||||
:password => "newpass", :password_confirmation => "newpass"}
|
:password => "newpass123", :password_confirmation => "newpass123"}
|
||||||
assert_redirected_to '/my/account'
|
assert_redirected_to '/my/account'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -123,7 +123,7 @@ class AccountTest < ActionController::IntegrationTest
|
||||||
Setting.self_registration = '2'
|
Setting.self_registration = '2'
|
||||||
|
|
||||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
|
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
|
||||||
:password => "newpass", :password_confirmation => "newpass"}
|
:password => "newpass123", :password_confirmation => "newpass123"}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
assert !User.find_by_login('newuser').active?
|
assert !User.find_by_login('newuser').active?
|
||||||
end
|
end
|
||||||
|
@ -133,7 +133,7 @@ class AccountTest < ActionController::IntegrationTest
|
||||||
Token.delete_all
|
Token.delete_all
|
||||||
|
|
||||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
|
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar",
|
||||||
:password => "newpass", :password_confirmation => "newpass"}
|
:password => "newpass123", :password_confirmation => "newpass123"}
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
assert !User.find_by_login('newuser').active?
|
assert !User.find_by_login('newuser').active?
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class AccountTest < ActionController::IntegrationTest
|
||||||
|
|
||||||
get 'account/activate', :token => token.value
|
get 'account/activate', :token => token.value
|
||||||
assert_redirected_to '/login'
|
assert_redirected_to '/login'
|
||||||
log_user('newuser', 'newpass')
|
log_user('newuser', 'newpass123')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_onthefly_registration
|
def test_onthefly_registration
|
||||||
|
|
|
@ -102,7 +102,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
|
||||||
@parameters = {
|
@parameters = {
|
||||||
:user => {
|
:user => {
|
||||||
:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
|
:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
|
||||||
:mail => 'foo@example.net', :password => 'secret',
|
:mail => 'foo@example.net', :password => 'secret123',
|
||||||
:mail_notification => 'only_assigned'
|
:mail_notification => 'only_assigned'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
|
||||||
'/users.xml',
|
'/users.xml',
|
||||||
{:user => {
|
{:user => {
|
||||||
:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
|
:login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
|
||||||
:mail => 'foo@example.net', :password => 'secret'
|
:mail => 'foo@example.net', :password => 'secret123'
|
||||||
}},
|
}},
|
||||||
{:success_code => :created})
|
{:success_code => :created})
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
|
||||||
assert_equal 'foo@example.net', user.mail
|
assert_equal 'foo@example.net', user.mail
|
||||||
assert_equal 'only_assigned', user.mail_notification
|
assert_equal 'only_assigned', user.mail_notification
|
||||||
assert !user.admin?
|
assert !user.admin?
|
||||||
assert user.check_password?('secret')
|
assert user.check_password?('secret123')
|
||||||
|
|
||||||
assert_response :created
|
assert_response :created
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
|
|
|
@ -37,9 +37,9 @@ class LayoutTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
test "browsing to an unauthorized page should render the base layout" do
|
test "browsing to an unauthorized page should render the base layout" do
|
||||||
change_user_password('miscuser9', 'test')
|
change_user_password('miscuser9', 'test1234')
|
||||||
|
|
||||||
log_user('miscuser9','test')
|
log_user('miscuser9','test1234')
|
||||||
|
|
||||||
get "/admin"
|
get "/admin"
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
|
@ -77,7 +77,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
assert_equal 1, user.errors.count
|
assert_equal 1, user.errors.count
|
||||||
|
|
||||||
user.login = "newuser"
|
user.login = "newuser"
|
||||||
user.password, user.password_confirmation = "passwd", "password"
|
user.password, user.password_confirmation = "password", "pass"
|
||||||
# password confirmation
|
# password confirmation
|
||||||
assert !user.save
|
assert !user.save
|
||||||
assert_equal 1, user.errors.count
|
assert_equal 1, user.errors.count
|
||||||
|
@ -375,12 +375,12 @@ class UserTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
should "select the exact matching user first" do
|
should "select the exact matching user first" do
|
||||||
case_sensitive_user = User.generate! do |user|
|
case_sensitive_user = User.generate! do |user|
|
||||||
user.password = "admin"
|
user.password = "admin123"
|
||||||
end
|
end
|
||||||
# bypass validations to make it appear like existing data
|
# bypass validations to make it appear like existing data
|
||||||
case_sensitive_user.update_attribute(:login, 'ADMIN')
|
case_sensitive_user.update_attribute(:login, 'ADMIN')
|
||||||
|
|
||||||
user = User.try_to_login("ADMIN", "admin")
|
user = User.try_to_login("ADMIN", "admin123")
|
||||||
assert_kind_of User, user
|
assert_kind_of User, user
|
||||||
assert_equal "ADMIN", user.login
|
assert_equal "ADMIN", user.login
|
||||||
|
|
||||||
|
@ -391,10 +391,10 @@ class UserTest < ActiveSupport::TestCase
|
||||||
user = User.try_to_login("admin", "admin")
|
user = User.try_to_login("admin", "admin")
|
||||||
assert_kind_of User, user
|
assert_kind_of User, user
|
||||||
assert_equal "admin", user.login
|
assert_equal "admin", user.login
|
||||||
user.password = "hello"
|
user.password = "hello123"
|
||||||
assert user.save
|
assert user.save
|
||||||
|
|
||||||
user = User.try_to_login("admin", "hello")
|
user = User.try_to_login("admin", "hello123")
|
||||||
assert_kind_of User, user
|
assert_kind_of User, user
|
||||||
assert_equal "admin", user.login
|
assert_equal "admin", user.login
|
||||||
end
|
end
|
||||||
|
@ -695,7 +695,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
def test_default_admin_account_changed_should_return_false_if_account_was_not_changed
|
def test_default_admin_account_changed_should_return_false_if_account_was_not_changed
|
||||||
user = User.find_by_login("admin")
|
user = User.find_by_login("admin")
|
||||||
user.password = "admin"
|
user.password = "admin"
|
||||||
user.save!
|
assert user.save(:validate => false)
|
||||||
|
|
||||||
assert_equal false, User.default_admin_account_changed?
|
assert_equal false, User.default_admin_account_changed?
|
||||||
end
|
end
|
||||||
|
@ -712,7 +712,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
user = User.find_by_login("admin")
|
user = User.find_by_login("admin")
|
||||||
user.password = "admin"
|
user.password = "admin"
|
||||||
user.status = User::STATUS_LOCKED
|
user.status = User::STATUS_LOCKED
|
||||||
user.save!
|
assert user.save(:validate => false)
|
||||||
|
|
||||||
assert_equal true, User.default_admin_account_changed?
|
assert_equal true, User.default_admin_account_changed?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue