diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-05-18 11:14:10 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-05-18 11:14:10 +0300 |
commit | af9b0bfbae84a402e5c706ac29772b0d70dfa156 (patch) | |
tree | cba1e625db3ca4f6e74c2d96ee04f2c24fabc994 /spec/lib/gitlab/untrusted_regexp_spec.rb | |
parent | 61d55b56ab4ee7d11484eeea6fabb2412af6578f (diff) |
Simplify untrusted regexp factory method
Diffstat (limited to 'spec/lib/gitlab/untrusted_regexp_spec.rb')
-rw-r--r-- | spec/lib/gitlab/untrusted_regexp_spec.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/spec/lib/gitlab/untrusted_regexp_spec.rb b/spec/lib/gitlab/untrusted_regexp_spec.rb index 4bca320ac2c..0a6ac0aa294 100644 --- a/spec/lib/gitlab/untrusted_regexp_spec.rb +++ b/spec/lib/gitlab/untrusted_regexp_spec.rb @@ -4,9 +4,13 @@ require 'support/shared_examples/malicious_regexp_shared_examples' describe Gitlab::UntrustedRegexp do describe '.valid?' do it 'returns true if regexp is valid' do + expect(described_class.valid?('/some ( thing/')) + .to be false end it 'returns true if regexp is invalid' do + expect(described_class.valid?('/some .* thing/')) + .to be true end end @@ -32,17 +36,9 @@ describe Gitlab::UntrustedRegexp do end end - context 'when regexp is not plain pattern' do - it 'fabricates regexp without flags' do - regexp = described_class.fabricate('something') - - expect(regexp).to eq described_class.new('something') - end - end - - context 'when regexp is invalid' do + context 'when regexp is a raw pattern' do it 'raises an error' do - expect { described_class.fabricate('/some ( thing/') } + expect { described_class.fabricate('some .* thing') } .to raise_error(RegexpError) end end |