# same secret token on each machine.
#secret_token: 'change it to a long random string'
+ # Requires users to re-enter their password for sensitive actions (editing
+ # of account data, project memberships, application settings, user, group,
+ # role, auth source management and project deletion).
+ # Disabled by default.
+ #
+ #sudo_mode: true
+
# Absolute path (e.g. /usr/bin/convert, c:/im/convert.exe) to
# the ImageMagick's `convert` binary. Used to generate attachment thumbnails.
#imagemagick_convert_command:
end
def self.possible?
- !disabled? && User.current.logged?
+ enabled? && User.current.logged?
end
# Turn off sudo mode (never require password entry).
RequestStore.store[:sudo_mode_disabled] = nil
end
- def self.disabled?
- !!RequestStore.store[:sudo_mode_disabled]
+ def self.enabled?
+ Redmine::Configuration['sudo_mode'] && !RequestStore.store[:sudo_mode_disabled]
end
-
end
end
def setup
@request.session[:user_id] = 1
- Redmine::SudoMode.disable!
end
def test_index
def setup
User.current = nil
- Redmine::SudoMode.disable!
end
def test_index_with_no_additional_emails
def setup
@request.session[:user_id] = 1
- Redmine::SudoMode.disable!
end
def test_index
def setup
User.current = nil
@request.session[:user_id] = 2
- Redmine::SudoMode.disable!
end
def test_new
def setup
@request.session[:user_id] = 2
- Redmine::SudoMode.disable!
end
def test_index
def setup
@request.session[:user_id] = nil
Setting.default_language = 'en'
- Redmine::SudoMode.disable!
end
def test_index_by_anonymous_should_not_show_private_projects
def setup
User.current = nil
@request.session[:user_id] = 1 # admin
- Redmine::SudoMode.disable!
end
def test_index
def setup
User.current = nil
@request.session[:user_id] = 1 # admin
- Redmine::SudoMode.disable!
end
def test_index
def setup
User.current = nil
@request.session[:user_id] = 1 # admin
- Redmine::SudoMode.disable!
end
def test_index
:members,
:enabled_modules
- def setup
- Redmine::SudoMode.enable!
- end
-
- def teardown
- Redmine::SudoMode.disable!
- end
-
def test_add_user
log_user("admin", "admin")
get "/users/new"
:lastname => "Smith", :mail => "psmith@somenet.foo",
:language => "en", :password => "psmith09",
:password_confirmation => "psmith09" }
- assert_response :success
- assert_nil User.find_by_login("psmith")
-
- post "/users",
- :user => { :login => "psmith", :firstname => "Paul",
- :lastname => "Smith", :mail => "psmith@somenet.foo",
- :language => "en", :password => "psmith09",
- :password_confirmation => "psmith09" },
- :sudo_password => 'admin'
user = User.find_by_login("psmith")
assert_kind_of User, user
fixtures :projects, :members, :member_roles, :roles, :users
def setup
- Redmine::SudoMode.enable!
+ Redmine::SudoMode.stubs(:enabled?).returns(true)
end
- def teardown
- Redmine::SudoMode.disable!
+ def test_add_user
+ log_user("admin", "admin")
+ get "/users/new"
+ assert_response :success
+ post "/users",
+ :user => { :login => "psmith", :firstname => "Paul",
+ :lastname => "Smith", :mail => "psmith@somenet.foo",
+ :language => "en", :password => "psmith09",
+ :password_confirmation => "psmith09" }
+ assert_response :success
+ assert_nil User.find_by_login("psmith")
+
+ post "/users",
+ :user => { :login => "psmith", :firstname => "Paul",
+ :lastname => "Smith", :mail => "psmith@somenet.foo",
+ :language => "en", :password => "psmith09",
+ :password_confirmation => "psmith09" },
+ :sudo_password => 'admin'
+ assert_response 302
+
+ user = User.find_by_login("psmith")
+ assert_kind_of User, user
end
def test_create_member_xhr
require 'net/ldap'
require 'mocha/setup'
+Redmine::SudoMode.disable!
+
class ActionView::TestCase
helper :application
include ApplicationHelper