CE port of Move EE specific lines in API::Users

This commit is contained in:
Imre Farkas 2019-05-28 10:14:26 +00:00 committed by Yorick Peterse
parent 9c2d0d8758
commit 3895e54741
3 changed files with 32 additions and 8 deletions

View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
module API
module Helpers
module UsersHelpers
extend ActiveSupport::Concern
extend Grape::API::Helpers
params :optional_params_ee do
end
params :optional_index_params_ee do
end
end
end
end

View File

@ -15,6 +15,8 @@ module API
authenticate_non_get!
end
helpers Helpers::UsersHelpers
helpers do
# rubocop: disable CodeReuse/ActiveRecord
def find_user_by_id(params)
@ -52,10 +54,7 @@ module API
optional :private_profile, type: Boolean, desc: 'Flag indicating the user has a private profile'
all_or_none_of :extern_uid, :provider
if Gitlab.ee?
optional :shared_runners_minutes_limit, type: Integer, desc: 'Pipeline minutes quota for this user'
optional :extra_shared_runners_minutes_limit, type: Integer, desc: '(admin-only) Extra pipeline minutes quota for this user'
end
use :optional_params_ee
end
params :sort_params do
@ -85,10 +84,7 @@ module API
use :sort_params
use :pagination
use :with_custom_attributes
if Gitlab.ee?
optional :skip_ldap, type: Boolean, default: false, desc: 'Skip LDAP users'
end
use :optional_index_params_ee
end
# rubocop: disable CodeReuse/ActiveRecord
get do

View File

@ -276,6 +276,18 @@ describe API::Users do
expect(response).to have_gitlab_http_status(400)
end
end
context "when authenticated and ldap is enabled" do
it "returns non-ldap user" do
create :omniauth_user, provider: "ldapserver1"
get api("/users", user), params: { skip_ldap: "true" }
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first["username"]).to eq user.username
end
end
end
describe "GET /users/:id" do