diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-07-30 04:27:52 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-07-30 04:27:52 +0300 |
commit | 534f8fc7975f1fe5f38f8d4b2ba3c15ddb8ac9d1 (patch) | |
tree | b90c08cb6f57746d6fcbb02d6193c94fbcb188c9 /spec/support | |
parent | 8d9451dff764300334faf27d40226fb1ae8767ac (diff) | |
parent | 9c8f6e0cdfcf3be90bd819751cf76ba760556d13 (diff) |
Merge branch 'determinstic_dns_specs' into 'master'
Have deterministic DNS for specs
See merge request gitlab-org/gitlab-ce!31086
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/stub_requests.rb | 13 |
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 |