Feature #23307 » add_auth_source_id_to_api.patch
| app/views/users/index.api.rsb | ||
|---|---|---|
| 8 | 8 |
api.mail user.mail |
| 9 | 9 |
api.created_on user.created_on |
| 10 | 10 |
api.last_login_on user.last_login_on |
| 11 |
api.auth_source_id user.auth_source_id |
|
| 11 | 12 | |
| 12 | 13 |
render_api_custom_values user.visible_custom_field_values, api |
| 13 | 14 |
end |
| app/views/users/show.api.rsb | ||
|---|---|---|
| 8 | 8 |
api.last_login_on @user.last_login_on |
| 9 | 9 |
api.api_key @user.api_key if User.current.admin? || (User.current == @user) |
| 10 | 10 |
api.status @user.status if User.current.admin? |
| 11 |
api.auth_source_id @user.auth_source_id if User.current.admin? |
|
| 11 | 12 | |
| 12 | 13 |
render_api_custom_values @user.visible_custom_field_values, api |
| test/fixtures/users.yml | ||
|---|---|---|
| 148 | 148 |
mail_notification: only_my_events |
| 149 | 149 |
login: miscuser9 |
| 150 | 150 |
type: User |
| 151 |
users_014: |
|
| 152 |
id: 14 |
|
| 153 |
created_on: 2006-07-19 19:33:19 +02:00 |
|
| 154 |
status: 1 |
|
| 155 |
last_login_on: |
|
| 156 |
language: 'de' |
|
| 157 |
hashed_password: 1 |
|
| 158 |
updated_on: 2006-07-19 19:33:19 +02:00 |
|
| 159 |
admin: false |
|
| 160 |
lastname: Ldap |
|
| 161 |
firstname: User |
|
| 162 |
auth_source_id: 1 |
|
| 163 |
mail_notification: only_my_events |
|
| 164 |
login: ldapuser |
|
| 165 |
type: User |
|
| 151 | 166 |
groups_010: |
| 152 | 167 |
id: 10 |
| 153 | 168 |
lastname: A Team |
| test/functional/auth_sources_controller_test.rb | ||
|---|---|---|
| 142 | 142 |
assert_select_error /host cannot be blank/i |
| 143 | 143 |
end |
| 144 | 144 | |
| 145 |
def test_destroy |
|
| 145 |
def test_destroy_auth_source_not_in_use |
|
| 146 |
User.find(14).update_attribute :auth_source_id, nil |
|
| 146 | 147 |
assert_difference 'AuthSourceLdap.count', -1 do |
| 147 | 148 |
delete :destroy, :params => {
|
| 148 | 149 |
:id => 1 |
| test/integration/api_test/users_test.rb | ||
|---|---|---|
| 28 | 28 |
assert_select 'users' do |
| 29 | 29 |
assert_select 'user', User.active.count |
| 30 | 30 |
end |
| 31 |
assert_select 'users user' do |
|
| 32 |
assert_select 'id', User.active.count |
|
| 33 |
assert_select 'login', User.active.count |
|
| 34 |
assert_select 'firstname', User.active.count |
|
| 35 |
assert_select 'lastname', User.active.count |
|
| 36 |
assert_select 'mail', User.active.count |
|
| 37 |
assert_select 'created_on', User.active.count |
|
| 38 |
assert_select 'last_login_on', User.active.count |
|
| 39 |
assert_select 'auth_source_id', User.active.count |
|
| 40 |
assert_select 'auth_source_id', "" |
|
| 41 |
assert_select 'auth_source_id', "1" |
|
| 42 |
end |
|
| 31 | 43 |
end |
| 32 | 44 | |
| 33 | 45 |
test "GET /users.json should return users" do |
| ... | ... | |
| 125 | 137 |
assert_select 'user status', :text => User.find(1).status.to_s |
| 126 | 138 |
end |
| 127 | 139 | |
| 140 |
test "GET /users/:id should not return auth_source_id for standard user" do |
|
| 141 |
get '/users/14.xml', :headers => credentials('jsmith')
|
|
| 142 |
assert_response :success |
|
| 143 |
assert_select 'user auth_source_id', 0 |
|
| 144 |
end |
|
| 145 | ||
| 146 |
test "GET /users/:id should return auth_source_id for administrators" do |
|
| 147 |
get '/users/14.xml', :headers => credentials('admin')
|
|
| 148 |
assert_response :success |
|
| 149 |
assert_select 'user auth_source_id', :text => '1' |
|
| 150 |
end |
|
| 151 | ||
| 128 | 152 |
test "POST /users.xml with valid parameters should create the user" do |
| 129 | 153 |
assert_difference('User.count') do
|
| 130 | 154 |
post '/users.xml', |