diff --git a/app/views/users/index.api.rsb b/app/views/users/index.api.rsb index 4265a4be4..4e898f4de 100644 --- a/app/views/users/index.api.rsb +++ b/app/views/users/index.api.rsb @@ -8,6 +8,7 @@ api.array :users, api_meta(:total_count => @user_count, :offset => @offset, :lim api.mail user.mail api.created_on user.created_on api.last_login_on user.last_login_on + api.auth_source_id user.auth_source_id render_api_custom_values user.visible_custom_field_values, api end diff --git a/app/views/users/show.api.rsb b/app/views/users/show.api.rsb index e4c49f9b8..59452037d 100644 --- a/app/views/users/show.api.rsb +++ b/app/views/users/show.api.rsb @@ -8,6 +8,7 @@ api.user do api.last_login_on @user.last_login_on api.api_key @user.api_key if User.current.admin? || (User.current == @user) api.status @user.status if User.current.admin? + api.auth_source_id @user.auth_source_id if User.current.admin? render_api_custom_values @user.visible_custom_field_values, api diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 986ed5d67..da1241206 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -148,6 +148,21 @@ users_009: mail_notification: only_my_events login: miscuser9 type: User +users_014: + id: 14 + created_on: 2006-07-19 19:33:19 +02:00 + status: 1 + last_login_on: + language: 'de' + hashed_password: 1 + updated_on: 2006-07-19 19:33:19 +02:00 + admin: false + lastname: Ldap + firstname: User + auth_source_id: 1 + mail_notification: only_my_events + login: ldapuser + type: User groups_010: id: 10 lastname: A Team diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index e6bfcf54c..b45ad7b57 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -142,7 +142,8 @@ class AuthSourcesControllerTest < Redmine::ControllerTest assert_select_error /host cannot be blank/i end - def test_destroy + def test_destroy_auth_source_not_in_use + User.find(14).update_attribute :auth_source_id, nil assert_difference 'AuthSourceLdap.count', -1 do delete :destroy, :params => { :id => 1 diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb index 468caf398..c02191c87 100644 --- a/test/integration/api_test/users_test.rb +++ b/test/integration/api_test/users_test.rb @@ -28,6 +28,18 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base assert_select 'users' do assert_select 'user', User.active.count end + assert_select 'users user' do + assert_select 'id', User.active.count + assert_select 'login', User.active.count + assert_select 'firstname', User.active.count + assert_select 'lastname', User.active.count + assert_select 'mail', User.active.count + assert_select 'created_on', User.active.count + assert_select 'last_login_on', User.active.count + assert_select 'auth_source_id', User.active.count + assert_select 'auth_source_id', "" + assert_select 'auth_source_id', "1" + end end test "GET /users.json should return users" do @@ -125,6 +137,18 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base assert_select 'user status', :text => User.find(1).status.to_s end + test "GET /users/:id should not return auth_source_id for standard user" do + get '/users/14.xml', :headers => credentials('jsmith') + assert_response :success + assert_select 'user auth_source_id', 0 + end + + test "GET /users/:id should return auth_source_id for administrators" do + get '/users/14.xml', :headers => credentials('admin') + assert_response :success + assert_select 'user auth_source_id', :text => '1' + end + test "POST /users.xml with valid parameters should create the user" do assert_difference('User.count') do post '/users.xml',