Commit d6e1a86b authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'explicit_masked_qa' into 'master'

Be explicit about setting :masked

See merge request gitlab-org/gitlab-ce!28759
parents e680e6f5 33132427
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
.append-right-default .append-right-default
= s_("CiVariable|Masked") = s_("CiVariable|Masked")
%button{ type: 'button', %button{ type: 'button',
class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if is_masked}", class: "js-project-feature-toggle project-feature-toggle qa-variable-masked #{'is-checked' if is_masked}",
"aria-label": s_("CiVariable|Toggle masked") } "aria-label": s_("CiVariable|Toggle masked") }
%input{ type: "hidden", %input{ type: "hidden",
class: 'js-ci-variable-input-masked js-project-feature-toggle-input', class: 'js-ci-variable-input-masked js-project-feature-toggle-input',
......
...@@ -11,6 +11,7 @@ module QA ...@@ -11,6 +11,7 @@ module QA
element :variable_row, '.ci-variable-row-body' # rubocop:disable QA/ElementWithPattern element :variable_row, '.ci-variable-row-body' # rubocop:disable QA/ElementWithPattern
element :variable_key, '.qa-ci-variable-input-key' # rubocop:disable QA/ElementWithPattern element :variable_key, '.qa-ci-variable-input-key' # rubocop:disable QA/ElementWithPattern
element :variable_value, '.qa-ci-variable-input-value' # rubocop:disable QA/ElementWithPattern element :variable_value, '.qa-ci-variable-input-value' # rubocop:disable QA/ElementWithPattern
element :variable_masked
end end
view 'app/views/ci/variables/_index.html.haml' do view 'app/views/ci/variables/_index.html.haml' do
...@@ -18,7 +19,7 @@ module QA ...@@ -18,7 +19,7 @@ module QA
element :reveal_values, '.js-secret-value-reveal-button' # rubocop:disable QA/ElementWithPattern element :reveal_values, '.js-secret-value-reveal-button' # rubocop:disable QA/ElementWithPattern
end end
def fill_variable(key, value) def fill_variable(key, value, masked)
keys = all_elements(:ci_variable_input_key) keys = all_elements(:ci_variable_input_key)
index = keys.size - 1 index = keys.size - 1
...@@ -32,6 +33,9 @@ module QA ...@@ -32,6 +33,9 @@ module QA
# The code was inspired from: # The code was inspired from:
# https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217 # https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217
execute_script("arguments[0].value = #{value.to_json}", node) execute_script("arguments[0].value = #{value.to_json}", node)
masked_node = all_elements(:variable_masked)[index]
toggle_masked(masked_node, masked)
end end
def save_variables def save_variables
...@@ -47,6 +51,24 @@ module QA ...@@ -47,6 +51,24 @@ module QA
find('.qa-ci-variable-input-value').value find('.qa-ci-variable-input-value').value
end end
end end
private
def toggle_masked(masked_node, masked)
wait(reload: false) do
masked_node.click
masked ? masked_enabled?(masked_node) : masked_disabled?(masked_node)
end
end
def masked_enabled?(masked_node)
masked_node[:class].include?('is-checked')
end
def masked_disabled?(masked_node)
!masked_enabled?(masked_node)
end
end end
end end
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module QA module QA
module Resource module Resource
class CiVariable < Base class CiVariable < Base
attr_accessor :key, :value attr_accessor :key, :value, :masked
attribute :project do attribute :project do
Project.fabricate! do |resource| Project.fabricate! do |resource|
...@@ -19,7 +19,7 @@ module QA ...@@ -19,7 +19,7 @@ module QA
Page::Project::Settings::CICD.perform do |setting| Page::Project::Settings::CICD.perform do |setting|
setting.expand_ci_variables do |page| setting.expand_ci_variables do |page|
page.fill_variable(key, value) page.fill_variable(key, value, masked)
page.save_variables page.save_variables
end end
...@@ -49,7 +49,8 @@ module QA ...@@ -49,7 +49,8 @@ module QA
def api_post_body def api_post_body
{ {
key: key, key: key,
value: value value: value,
masked: masked
} }
end end
end end
......
...@@ -16,6 +16,7 @@ module QA ...@@ -16,6 +16,7 @@ module QA
resource.project = project resource.project = project
resource.key = 'VARIABLE_KEY' resource.key = 'VARIABLE_KEY'
resource.value = 'some_CI_variable' resource.value = 'some_CI_variable'
resource.masked = false
end end
project.visit! project.visit!
......
...@@ -60,6 +60,7 @@ module QA ...@@ -60,6 +60,7 @@ module QA
resource.project = @project resource.project = @project
resource.key = deploy_key_name resource.key = deploy_key_name
resource.value = key.private_key resource.value = key.private_key
resource.masked = false
end end
gitlab_ci = <<~YAML gitlab_ci = <<~YAML
......
...@@ -34,6 +34,7 @@ module QA ...@@ -34,6 +34,7 @@ module QA
resource.project = @project resource.project = @project
resource.key = 'CODE_QUALITY_DISABLED' resource.key = 'CODE_QUALITY_DISABLED'
resource.value = '1' resource.value = '1'
resource.masked = false
end end
# Set an application secret CI variable (prefixed with K8S_SECRET_) # Set an application secret CI variable (prefixed with K8S_SECRET_)
...@@ -41,6 +42,7 @@ module QA ...@@ -41,6 +42,7 @@ module QA
resource.project = @project resource.project = @project
resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE' resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE'
resource.value = 'you_can_see_this_variable' resource.value = 'you_can_see_this_variable'
resource.masked = false
end end
# Connect K8s cluster # Connect K8s cluster
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment