Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
28a5f8c6
Commit
28a5f8c6
authored
Mar 16, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use secret_key and secret_value in Variables controller
parent
79aa0032
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
12 deletions
+22
-12
app/controllers/groups/variables_controller.rb
app/controllers/groups/variables_controller.rb
+7
-2
app/controllers/projects/variables_controller.rb
app/controllers/projects/variables_controller.rb
+7
-2
spec/support/shared_examples/controllers/variables_shared_examples.rb
.../shared_examples/controllers/variables_shared_examples.rb
+8
-8
No files found.
app/controllers/groups/variables_controller.rb
View file @
28a5f8c6
...
...
@@ -35,11 +35,16 @@ module Groups
end
def
group_variables_params
params
.
permit
(
variables_attributes:
[
*
variable_params_attributes
])
filtered_params
=
params
.
permit
(
variables_attributes:
[
*
variable_params_attributes
])
filtered_params
[
"variables_attributes"
].
each
do
|
variable
|
variable
[
"key"
]
=
variable
.
delete
(
"secret_key"
)
variable
[
"value"
]
=
variable
.
delete
(
"secret_value"
)
end
filtered_params
end
def
variable_params_attributes
%i[id
key
value protected _destroy]
%i[id
secret_key secret_
value protected _destroy]
end
def
authorize_admin_build!
...
...
app/controllers/projects/variables_controller.rb
View file @
28a5f8c6
...
...
@@ -32,10 +32,15 @@ class Projects::VariablesController < Projects::ApplicationController
end
def
variables_params
params
.
permit
(
variables_attributes:
[
*
variable_params_attributes
])
filtered_params
=
params
.
permit
(
variables_attributes:
[
*
variable_params_attributes
])
filtered_params
[
"variables_attributes"
].
each
do
|
variable
|
variable
[
"key"
]
=
variable
.
delete
(
"secret_key"
)
variable
[
"value"
]
=
variable
.
delete
(
"secret_value"
)
end
filtered_params
end
def
variable_params_attributes
%i[id
key
value protected _destroy]
%i[id
secret_key secret_
value protected _destroy]
end
end
spec/support/shared_examples/controllers/variables_shared_examples.rb
View file @
28a5f8c6
...
...
@@ -15,21 +15,21 @@ end
shared_examples
'PATCH #update updates variables'
do
let
(
:variable_attributes
)
do
{
id:
variable
.
id
,
key:
variable
.
key
,
value:
variable
.
value
,
secret_
key:
variable
.
key
,
secret_
value:
variable
.
value
,
protected:
variable
.
protected?
.
to_s
}
end
let
(
:new_variable_attributes
)
do
{
key:
'new_key'
,
value:
'dummy_value'
,
{
secret_
key:
'new_key'
,
secret_
value:
'dummy_value'
,
protected:
'false'
}
end
context
'with invalid new variable parameters'
do
let
(
:variables_attributes
)
do
[
variable_attributes
.
merge
(
value:
'other_value'
),
new_variable_attributes
.
merge
(
key:
'...?'
)
variable_attributes
.
merge
(
secret_
value:
'other_value'
),
new_variable_attributes
.
merge
(
secret_
key:
'...?'
)
]
end
...
...
@@ -52,7 +52,7 @@ shared_examples 'PATCH #update updates variables' do
let
(
:variables_attributes
)
do
[
new_variable_attributes
,
new_variable_attributes
.
merge
(
value:
'other_value'
)
new_variable_attributes
.
merge
(
secret_
value:
'other_value'
)
]
end
...
...
@@ -74,7 +74,7 @@ shared_examples 'PATCH #update updates variables' do
context
'with valid new variable parameters'
do
let
(
:variables_attributes
)
do
[
variable_attributes
.
merge
(
value:
'other_value'
),
variable_attributes
.
merge
(
secret_
value:
'other_value'
),
new_variable_attributes
]
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment