Commit 0d67d6d6 authored by James Lopez's avatar James Lopez

Merge branch '199047-add-anchors-to-dns-stubbing-in-spec-suite' into 'master'

Resolve "Add anchors to DNS stubbing in spec suite"

Closes #199047

See merge request gitlab-org/gitlab!24180
parents ed300684 f05eb54e
......@@ -17,13 +17,13 @@ module DnsHelpers
end
def stub_invalid_dns!
allow(Addrinfo).to receive(:getaddrinfo).with(/foobar\.\w|(\d{1,3}\.){4,}\d{1,3}/i, anything, nil, :STREAM) do
allow(Addrinfo).to receive(:getaddrinfo).with(/\Afoobar\.\w|(\d{1,3}\.){4,}\d{1,3}\z/i, anything, nil, :STREAM) do
raise SocketError.new("getaddrinfo: Name or service not known")
end
end
def permit_local_dns!
local_addresses = /(127|10)\.0\.0\.\d{1,3}|(192\.168|172\.16)\.\d{1,3}\.\d{1,3}|0\.0\.0\.0|localhost/i
local_addresses = /\A(127|10)\.0\.0\.\d{1,3}|(192\.168|172\.16)\.\d{1,3}\.\d{1,3}|0\.0\.0\.0|localhost\z/i
allow(Addrinfo).to receive(:getaddrinfo).with(local_addresses, anything, nil, :STREAM).and_call_original
allow(Addrinfo).to receive(:getaddrinfo).with(local_addresses, anything, nil, :STREAM, anything, anything).and_call_original
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