Project

General

Profile

Feature #23307 » add_auth_source_id_to_api.patch

Anonymous, 2018-02-06 18:00

View differences:

app/views/users/index.api.rsb
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
app/views/users/show.api.rsb
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
test/fixtures/users.yml
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
test/functional/auth_sources_controller_test.rb
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
test/integration/api_test/users_test.rb
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
......
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',
(1-1/2)