Commit 127807b7 authored by Marcel Amirault's avatar Marcel Amirault Committed by Thong Kuah

Renaming Secret Variables in the codebase (EE Port)

Cherry-picked from master to resolve automated CE-to-EE MR spec
failures.
parent e02d4830
...@@ -315,7 +315,7 @@ module EE ...@@ -315,7 +315,7 @@ module EE
end end
end end
def secret_variables_for(ref:, environment: nil) def ci_variables_for(ref:, environment: nil)
return super.where(environment_scope: '*') unless return super.where(environment_scope: '*') unless
environment && feature_available?(:variable_environment_scope) environment && feature_available?(:variable_environment_scope)
......
...@@ -18,7 +18,7 @@ describe Gitlab::Ci::Build::Policy::Variables do ...@@ -18,7 +18,7 @@ describe Gitlab::Ci::Build::Policy::Variables do
let(:seed) { double('build seed', to_resource: ci_build) } let(:seed) { double('build seed', to_resource: ci_build) }
describe '#satisfied_by?' do describe '#satisfied_by?' do
context 'when using project secret variables in environment scope' do context 'when using project ci variables in environment scope' do
before do before do
create(:ci_variable, project: project, create(:ci_variable, project: project,
key: 'SCOPED_VARIABLE', key: 'SCOPED_VARIABLE',
......
...@@ -894,10 +894,10 @@ describe Project do ...@@ -894,10 +894,10 @@ describe Project do
end end
end end
describe '#secret_variables_for' do describe '#ci_variables_for' do
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:secret_variable) do let!(:ci_variable) do
create(:ci_variable, value: 'secret', project: project) create(:ci_variable, value: 'secret', project: project)
end end
...@@ -905,7 +905,7 @@ describe Project do ...@@ -905,7 +905,7 @@ describe Project do
create(:ci_variable, :protected, value: 'protected', project: project) create(:ci_variable, :protected, value: 'protected', project: project)
end end
subject { project.secret_variables_for(ref: 'ref') } subject { project.ci_variables_for(ref: 'ref') }
before do before do
stub_application_setting( stub_application_setting(
...@@ -916,7 +916,7 @@ describe Project do ...@@ -916,7 +916,7 @@ describe Project do
let(:environment) { 'review/name' } let(:environment) { 'review/name' }
subject do subject do
project.secret_variables_for(ref: 'ref', environment: environment) project.ci_variables_for(ref: 'ref', environment: environment)
end end
shared_examples 'matching environment scope' do shared_examples 'matching environment scope' do
...@@ -925,8 +925,8 @@ describe Project do ...@@ -925,8 +925,8 @@ describe Project do
stub_licensed_features(variable_environment_scope: true) stub_licensed_features(variable_environment_scope: true)
end end
it 'contains the secret variable' do it 'contains the ci variable' do
is_expected.to contain_exactly(secret_variable) is_expected.to contain_exactly(ci_variable)
end end
end end
...@@ -935,8 +935,8 @@ describe Project do ...@@ -935,8 +935,8 @@ describe Project do
stub_licensed_features(variable_environment_scope: false) stub_licensed_features(variable_environment_scope: false)
end end
it 'does not contain the secret variable' do it 'does not contain the ci variable' do
is_expected.not_to contain_exactly(secret_variable) is_expected.not_to contain_exactly(ci_variable)
end end
end end
end end
...@@ -947,8 +947,8 @@ describe Project do ...@@ -947,8 +947,8 @@ describe Project do
stub_licensed_features(variable_environment_scope: true) stub_licensed_features(variable_environment_scope: true)
end end
it 'does not contain the secret variable' do it 'does not contain the ci variable' do
is_expected.not_to contain_exactly(secret_variable) is_expected.not_to contain_exactly(ci_variable)
end end
end end
...@@ -957,15 +957,15 @@ describe Project do ...@@ -957,15 +957,15 @@ describe Project do
stub_licensed_features(variable_environment_scope: false) stub_licensed_features(variable_environment_scope: false)
end end
it 'does not contain the secret variable' do it 'does not contain the ci variable' do
is_expected.not_to contain_exactly(secret_variable) is_expected.not_to contain_exactly(ci_variable)
end end
end end
end end
context 'when environment scope is exactly matched' do context 'when environment scope is exactly matched' do
before do before do
secret_variable.update(environment_scope: 'review/name') ci_variable.update(environment_scope: 'review/name')
end end
it_behaves_like 'matching environment scope' it_behaves_like 'matching environment scope'
...@@ -973,7 +973,7 @@ describe Project do ...@@ -973,7 +973,7 @@ describe Project do
context 'when environment scope is matched by wildcard' do context 'when environment scope is matched by wildcard' do
before do before do
secret_variable.update(environment_scope: 'review/*') ci_variable.update(environment_scope: 'review/*')
end end
it_behaves_like 'matching environment scope' it_behaves_like 'matching environment scope'
...@@ -981,7 +981,7 @@ describe Project do ...@@ -981,7 +981,7 @@ describe Project do
context 'when environment scope does not match' do context 'when environment scope does not match' do
before do before do
secret_variable.update(environment_scope: 'review/*/special') ci_variable.update(environment_scope: 'review/*/special')
end end
it_behaves_like 'not matching environment scope' it_behaves_like 'not matching environment scope'
...@@ -993,18 +993,18 @@ describe Project do ...@@ -993,18 +993,18 @@ describe Project do
end end
it 'does not treat it as wildcard' do it 'does not treat it as wildcard' do
secret_variable.update(environment_scope: '*_*') ci_variable.update(environment_scope: '*_*')
is_expected.not_to contain_exactly(secret_variable) is_expected.not_to contain_exactly(ci_variable)
end end
context 'when environment name contains underscore' do context 'when environment name contains underscore' do
let(:environment) { 'foo_bar/test' } let(:environment) { 'foo_bar/test' }
it 'matches literally for _' do it 'matches literally for _' do
secret_variable.update(environment_scope: 'foo_bar/*') ci_variable.update(environment_scope: 'foo_bar/*')
is_expected.to contain_exactly(secret_variable) is_expected.to contain_exactly(ci_variable)
end end
end end
end end
...@@ -1019,18 +1019,18 @@ describe Project do ...@@ -1019,18 +1019,18 @@ describe Project do
end end
it 'does not treat it as wildcard' do it 'does not treat it as wildcard' do
secret_variable.update_attribute(:environment_scope, '*%*') ci_variable.update_attribute(:environment_scope, '*%*')
is_expected.not_to contain_exactly(secret_variable) is_expected.not_to contain_exactly(ci_variable)
end end
context 'when environment name contains a percent' do context 'when environment name contains a percent' do
let(:environment) { 'foo%bar/test' } let(:environment) { 'foo%bar/test' }
it 'matches literally for _' do it 'matches literally for _' do
secret_variable.update(environment_scope: 'foo%bar/*') ci_variable.update(environment_scope: 'foo%bar/*')
is_expected.to contain_exactly(secret_variable) is_expected.to contain_exactly(ci_variable)
end end
end end
end end
...@@ -1038,7 +1038,7 @@ describe Project do ...@@ -1038,7 +1038,7 @@ describe Project do
context 'when variables with the same name have different environment scopes' do context 'when variables with the same name have different environment scopes' do
let!(:partially_matched_variable) do let!(:partially_matched_variable) do
create(:ci_variable, create(:ci_variable,
key: secret_variable.key, key: ci_variable.key,
value: 'partial', value: 'partial',
environment_scope: 'review/*', environment_scope: 'review/*',
project: project) project: project)
...@@ -1046,7 +1046,7 @@ describe Project do ...@@ -1046,7 +1046,7 @@ describe Project do
let!(:perfectly_matched_variable) do let!(:perfectly_matched_variable) do
create(:ci_variable, create(:ci_variable,
key: secret_variable.key, key: ci_variable.key,
value: 'prefect', value: 'prefect',
environment_scope: 'review/name', environment_scope: 'review/name',
project: project) project: project)
...@@ -1058,7 +1058,7 @@ describe Project do ...@@ -1058,7 +1058,7 @@ describe Project do
it 'puts variables matching environment scope more in the end' do it 'puts variables matching environment scope more in the end' do
is_expected.to eq( is_expected.to eq(
[secret_variable, [ci_variable,
partially_matched_variable, partially_matched_variable,
perfectly_matched_variable]) perfectly_matched_variable])
end end
......
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