summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-03-16 16:54:36 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-03-16 16:56:42 +0100
commit28a5f8c60a29445e147614767a8452b3141ef868 (patch)
tree72f8bda91908354d72d5267bf6e1b75dbd807b87
parent79aa00321063daf8f650683373db29832c8e13f1 (diff)
downloadgitlab-ce-28a5f8c60a29445e147614767a8452b3141ef868.tar.gz
Use secret_key and secret_value in Variables controller
-rw-r--r--app/controllers/groups/variables_controller.rb9
-rw-r--r--app/controllers/projects/variables_controller.rb9
-rw-r--r--spec/support/shared_examples/controllers/variables_shared_examples.rb16
3 files changed, 22 insertions, 12 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb
index cb8771bc97e..2794d5fe6ec 100644
--- a/app/controllers/groups/variables_controller.rb
+++ b/app/controllers/groups/variables_controller.rb
@@ -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!
diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb
index 7eb509e2e64..3cbfe7b3cc1 100644
--- a/app/controllers/projects/variables_controller.rb
+++ b/app/controllers/projects/variables_controller.rb
@@ -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
diff --git a/spec/support/shared_examples/controllers/variables_shared_examples.rb b/spec/support/shared_examples/controllers/variables_shared_examples.rb
index d7acf8c0032..7c7e345f715 100644
--- a/spec/support/shared_examples/controllers/variables_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/variables_shared_examples.rb
@@ -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