Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
bba43d5b
未验证
提交
bba43d5b
编辑于
5 months ago
作者:
Andrejs Cunskis
浏览文件
操作
下载
补丁
差异文件
Remove admin password reset from license fabrication
上级
4b0c6a1b
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
qa/qa/ce/strategy.rb
+59
-32
59 个添加, 32 个删除
qa/qa/ce/strategy.rb
qa/qa/ee/resource/license.rb
+3
-12
3 个添加, 12 个删除
qa/qa/ee/resource/license.rb
qa/qa/ee/strategy.rb
+7
-10
7 个添加, 10 个删除
qa/qa/ee/strategy.rb
有
69 个添加
和
54 个删除
qa/qa/ce/strategy.rb
+
59
−
32
浏览文件 @
bba43d5b
...
@@ -3,49 +3,76 @@
...
@@ -3,49 +3,76 @@
module
QA
module
QA
module
CE
module
CE
module
Strategy
module
Strategy
extend
self
class
<<
self
# Perform global setup
# Perform global setup
#
#
# @return [Boolean] returns true if hooks were performed successfully
# @return [Boolean] returns true if hooks were performed successfully
def
perform_before_hooks
def
perform_before_hooks
cache_tokens!
if
QA
::
Runtime
::
Env
.
admin_personal_access_token
.
present?
log_browser_versions
QA
::
Resource
::
PersonalAccessTokenCache
.
set_token_for_username
(
QA
::
Runtime
::
User
.
admin_username
,
if
Runtime
::
Env
.
rspec_retried?
QA
::
Runtime
::
Env
.
admin_personal_access_token
Runtime
::
Logger
.
info
(
'Skipping global hooks due to retry process'
)
)
return
false
end
QA
::
Support
::
Retrier
.
retry_on_exception
do
QA
::
Runtime
::
Browser
.
visit
(
:gitlab
,
QA
::
Page
::
Main
::
Login
)
end
# Reset admin password if admin token is present but can't be used due to expired password
reset_admin_password!
if
Runtime
::
Env
.
allow_local_requests?
Runtime
::
ApplicationSettings
.
set_application_settings
(
allow_local_requests_from_web_hooks_and_services:
true
)
end
true
end
end
if
QA
::
Runtime
::
Env
.
personal_access_token
.
present?
&&
QA
::
Runtime
::
Env
.
user_username
.
present?
private
QA
::
Resource
::
PersonalAccessTokenCache
.
set_token_for_username
(
QA
::
Runtime
::
Env
.
user_username
,
def
cache_tokens!
QA
::
Runtime
::
Env
.
personal_access_token
if
Runtime
::
Env
.
admin_personal_access_token
.
present?
Resource
::
PersonalAccessTokenCache
.
set_token_for_username
(
Runtime
::
User
.
admin_username
,
Runtime
::
Env
.
admin_personal_access_token
)
end
return
unless
Runtime
::
Env
.
personal_access_token
.
present?
&&
Runtime
::
Env
.
user_username
.
present?
Resource
::
PersonalAccessTokenCache
.
set_token_for_username
(
Runtime
::
Env
.
user_username
,
Runtime
::
Env
.
personal_access_token
)
)
end
end
QA
::
Runtime
::
Logger
.
info
(
"Using Browser:
#{
QA
::
Runtime
::
Env
.
browser
}
"
)
def
log_browser_versions
Runtime
::
Logger
.
info
(
"Using Browser:
#{
Runtime
::
Env
.
browser
}
"
)
return
unless
Runtime
::
Env
.
use_selenoid?
if
QA
::
Runtime
::
Env
.
use_selenoid?
Runtime
::
Logger
.
info
(
"Using Selenoid Browser version:
#{
Runtime
::
Env
.
selenoid_browser_version
}
"
)
QA
::
Runtime
::
Logger
.
info
(
"Using Selenoid Browser version:
#{
QA
::
Runtime
::
Env
.
selenoid_browser_version
}
"
)
end
end
if
Runtime
::
Env
.
rspec_retried?
def
reset_admin_password!
Runtime
::
Logger
.
info
(
'Skipping global hooks due to retry process'
)
return
unless
Runtime
::
Env
.
admin_personal_access_token
.
present?
return
false
end
# The login page could take some time to load the first time it is visited.
response
=
Support
::
API
.
get
(
Runtime
::
API
::
Request
.
new
(
Runtime
::
API
::
Client
.
as_admin
,
"/user"
).
url
)
# We visit the login page and wait for it to properly load only once before the tests.
return
unless
response
.
code
==
403
&&
response
.
body
.
include?
(
"Your password expired"
)
QA
::
Runtime
::
Logger
.
info
(
"Performing sanity check for environment!"
)
QA
::
Support
::
Retrier
.
retry_on_exception
do
QA
::
Runtime
::
Browser
.
visit
(
:gitlab
,
QA
::
Page
::
Main
::
Login
)
end
if
QA
::
Runtime
::
Env
.
allow_local_requests?
# Mostly issue with gdk where default seeded password for admin user will be expired
Runtime
::
ApplicationSettings
.
set_application_settings
(
allow_local_requests_from_web_hooks_and_services:
true
)
Runtime
::
Logger
.
warn
(
end
"Admin password must be reset before the configured access token can be used. Setting password now..."
)
true
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_admin_credentials
)
Page
::
Main
::
Login
.
perform
(
&
:set_up_new_admin_password_if_required
)
Page
::
Main
::
Menu
.
perform
(
&
:sign_out_if_signed_in
)
end
end
end
end
end
end
end
...
...
此差异已折叠。
点击以展开。
qa/qa/ee/resource/license.rb
+
3
−
12
浏览文件 @
bba43d5b
...
@@ -40,6 +40,7 @@ def initialize
...
@@ -40,6 +40,7 @@ def initialize
end
end
def
fabricate!
def
fabricate!
QA
::
Page
::
Main
::
Menu
.
perform
(
&
:sign_out_if_signed_in
)
QA
::
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_admin_credentials
)
QA
::
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_admin_credentials
)
QA
::
Page
::
Main
::
Menu
.
perform
(
&
:go_to_admin_area
)
QA
::
Page
::
Main
::
Menu
.
perform
(
&
:go_to_admin_area
)
QA
::
Page
::
Main
::
Login
.
perform
(
&
:set_up_new_admin_password_if_required
)
QA
::
Page
::
Main
::
Login
.
perform
(
&
:set_up_new_admin_password_if_required
)
...
@@ -83,18 +84,8 @@ def fabricate_via_api!
...
@@ -83,18 +84,8 @@ def fabricate_via_api!
api_post
.
tap
{
QA
::
Runtime
::
Logger
.
info
(
"Successfully added license key. Details:
\n
#{
license_info
}
"
)
}
api_post
.
tap
{
QA
::
Runtime
::
Logger
.
info
(
"Successfully added license key. Details:
\n
#{
license_info
}
"
)
}
rescue
RuntimeError
=>
e
rescue
RuntimeError
=>
e
unless
e
.
message
.
include?
(
'Your password expired'
)
QA
::
Runtime
::
Logger
.
error
(
"Following license fabrication failed:
#{
base_license_info
}
"
)
QA
::
Runtime
::
Logger
.
error
(
"Following license fabrication failed:
#{
base_license_info
}
"
)
raise
(
e
)
raise
(
e
)
end
QA
::
Runtime
::
Logger
.
warn
(
'Admin password must be reset before the default access token can be used. '
\
'Setting password now...'
)
QA
::
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_admin_credentials
)
QA
::
Page
::
Main
::
Login
.
perform
(
&
:set_up_new_admin_password_if_required
)
retry
end
end
end
end
...
...
此差异已折叠。
点击以展开。
qa/qa/ee/strategy.rb
+
7
−
10
浏览文件 @
bba43d5b
...
@@ -12,23 +12,20 @@ def perform_before_hooks
...
@@ -12,23 +12,20 @@ def perform_before_hooks
if
QA
::
Runtime
::
Env
.
ee_license
.
present?
if
QA
::
Runtime
::
Env
.
ee_license
.
present?
QA
::
Runtime
::
Logger
.
info
(
"Performing initial license fabrication!"
)
QA
::
Runtime
::
Logger
.
info
(
"Performing initial license fabrication!"
)
QA
::
Page
::
Main
::
Menu
.
perform
(
&
:sign_out_if_signed_in
)
EE
::
Resource
::
License
.
fabricate!
do
|
resource
|
EE
::
Resource
::
License
.
fabricate!
do
|
resource
|
resource
.
license
=
QA
::
Runtime
::
Env
.
ee_license
resource
.
license
=
QA
::
Runtime
::
Env
.
ee_license
end
end
end
end
unless
QA
::
Runtime
::
Env
.
running_on_dot_com?
return
if
QA
::
Runtime
::
Env
.
running_on_dot_com?
QA
::
Runtime
::
Logger
.
info
(
"Disabling sync with External package metadata database"
)
# we can't pass [] here, otherwise it causes a validation error, because the value we pass
# must be a valid purl_type. Instead, we pass the `deb` purl_type which is only used for
# container scanning advisories, which are not yet supported/ingested, so this is effectively
# the same thing as disabling the sync.
QA
::
Runtime
::
ApplicationSettings
.
set_application_settings
(
package_metadata_purl_types:
[
DEB_PURL_TYPE
])
end
QA
::
Page
::
Main
::
Menu
.
perform
(
&
:sign_out_if_signed_in
)
QA
::
Runtime
::
Logger
.
info
(
"Disabling sync with External package metadata database"
)
# we can't pass [] here, otherwise it causes a validation error, because the value we pass
# must be a valid purl_type. Instead, we pass the `deb` purl_type which is only used for
# container scanning advisories, which are not yet supported/ingested, so this is effectively
# the same thing as disabling the sync.
QA
::
Runtime
::
ApplicationSettings
.
set_application_settings
(
package_metadata_purl_types:
[
DEB_PURL_TYPE
])
end
end
end
end
end
end
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录