summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-04-19 19:50:38 +0000
committerRobert Speicher <robert@gitlab.com>2017-04-19 19:50:38 +0000
commit93e23a5d718eafb78c4b8d5b605d740d48c75418 (patch)
treea20733da8f0a9f442e48d8ae1324edadd3b01b77 /spec
parenta4688d9d9ac2af39562770d011394a2151a12c60 (diff)
parentddf7e6ae78cc87314d081427f00d54f203cfd60a (diff)
downloadgitlab-ce-93e23a5d718eafb78c4b8d5b605d740d48c75418.tar.gz
Merge branch 'query-users-by-extern-uid' into 'master'
Implement search by extern_uid in Users API See merge request !10509
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/users_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index ea9b886e995..165ab389917 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -72,6 +72,12 @@ describe API::Users, api: true do
expect(json_response).to be_an Array
expect(json_response.first['username']).to eq(omniauth_user.username)
end
+
+ it "returns a 403 when non-admin user searches by external UID" do
+ get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}&provider=#{omniauth_user.identities.first.provider}", user)
+
+ expect(response).to have_http_status(403)
+ end
end
context "when admin" do
@@ -100,6 +106,27 @@ describe API::Users, api: true do
expect(json_response).to be_an Array
expect(json_response).to all(include('external' => true))
end
+
+ it "returns one user by external UID" do
+ get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}&provider=#{omniauth_user.identities.first.provider}", admin)
+
+ expect(response).to have_http_status(200)
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(1)
+ expect(json_response.first['username']).to eq(omniauth_user.username)
+ end
+
+ it "returns 400 error if provider with no extern_uid" do
+ get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}", admin)
+
+ expect(response).to have_http_status(400)
+ end
+
+ it "returns 400 error if provider with no extern_uid" do
+ get api("/users?provider=#{omniauth_user.identities.first.provider}", admin)
+
+ expect(response).to have_http_status(400)
+ end
end
end