Skip to content
代码片段 群组 项目
未验证 提交 fbe45b78 编辑于 作者: Jenny Kim's avatar Jenny Kim 提交者: GitLab
浏览文件

Merge branch 'revert-5500a16b' into 'master'

Revert "Merge branch 'jmc-fix-pr-spec' into 'master'"

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170462



Merged-by: default avatarJenny Kim <yjeankim@gitlab.com>
Approved-by: default avatarGrant Young <gyoung@gitlab.com>
Approved-by: default avatarMayra Cabrera <mcabrera@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -21,42 +21,6 @@ class User < Base ...@@ -21,42 +21,6 @@ class User < Base
:last_name, :last_name,
:email :email
def self.default
Resource::User.init do |user|
user.username = Runtime::User.ldap_user? ? Runtime::User.ldap_username : Runtime::User.username
user.password = Runtime::User.ldap_user? ? Runtime::User.ldap_password : Runtime::User.password
end
end
def self.fabricate_or_use(username = nil, password = nil)
if Runtime::Env.signup_disabled? && !Runtime::Env.personal_access_tokens_disabled?
fabricate_via_api! do |user|
user.username = username
user.password = password
end
else
fabricate! do |user|
user.username = username if username
user.password = password if password
end
end
end
# Get users from the API
#
# @param [Integer] per_page the number of pages to traverse (used for pagination)
# @return [Array<Hash>] parsed response body
def self.all(per_page: 100)
response = nil
Resource::User.init do |user|
response = user.get(Runtime::API::Request.new(
Runtime::API::Client.as_admin, '/users', per_page: per_page.to_s
).url)
raise ResourceQueryError unless response.code == 200
end.parse_body(response)
end
def initialize def initialize
@admin = false @admin = false
@hard_delete_on_api_removal = false @hard_delete_on_api_removal = false
...@@ -65,11 +29,11 @@ def initialize ...@@ -65,11 +29,11 @@ def initialize
@email_domain = 'example.com' @email_domain = 'example.com'
end end
# Override api_client to make sure admin pat is always used def self.default
# Resource::User.init do |user|
# @return [QA::Runtime::API::Client] user.username = Runtime::User.ldap_user? ? Runtime::User.ldap_username : Runtime::User.username
def api_client user.password = Runtime::User.ldap_user? ? Runtime::User.ldap_password : Runtime::User.password
@api_client ||= Runtime::API::Client.as_admin end
end end
def admin? def admin?
...@@ -193,6 +157,35 @@ def api_post_body ...@@ -193,6 +157,35 @@ def api_post_body
}.merge(ldap_post_body) }.merge(ldap_post_body)
end end
def self.fabricate_or_use(username = nil, password = nil)
if Runtime::Env.signup_disabled? && !Runtime::Env.personal_access_tokens_disabled?
fabricate_via_api! do |user|
user.username = username
user.password = password
end
else
fabricate! do |user|
user.username = username if username
user.password = password if password
end
end
end
# Get users from the API
#
# @param [Integer] per_page the number of pages to traverse (used for pagination)
# @return [Array<Hash>] parsed response body
def self.all(per_page: 100)
response = nil
Resource::User.init do |user|
response = user.get(Runtime::API::Request.new(
Runtime::API::Client.as_admin, '/users', per_page: per_page.to_s
).url)
raise ResourceQueryError unless response.code == 200
end.parse_body(response)
end
def approve! def approve!
response = post(Runtime::API::Request.new(api_client, api_approve_path).url, nil) response = post(Runtime::API::Request.new(api_client, api_approve_path).url, nil)
return if response.code == 201 return if response.code == 201
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册