summaryrefslogtreecommitdiffstats
path: root/test/integration/api_test
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-01-31 03:24:44 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-01-31 03:24:44 +0000
commitc1fa75386ceb17880168f24ad0d7c76af7c659ff (patch)
tree1ccd6f06b8609c74214ef7a60fbdb494e2716095 /test/integration/api_test
parentb971a49c3e1566eab29d9eb9c6305081c4dabc3e (diff)
downloadredmine-c1fa75386ceb17880168f24ad0d7c76af7c659ff.tar.gz
redmine-c1fa75386ceb17880168f24ad0d7c76af7c659ff.zip
Include auth_source in /users API response if request includes auth_source (#23307).
git-svn-id: https://svn.redmine.org/redmine/trunk@22666 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration/api_test')
-rw-r--r--test/integration/api_test/users_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 89d1f9f86..88f39bf20 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -128,6 +128,25 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_equal 0, json['users'].size
end
+ test "GET /users.json with include=auth_source" do
+ user = User.find(2)
+ user.update(:auth_source_id => 1)
+ get '/users.json?include=auth_source', :headers => credentials('admin')
+
+ json = ActiveSupport::JSON.decode(response.body)
+ assert json.key?('users')
+
+ json['users'].each do | user_json |
+ if user_json['id'] == user.id
+ assert_kind_of Hash, user_json['auth_source']
+ assert_equal user.auth_source.id, user_json['auth_source']['id']
+ assert_equal user.auth_source.name, user_json['auth_source']['name']
+ else
+ assert_nil user_json['auth_source']
+ end
+ end
+ end
+
test "GET /users.json with short filters" do
get '/users.json', headers: credentials('admin'), params: { status: "1|3" }
assert_response :success