Skip to content

Commit 1f2a189

Browse files
varshavaradarajanzabil
authored andcommitted
Do not display the value of secure environment variable in templates view. (#2647) (#2652)
1 parent 197480d commit 1f2a189

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

server/webapp/WEB-INF/rails.new/app/views/config_view/templates/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<%= environment_variable.getName() %>
8585
</td>
8686
<td class="name_value_cell">
87-
<%= environment_variable.getValue() %>
87+
<%= environment_variable.getDisplayValue() %>
8888
</td>
8989
</tr>
9090
<% end %>

server/webapp/WEB-INF/rails.new/spec/views/config_view/templates/show_html_spec.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##########################GO-LICENSE-START################################
2-
# Copyright 2014 ThoughtWorks, Inc.
2+
# Copyright 2016 ThoughtWorks, Inc.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -134,6 +134,34 @@
134134
end
135135
end
136136

137+
it 'should mask the value of secure environment variable for a stage' do
138+
stage = StageConfigMother.stage_config("stage1")
139+
environment_variable_config_new = EnvironmentVariableConfig.new("env2", "value2")
140+
environment_variable_config_new.setIsSecure(true)
141+
stage.setVariables(EnvironmentVariablesConfig.new([EnvironmentVariableConfig.new("env1", "value1"), environment_variable_config_new]))
142+
template = PipelineTemplateConfigMother.create_template("t1", [stage].to_java(StageConfig))
143+
assign(:template_config, template)
144+
render
145+
Capybara.string(response.body).find("#definition_view_stage_1").tap do |stage|
146+
stage.find(".tab-content #environment_variables_stage_1.tab-pane.active table.variables").tap do |table|
147+
table.find("thead").tap do |head|
148+
head.find("tr").tap do |row|
149+
expect(row).to have_selector("th", :text => "Name")
150+
expect(row).to have_selector("th", :text => "Value")
151+
end
152+
end
153+
table.find("tbody").tap do |body|
154+
body.all("tr").tap do |rows|
155+
expect(rows[0]).to have_selector("td.name_value_cell", :text => "env1")
156+
expect(rows[0]).to have_selector("td.name_value_cell", :text => "value1")
157+
expect(rows[1]).to have_selector("td.name_value_cell", :text => "env2")
158+
expect(rows[1]).to have_selector("td.name_value_cell", :text => "****")
159+
end
160+
end
161+
end
162+
end
163+
end
164+
137165
it "should not show environment variables table if none are configured" do
138166
template = PipelineTemplateConfigMother.create_template("t1")
139167
assign(:template_config, template)

0 commit comments

Comments
 (0)