Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/regex_requires_app_spec.rb')
-rw-r--r--spec/lib/gitlab/regex_requires_app_spec.rb40
1 files changed, 31 insertions, 9 deletions
diff --git a/spec/lib/gitlab/regex_requires_app_spec.rb b/spec/lib/gitlab/regex_requires_app_spec.rb
index bea5d25dbc8..7a247e5e8cf 100644
--- a/spec/lib/gitlab/regex_requires_app_spec.rb
+++ b/spec/lib/gitlab/regex_requires_app_spec.rb
@@ -5,6 +5,18 @@ require 'spec_helper'
# Only specs that *cannot* be run with fast_spec_helper only
# See regex_spec for tests that do not require the full spec_helper
RSpec.describe Gitlab::Regex, feature_category: :tooling do
+ shared_examples_for 'npm package name regex' do
+ it { is_expected.to match('@scope/package') }
+ it { is_expected.to match('unscoped-package') }
+ it { is_expected.not_to match('@first-scope@second-scope/package') }
+ it { is_expected.not_to match('scope-without-at-symbol/package') }
+ it { is_expected.not_to match('@not-a-scoped-package') }
+ it { is_expected.not_to match('@scope/sub/package') }
+ it { is_expected.not_to match('@scope/../../package') }
+ it { is_expected.not_to match('@scope%2e%2e%2fpackage') }
+ it { is_expected.not_to match('@%2e%2e%2f/package') }
+ end
+
describe '.debian_architecture_regex' do
subject { described_class.debian_architecture_regex }
@@ -37,15 +49,7 @@ RSpec.describe Gitlab::Regex, feature_category: :tooling do
describe '.npm_package_name_regex' do
subject { described_class.npm_package_name_regex }
- it { is_expected.to match('@scope/package') }
- it { is_expected.to match('unscoped-package') }
- it { is_expected.not_to match('@first-scope@second-scope/package') }
- it { is_expected.not_to match('scope-without-at-symbol/package') }
- it { is_expected.not_to match('@not-a-scoped-package') }
- it { is_expected.not_to match('@scope/sub/package') }
- it { is_expected.not_to match('@scope/../../package') }
- it { is_expected.not_to match('@scope%2e%2e%2fpackage') }
- it { is_expected.not_to match('@%2e%2e%2f/package') }
+ it_behaves_like 'npm package name regex'
context 'capturing group' do
[
@@ -63,6 +67,24 @@ RSpec.describe Gitlab::Regex, feature_category: :tooling do
end
end
+ describe '.protection_rules_npm_package_name_pattern_regex' do
+ subject { described_class.protection_rules_npm_package_name_pattern_regex }
+
+ it_behaves_like 'npm package name regex'
+
+ it { is_expected.to match('@scope/package-*') }
+ it { is_expected.to match('@my-scope/*my-package-with-wildcard-inbetween') }
+ it { is_expected.to match('@my-scope/*my-package-with-wildcard-start') }
+ it { is_expected.to match('@my-scope/my-*package-*with-wildcard-multiple-*') }
+ it { is_expected.to match('@my-scope/my-package-with_____underscore') }
+ it { is_expected.to match('@my-scope/my-package-with-wildcard-end*') }
+ it { is_expected.to match('@my-scope/my-package-with-regex-characters.+') }
+
+ it { is_expected.not_to match('@my-scope/my-package-with-percent-sign-%') }
+ it { is_expected.not_to match('*@my-scope/my-package-with-wildcard-start') }
+ it { is_expected.not_to match('@my-scope/my-package-with-backslash-\*') }
+ end
+
describe '.debian_distribution_regex' do
subject { described_class.debian_distribution_regex }