Make Variable key not secret

This commit is contained in:
Matija Čupić 2018-03-22 12:08:16 +01:00
parent ca3b2991a5
commit 05103f080c
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE
12 changed files with 21 additions and 24 deletions

View file

@ -29,7 +29,7 @@ export default class VariableList {
selector: '.js-ci-variable-input-id',
default: '',
},
secret_key: {
key: {
selector: '.js-ci-variable-input-key',
default: '',
},
@ -174,7 +174,7 @@ export default class VariableList {
}
toggleEnableRow(isEnabled = true) {
this.$container.find(this.inputMap.secret_key.selector).attr('disabled', !isEnabled);
this.$container.find(this.inputMap.key.selector).attr('disabled', !isEnabled);
this.$container.find('.js-row-remove-button').attr('disabled', !isEnabled);
}

View file

@ -39,7 +39,7 @@ module Groups
end
def variable_params_attributes
%i[id secret_key secret_value protected _destroy]
%i[id key secret_value protected _destroy]
end
def authorize_admin_build!

View file

@ -92,7 +92,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
def schedule_params
params.require(:schedule)
.permit(:description, :cron, :cron_timezone, :ref, :active,
variables_attributes: [:id, :secret_key, :secret_value, :_destroy] )
variables_attributes: [:id, :key, :secret_value, :_destroy] )
end
def authorize_play_pipeline_schedule!

View file

@ -36,6 +36,6 @@ class Projects::VariablesController < Projects::ApplicationController
end
def variable_params_attributes
%i[id secret_key secret_value protected _destroy]
%i[id key secret_value protected _destroy]
end
end

View file

@ -6,7 +6,6 @@ module Ci
belongs_to :group
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: {

View file

@ -5,7 +5,6 @@ module Ci
belongs_to :pipeline_schedule
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: { scope: :pipeline_schedule_id }

View file

@ -6,7 +6,6 @@ module Ci
belongs_to :project
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: {

View file

@ -9,7 +9,7 @@
- id_input_name = "#{form_field}[variables_attributes][][id]"
- destroy_input_name = "#{form_field}[variables_attributes][][_destroy]"
- key_input_name = "#{form_field}[variables_attributes][][secret_key]"
- key_input_name = "#{form_field}[variables_attributes][][key]"
- value_input_name = "#{form_field}[variables_attributes][][secret_value]"
- protected_input_name = "#{form_field}[variables_attributes][][protected]"

View file

@ -80,7 +80,7 @@ describe Projects::PipelineSchedulesController do
context 'when variables_attributes has one variable' do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ secret_key: 'AAA', secret_value: 'AAA123' }]
variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' }]
})
end
@ -101,8 +101,8 @@ describe Projects::PipelineSchedulesController do
context 'when variables_attributes has two variables and duplicated' do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ secret_key: 'AAA', secret_value: 'AAA123' },
{ secret_key: 'AAA', secret_value: 'BBB123' }]
variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' },
{ key: 'AAA', secret_value: 'BBB123' }]
})
end
@ -153,7 +153,7 @@ describe Projects::PipelineSchedulesController do
context 'when params include one variable' do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ secret_key: 'AAA', secret_value: 'AAA123' }]
variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' }]
})
end
@ -170,8 +170,8 @@ describe Projects::PipelineSchedulesController do
context 'when params include two duplicated variables' do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ secret_key: 'AAA', secret_value: 'AAA123' },
{ secret_key: 'AAA', secret_value: 'BBB123' }]
variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' },
{ key: 'AAA', secret_value: 'BBB123' }]
})
end
@ -196,7 +196,7 @@ describe Projects::PipelineSchedulesController do
context 'when adds a new variable' do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ secret_key: 'AAA', secret_value: 'AAA123' }]
variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' }]
})
end
@ -211,7 +211,7 @@ describe Projects::PipelineSchedulesController do
context 'when adds a new duplicated variable' do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ secret_key: 'CCC', secret_value: 'AAA123' }]
variables_attributes: [{ key: 'CCC', secret_value: 'AAA123' }]
})
end
@ -254,7 +254,7 @@ describe Projects::PipelineSchedulesController do
let(:schedule) do
basic_param.merge({
variables_attributes: [{ id: pipeline_schedule_variable.id, _destroy: true },
{ secret_key: 'CCC', secret_value: 'CCC123' }]
{ key: 'CCC', secret_value: 'CCC123' }]
})
end

View file

@ -159,9 +159,9 @@ feature 'Pipeline Schedules', :js do
visit_pipelines_schedules
click_link 'New schedule'
fill_in_schedule_form
all('[name="schedule[variables_attributes][][secret_key]"]')[0].set('AAA')
all('[name="schedule[variables_attributes][][key]"]')[0].set('AAA')
all('[name="schedule[variables_attributes][][secret_value]"]')[0].set('AAA123')
all('[name="schedule[variables_attributes][][secret_key]"]')[1].set('BBB')
all('[name="schedule[variables_attributes][][key]"]')[1].set('BBB')
all('[name="schedule[variables_attributes][][secret_value]"]')[1].set('BBB123')
save_pipeline_schedule
end

View file

@ -19,7 +19,7 @@ describe('NativeFormVariableList', () => {
describe('onFormSubmit', () => {
it('should clear out the `name` attribute on the inputs for the last empty row on form submission (avoid BE validation)', () => {
const $row = $wrapper.find('.js-row');
expect($row.find('.js-ci-variable-input-key').attr('name')).toBe('schedule[variables_attributes][][secret_key]');
expect($row.find('.js-ci-variable-input-key').attr('name')).toBe('schedule[variables_attributes][][key]');
expect($row.find('.js-ci-variable-input-value').attr('name')).toBe('schedule[variables_attributes][][secret_value]');
$wrapper.closest('form').trigger('trigger-submit');

View file

@ -15,12 +15,12 @@ end
shared_examples 'PATCH #update updates variables' do
let(:variable_attributes) do
{ id: variable.id,
secret_key: variable.key,
key: variable.key,
secret_value: variable.value,
protected: variable.protected?.to_s }
end
let(:new_variable_attributes) do
{ secret_key: 'new_key',
{ key: 'new_key',
secret_value: 'dummy_value',
protected: 'false' }
end
@ -29,7 +29,7 @@ shared_examples 'PATCH #update updates variables' do
let(:variables_attributes) do
[
variable_attributes.merge(secret_value: 'other_value'),
new_variable_attributes.merge(secret_key: '...?')
new_variable_attributes.merge(key: '...?')
]
end