Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c6b2ff8a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c6b2ff8a
编写于
2月 09, 2018
作者:
E
Eric Eastwood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hide CI secret variable values on save
See
https://gitlab.com/gitlab-org/gitlab-ce/issues/42928
上级
dbb934c8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
82 addition
and
15 deletion
+82
-15
app/assets/javascripts/ci_variable_list/ajax_variable_list.js
...assets/javascripts/ci_variable_list/ajax_variable_list.js
+1
-0
app/assets/javascripts/ci_variable_list/ci_variable_list.js
app/assets/javascripts/ci_variable_list/ci_variable_list.js
+4
-0
changelogs/unreleased/42929-hide-new-variable-values.yml
changelogs/unreleased/42929-hide-new-variable-values.yml
+5
-0
spec/javascripts/ci_variable_list/ajax_variable_list_spec.js
spec/javascripts/ci_variable_list/ajax_variable_list_spec.js
+35
-11
spec/javascripts/ci_variable_list/ci_variable_list_spec.js
spec/javascripts/ci_variable_list/ci_variable_list_spec.js
+37
-4
未找到文件。
app/assets/javascripts/ci_variable_list/ajax_variable_list.js
浏览文件 @
c6b2ff8a
...
...
@@ -75,6 +75,7 @@ export default class AjaxVariableList {
if
(
res
.
status
===
statusCodes
.
OK
&&
res
.
data
)
{
this
.
updateRowsWithPersistedVariables
(
res
.
data
.
variables
);
this
.
variableList
.
hideValues
();
}
else
if
(
res
.
status
===
statusCodes
.
BAD_REQUEST
)
{
// Validation failed
this
.
errorBox
.
innerHTML
=
generateErrorBoxContent
(
res
.
data
);
...
...
app/assets/javascripts/ci_variable_list/ci_variable_list.js
浏览文件 @
c6b2ff8a
...
...
@@ -178,6 +178,10 @@ export default class VariableList {
this
.
$container
.
find
(
'
.js-row-remove-button
'
).
attr
(
'
disabled
'
,
!
isEnabled
);
}
hideValues
()
{
this
.
secretValues
.
updateDom
(
false
);
}
getAllData
()
{
// Ignore the last empty row because we don't want to try persist
// a blank variable and run into validation problems.
...
...
changelogs/unreleased/42929-hide-new-variable-values.yml
0 → 100644
浏览文件 @
c6b2ff8a
---
title
:
Hide CI secret variable values after saving
merge_request
:
17044
author
:
type
:
changed
spec/javascripts/ci_variable_list/ajax_variable_list_spec.js
浏览文件 @
c6b2ff8a
import
$
from
'
jquery
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
AjaxFormVariableList
from
'
~/ci_variable_list/ajax_variable_list
'
;
const
VARIABLE_PATCH_ENDPOINT
=
'
http://test.host/frontend-fixtures/builds-project/variables
'
;
const
HIDE_CLASS
=
'
hide
'
;
describe
(
'
AjaxFormVariableList
'
,
()
=>
{
preloadFixtures
(
'
projects/ci_cd_settings.html.raw
'
);
...
...
@@ -45,16 +47,16 @@ describe('AjaxFormVariableList', () => {
const
loadingIcon
=
saveButton
.
querySelector
(
'
.js-secret-variables-save-loading-icon
'
);
mock
.
onPatch
(
VARIABLE_PATCH_ENDPOINT
).
reply
(()
=>
{
expect
(
loadingIcon
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
false
);
expect
(
loadingIcon
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
false
);
return
[
200
,
{}];
});
expect
(
loadingIcon
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
loadingIcon
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
ajaxVariableList
.
onSaveClicked
()
.
then
(()
=>
{
expect
(
loadingIcon
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
loadingIcon
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -78,11 +80,11 @@ describe('AjaxFormVariableList', () => {
it
(
'
hides any previous error box
'
,
(
done
)
=>
{
mock
.
onPatch
(
VARIABLE_PATCH_ENDPOINT
).
reply
(
200
);
expect
(
errorBox
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
errorBox
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
ajaxVariableList
.
onSaveClicked
()
.
then
(()
=>
{
expect
(
errorBox
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
errorBox
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -103,17 +105,39 @@ describe('AjaxFormVariableList', () => {
.
catch
(
done
.
fail
);
});
it
(
'
hides secret values
'
,
(
done
)
=>
{
mock
.
onPatch
(
VARIABLE_PATCH_ENDPOINT
).
reply
(
200
,
{});
const
row
=
container
.
querySelector
(
'
.js-row:first-child
'
);
const
valueInput
=
row
.
querySelector
(
'
.js-ci-variable-input-value
'
);
const
valuePlaceholder
=
row
.
querySelector
(
'
.js-secret-value-placeholder
'
);
valueInput
.
value
=
'
bar
'
;
$
(
valueInput
).
trigger
(
'
input
'
);
expect
(
valuePlaceholder
.
classList
.
contains
(
HIDE_CLASS
)).
toBe
(
true
);
expect
(
valueInput
.
classList
.
contains
(
HIDE_CLASS
)).
toBe
(
false
);
ajaxVariableList
.
onSaveClicked
()
.
then
(()
=>
{
expect
(
valuePlaceholder
.
classList
.
contains
(
HIDE_CLASS
)).
toBe
(
false
);
expect
(
valueInput
.
classList
.
contains
(
HIDE_CLASS
)).
toBe
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
shows error box with validation errors
'
,
(
done
)
=>
{
const
validationError
=
'
some validation error
'
;
mock
.
onPatch
(
VARIABLE_PATCH_ENDPOINT
).
reply
(
400
,
[
validationError
,
]);
expect
(
errorBox
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
errorBox
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
ajaxVariableList
.
onSaveClicked
()
.
then
(()
=>
{
expect
(
errorBox
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
false
);
expect
(
errorBox
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
false
);
expect
(
errorBox
.
textContent
.
trim
().
replace
(
/
\n
+
\s
+/m
,
'
'
)).
toEqual
(
`Validation failed
${
validationError
}
`
);
})
.
then
(
done
)
...
...
@@ -123,11 +147,11 @@ describe('AjaxFormVariableList', () => {
it
(
'
shows flash message when request fails
'
,
(
done
)
=>
{
mock
.
onPatch
(
VARIABLE_PATCH_ENDPOINT
).
reply
(
500
);
expect
(
errorBox
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
errorBox
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
ajaxVariableList
.
onSaveClicked
()
.
then
(()
=>
{
expect
(
errorBox
.
classList
.
contains
(
'
hide
'
)).
toEqual
(
true
);
expect
(
errorBox
.
classList
.
contains
(
HIDE_CLASS
)).
toEqual
(
true
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -170,9 +194,9 @@ describe('AjaxFormVariableList', () => {
const
valueInput
=
row
.
querySelector
(
'
.js-ci-variable-input-value
'
);
keyInput
.
value
=
'
foo
'
;
keyInput
.
dispatchEvent
(
new
Event
(
'
input
'
)
);
$
(
keyInput
).
trigger
(
'
input
'
);
valueInput
.
value
=
'
bar
'
;
valueInput
.
dispatchEvent
(
new
Event
(
'
input
'
)
);
$
(
valueInput
).
trigger
(
'
input
'
);
expect
(
idInput
.
value
).
toEqual
(
''
);
...
...
spec/javascripts/ci_variable_list/ci_variable_list_spec.js
浏览文件 @
c6b2ff8a
import
VariableList
from
'
~/ci_variable_list/ci_variable_list
'
;
import
getSetTimeoutPromise
from
'
../helpers/set_timeout_promise_helper
'
;
const
HIDE_CLASS
=
'
hide
'
;
describe
(
'
VariableList
'
,
()
=>
{
preloadFixtures
(
'
pipeline_schedules/edit.html.raw
'
);
preloadFixtures
(
'
pipeline_schedules/edit_with_variables.html.raw
'
);
...
...
@@ -92,14 +94,14 @@ describe('VariableList', () => {
const
$inputValue
=
$row
.
find
(
'
.js-ci-variable-input-value
'
);
const
$placeholder
=
$row
.
find
(
'
.js-secret-value-placeholder
'
);
expect
(
$placeholder
.
hasClass
(
'
hide
'
)).
toBe
(
false
);
expect
(
$inputValue
.
hasClass
(
'
hide
'
)).
toBe
(
true
);
expect
(
$placeholder
.
hasClass
(
HIDE_CLASS
)).
toBe
(
false
);
expect
(
$inputValue
.
hasClass
(
HIDE_CLASS
)).
toBe
(
true
);
// Reveal values
$wrapper
.
find
(
'
.js-secret-value-reveal-button
'
).
click
();
expect
(
$placeholder
.
hasClass
(
'
hide
'
)).
toBe
(
true
);
expect
(
$inputValue
.
hasClass
(
'
hide
'
)).
toBe
(
false
);
expect
(
$placeholder
.
hasClass
(
HIDE_CLASS
)).
toBe
(
true
);
expect
(
$inputValue
.
hasClass
(
HIDE_CLASS
)).
toBe
(
false
);
});
});
});
...
...
@@ -179,4 +181,35 @@ describe('VariableList', () => {
expect
(
$wrapper
.
find
(
'
.js-ci-variable-input-key:not([disabled])
'
).
length
).
toBe
(
3
);
});
});
describe
(
'
hideValues
'
,
()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
'
projects/ci_cd_settings.html.raw
'
);
$wrapper
=
$
(
'
.js-ci-variable-list-section
'
);
variableList
=
new
VariableList
({
container
:
$wrapper
,
formField
:
'
variables
'
,
});
variableList
.
init
();
});
it
(
'
should hide value input and show placeholder stars
'
,
()
=>
{
const
$row
=
$wrapper
.
find
(
'
.js-row
'
);
const
$inputValue
=
$row
.
find
(
'
.js-ci-variable-input-value
'
);
const
$placeholder
=
$row
.
find
(
'
.js-secret-value-placeholder
'
);
$row
.
find
(
'
.js-ci-variable-input-value
'
)
.
val
(
'
foo
'
)
.
trigger
(
'
input
'
);
expect
(
$placeholder
.
hasClass
(
HIDE_CLASS
)).
toBe
(
true
);
expect
(
$inputValue
.
hasClass
(
HIDE_CLASS
)).
toBe
(
false
);
variableList
.
hideValues
();
expect
(
$placeholder
.
hasClass
(
HIDE_CLASS
)).
toBe
(
false
);
expect
(
$inputValue
.
hasClass
(
HIDE_CLASS
)).
toBe
(
true
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录