Commit 1db01726 authored by Thong Kuah's avatar Thong Kuah

Merge branch '11951-fix-url-blocker-segfault' into 'master'

Fix random segfaults when running url_blocker_spec

See merge request gitlab-org/gitlab!54404
parents 9b4c4af9 7bdd68e4
......@@ -167,10 +167,8 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
subject { described_class.validate!(import_url, dns_rebind_protection: dns_rebind_protection) }
before do
skip 'timeout is not available' unless timeout_available?
stub_env('RSPEC_ALLOW_INVALID_URLS', 'false')
stub_const("#{described_class}::GETADDRINFO_TIMEOUT_SECONDS", 0)
allow(Addrinfo).to receive(:getaddrinfo).and_raise(SocketError)
end
context 'with dns rebinding enabled' do
......@@ -189,17 +187,6 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
let(:expected_hostname) { nil }
end
end
# Detect whether the timeout option is available.
#
# See https://bugs.ruby-lang.org/issues/15553
def timeout_available?
Addrinfo.getaddrinfo('localhost', nil, timeout: 0)
false
rescue SocketError
true
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment