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
Boxiang Sun
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
Show 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
...
@@ -35,11 +35,16 @@ module Groups
end
end
def
group_variables_params
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
end
def
variable_params_attributes
def
variable_params_attributes
%i[id
key
value protected _destroy]
%i[id
secret_key secret_
value protected _destroy]
end
end
def
authorize_admin_build!
def
authorize_admin_build!
...
...
app/controllers/projects/variables_controller.rb
View file @
28a5f8c6
...
@@ -32,10 +32,15 @@ class Projects::VariablesController < Projects::ApplicationController
...
@@ -32,10 +32,15 @@ class Projects::VariablesController < Projects::ApplicationController
end
end
def
variables_params
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
end
def
variable_params_attributes
def
variable_params_attributes
%i[id
key
value protected _destroy]
%i[id
secret_key secret_
value protected _destroy]
end
end
end
end
spec/support/shared_examples/controllers/variables_shared_examples.rb
View file @
28a5f8c6
...
@@ -15,21 +15,21 @@ end
...
@@ -15,21 +15,21 @@ end
shared_examples
'PATCH #update updates variables'
do
shared_examples
'PATCH #update updates variables'
do
let
(
:variable_attributes
)
do
let
(
:variable_attributes
)
do
{
id:
variable
.
id
,
{
id:
variable
.
id
,
key:
variable
.
key
,
secret_
key:
variable
.
key
,
value:
variable
.
value
,
secret_
value:
variable
.
value
,
protected:
variable
.
protected?
.
to_s
}
protected:
variable
.
protected?
.
to_s
}
end
end
let
(
:new_variable_attributes
)
do
let
(
:new_variable_attributes
)
do
{
key:
'new_key'
,
{
secret_
key:
'new_key'
,
value:
'dummy_value'
,
secret_
value:
'dummy_value'
,
protected:
'false'
}
protected:
'false'
}
end
end
context
'with invalid new variable parameters'
do
context
'with invalid new variable parameters'
do
let
(
:variables_attributes
)
do
let
(
:variables_attributes
)
do
[
[
variable_attributes
.
merge
(
value:
'other_value'
),
variable_attributes
.
merge
(
secret_
value:
'other_value'
),
new_variable_attributes
.
merge
(
key:
'...?'
)
new_variable_attributes
.
merge
(
secret_
key:
'...?'
)
]
]
end
end
...
@@ -52,7 +52,7 @@ shared_examples 'PATCH #update updates variables' do
...
@@ -52,7 +52,7 @@ shared_examples 'PATCH #update updates variables' do
let
(
:variables_attributes
)
do
let
(
:variables_attributes
)
do
[
[
new_variable_attributes
,
new_variable_attributes
,
new_variable_attributes
.
merge
(
value:
'other_value'
)
new_variable_attributes
.
merge
(
secret_
value:
'other_value'
)
]
]
end
end
...
@@ -74,7 +74,7 @@ shared_examples 'PATCH #update updates variables' do
...
@@ -74,7 +74,7 @@ shared_examples 'PATCH #update updates variables' do
context
'with valid new variable parameters'
do
context
'with valid new variable parameters'
do
let
(
:variables_attributes
)
do
let
(
:variables_attributes
)
do
[
[
variable_attributes
.
merge
(
value:
'other_value'
),
variable_attributes
.
merge
(
secret_
value:
'other_value'
),
new_variable_attributes
new_variable_attributes
]
]
end
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