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:
authorThong Kuah <tkuah@gitlab.com>2019-07-24 06:48:44 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-07-30 01:20:30 +0300
commit9c8f6e0cdfcf3be90bd819751cf76ba760556d13 (patch)
treeea57a0c1a211bd37a8ffaadac8dbea4f9a1f455f /spec/support/helpers
parentd6a7408fd319749b9cd47690f03720d1a5c088ca (diff)
Stub DNS to return IPv4 address
Otherwise certain machines return IPv6 first, which is non-deterministic
Diffstat (limited to 'spec/support/helpers')
-rw-r--r--spec/support/helpers/stub_requests.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/support/helpers/stub_requests.rb b/spec/support/helpers/stub_requests.rb
index 6eb8007ed26..473f07dd413 100644
--- a/spec/support/helpers/stub_requests.rb
+++ b/spec/support/helpers/stub_requests.rb
@@ -28,6 +28,19 @@ module StubRequests
.and_return([addr])
end
+ def stub_all_dns(url, ip_address:)
+ url = URI(url)
+ port = 80 # arbitarily chosen, does not matter as we are not going to connect
+ socket = Socket.sockaddr_in(port, ip_address)
+ addr = Addrinfo.new(socket)
+
+ # See Gitlab::UrlBlocker
+ allow(Addrinfo).to receive(:getaddrinfo).and_call_original
+ allow(Addrinfo).to receive(:getaddrinfo)
+ .with(url.hostname, anything, nil, :STREAM)
+ .and_return([addr])
+ end
+
def stubbed_hostname(url, hostname: IP_ADDRESS_STUB)
url = parse_url(url)
url.hostname = hostname