diff options
Diffstat (limited to 'spec/lib/gitlab/octokit/middleware_spec.rb')
-rw-r--r-- | spec/lib/gitlab/octokit/middleware_spec.rb | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/spec/lib/gitlab/octokit/middleware_spec.rb b/spec/lib/gitlab/octokit/middleware_spec.rb index f7063f2c4f2..5555990b113 100644 --- a/spec/lib/gitlab/octokit/middleware_spec.rb +++ b/spec/lib/gitlab/octokit/middleware_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do let(:app) { double(:app) } let(:middleware) { described_class.new(app) } - shared_examples 'Allowed URL' do + shared_examples 'Public URL' do it 'does not raise an error' do expect(app).to receive(:call).with(env) @@ -14,7 +14,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do end end - shared_examples 'Blocked URL' do + shared_examples 'Local URL' do it 'raises an error' do expect { middleware.call(env) }.to raise_error(Gitlab::UrlBlocker::BlockedUrlError) end @@ -24,24 +24,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do context 'when the URL is a public URL' do let(:env) { { url: 'https://public-url.com' } } - it_behaves_like 'Allowed URL' - - context 'with failed address check' do - before do - stub_env('RSPEC_ALLOW_INVALID_URLS', 'false') - allow(Addrinfo).to receive(:getaddrinfo).and_raise(SocketError) - end - - it_behaves_like 'Blocked URL' - - context 'with disabled dns rebinding check' do - before do - stub_application_setting(dns_rebinding_protection_enabled: false) - end - - it_behaves_like 'Allowed URL' - end - end + it_behaves_like 'Public URL' end context 'when the URL is a localhost address' do @@ -52,7 +35,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do stub_application_setting(allow_local_requests_from_web_hooks_and_services: false) end - it_behaves_like 'Blocked URL' + it_behaves_like 'Local URL' end context 'when localhost requests are allowed' do @@ -60,7 +43,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do stub_application_setting(allow_local_requests_from_web_hooks_and_services: true) end - it_behaves_like 'Allowed URL' + it_behaves_like 'Public URL' end end @@ -72,7 +55,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do stub_application_setting(allow_local_requests_from_web_hooks_and_services: false) end - it_behaves_like 'Blocked URL' + it_behaves_like 'Local URL' end context 'when local network requests are allowed' do @@ -80,7 +63,7 @@ RSpec.describe Gitlab::Octokit::Middleware, feature_category: :importers do stub_application_setting(allow_local_requests_from_web_hooks_and_services: true) end - it_behaves_like 'Allowed URL' + it_behaves_like 'Public URL' end end |