diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-05-23 03:16:37 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-05-23 03:16:37 +0000 |
commit | 908d44519c410db2ef841c72e501a6c198051b43 (patch) | |
tree | d3cdca7c8028f2ad4c9842f1cce683d9304862d8 /test | |
parent | 715c9d16ef2c2effbc614dace8b50d145e703b80 (diff) | |
download | redmine-908d44519c410db2ef841c72e501a6c198051b43.tar.gz redmine-908d44519c410db2ef841c72e501a6c198051b43.zip |
Allow AuthSources to control if they allow password changes.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3745 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/user_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index f63716501..77a9ee984 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -273,6 +273,32 @@ class UserTest < ActiveSupport::TestCase assert !u.password.blank? assert !u.password_confirmation.blank? end + + context "#change_password_allowed?" do + should "be allowed if no auth source is set" do + user = User.generate_with_protected! + assert user.change_password_allowed? + end + + should "delegate to the auth source" do + user = User.generate_with_protected! + + allowed_auth_source = AuthSource.generate! + def allowed_auth_source.allow_password_changes?; true; end + + denied_auth_source = AuthSource.generate! + def denied_auth_source.allow_password_changes?; false; end + + assert user.change_password_allowed? + + user.auth_source = allowed_auth_source + assert user.change_password_allowed?, "User not allowed to change password, though auth source does" + + user.auth_source = denied_auth_source + assert !user.change_password_allowed?, "User allowed to change password, though auth source does not" + end + + end if Object.const_defined?(:OpenID) |