Commit fa1127c6 authored by Rémy Coutable's avatar Rémy Coutable

Strip leading & trailing whitespaces in CI/CD secret variable's environment scope

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 1bdeed0e
......@@ -4,7 +4,6 @@ module Ci
include HasVariable
include Presentable
prepend EE::Ci::Variable
include Presentable
belongs_to :project
......
---
title: Strip leading & trailing whitespaces in CI/CD secret variable's environment
scope
merge_request: 3563
author:
type: fixed
......@@ -11,6 +11,10 @@ module EE
message: ::Gitlab::Regex.environment_scope_regex_message }
)
end
def environment_scope=(new_environment_scope)
super(new_environment_scope.to_s.strip)
end
end
end
end
......@@ -11,4 +11,22 @@ describe Ci::Variable do
is_expected.to validate_uniqueness_of(:key)
.scoped_to(:project_id, :environment_scope)
end
describe '#environment_scope=' do
context 'when the new environment_scope is nil' do
it 'strips leading and trailing whitespaces' do
subject.environment_scope = nil
expect(subject.environment_scope).to eq('')
end
end
context 'when the new environment_scope has leadind and trailing whitespaces' do
it 'strips leading and trailing whitespaces' do
subject.environment_scope = ' * '
expect(subject.environment_scope).to eq('*')
end
end
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