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:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-09-05 12:11:14 +0300
committerThong Kuah <tkuah@gitlab.com>2019-09-05 12:11:14 +0300
commit537eb0bb2d4d8a2af9753850c4a85fc473b68d8d (patch)
tree13528ed19cbc5c7a30fd0945223b8f2d84e9396b /spec/validators
parent8d93ec2e90edde1b519fa59fdc8e2af12d76d4c0 (diff)
Avoid checking dns rebind protection in validation
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/addressable_url_validator_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/validators/addressable_url_validator_spec.rb b/spec/validators/addressable_url_validator_spec.rb
index 387e84b2d04..6927a1f67a1 100644
--- a/spec/validators/addressable_url_validator_spec.rb
+++ b/spec/validators/addressable_url_validator_spec.rb
@@ -92,6 +92,15 @@ describe AddressableUrlValidator do
expect(badge.errors).to be_empty
expect(badge.link_url).to eq('https://127.0.0.1')
end
+
+ it 'allows urls that cannot be resolved' do
+ stub_env('RSPEC_ALLOW_INVALID_URLS', 'false')
+ badge.link_url = 'http://foobar.x'
+
+ subject
+
+ expect(badge.errors).to be_empty
+ end
end
context 'when message is set' do
@@ -312,4 +321,32 @@ describe AddressableUrlValidator do
end
end
end
+
+ context 'when dns_rebind_protection is' do
+ let(:not_resolvable_url) { 'http://foobar.x' }
+ let(:validator) { described_class.new(attributes: [:link_url], dns_rebind_protection: dns_value) }
+
+ before do
+ stub_env('RSPEC_ALLOW_INVALID_URLS', 'false')
+ badge.link_url = not_resolvable_url
+
+ subject
+ end
+
+ context 'true' do
+ let(:dns_value) { true }
+
+ it 'raises error' do
+ expect(badge.errors).to be_present
+ end
+ end
+
+ context 'false' do
+ let(:dns_value) { false }
+
+ it 'allows urls that cannot be resolved' do
+ expect(badge.errors).to be_empty
+ end
+ end
+ end
end