diff options
Diffstat (limited to 'spec/lib/gitlab/checks/tag_check_spec.rb')
-rw-r--r-- | spec/lib/gitlab/checks/tag_check_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/gitlab/checks/tag_check_spec.rb b/spec/lib/gitlab/checks/tag_check_spec.rb index 60d3eb4bfb3..b5aafde006f 100644 --- a/spec/lib/gitlab/checks/tag_check_spec.rb +++ b/spec/lib/gitlab/checks/tag_check_spec.rb @@ -41,6 +41,36 @@ RSpec.describe Gitlab::Checks::TagCheck, feature_category: :source_code_manageme expect { subject.validate! }.not_to raise_error end end + + it "prohibits tag names that include characters incompatible with UTF-8" do + allow(subject).to receive(:tag_name).and_return("v6.0.0-\xCE.BETA") + + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, "Tag names must be valid when converted to UTF-8 encoding") + end + + it "doesn't prohibit UTF-8 compatible characters" do + allow(subject).to receive(:tag_name).and_return("v6.0.0-Ü.BETA") + + expect { subject.validate! }.not_to raise_error + end + + context "when prohibited_tag_name_encoding_check feature flag is disabled" do + before do + stub_feature_flags(prohibited_tag_name_encoding_check: false) + end + + it "doesn't prohibit tag names that include characters incompatible with UTF-8" do + allow(subject).to receive(:tag_name).and_return("v6.0.0-\xCE.BETA") + + expect { subject.validate! }.not_to raise_error + end + + it "doesn't prohibit UTF-8 compatible characters" do + allow(subject).to receive(:tag_name).and_return("v6.0.0-Ü.BETA") + + expect { subject.validate! }.not_to raise_error + end + end end context 'with protected tag' do |