Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
22da85fc
Commit
22da85fc
authored
Jul 24, 2019
by
Thong Kuah
Committed by
Douglas Barbosa Alexandre
Jul 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stub DNS to return IPv4 address
Otherwise certain machines return IPv6 first, which is non-deterministic
parent
ec9c05b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
spec/lib/gitlab/http_connection_adapter_spec.rb
spec/lib/gitlab/http_connection_adapter_spec.rb
+6
-0
spec/support/helpers/stub_requests.rb
spec/support/helpers/stub_requests.rb
+13
-0
No files found.
spec/lib/gitlab/http_connection_adapter_spec.rb
View file @
22da85fc
...
...
@@ -3,7 +3,13 @@
require
'spec_helper'
describe
Gitlab
::
HTTPConnectionAdapter
do
include
StubRequests
describe
'#connection'
do
before
do
stub_all_dns
(
'https://example.org'
,
ip_address:
'93.184.216.34'
)
end
context
'when local requests are not allowed'
do
it
'sets up the connection'
do
uri
=
URI
(
'https://example.org'
)
...
...
spec/support/helpers/stub_requests.rb
View file @
22da85fc
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment