Skip to content

Commit 759c659

Browse files
committed
Try and fix private address check test in CI
1 parent 9cb0683 commit 759c659

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ jobs:
6161
- name: Install JS dependencies
6262
run: yarn install --frozen-lockfile --non-interactive
6363
- name: Run tests
64-
run: bundle exec rails test
64+
run: bundle exec rails test test/unit/ingestors/ingestor_test.rb

test/unit/ingestors/ingestor_test.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,18 @@ def run_filter(source_filter)
372372
end
373373

374374
# private address
375-
with_net_connection do # Allow request through to be caught by private_address_check
376-
assert_nil ingestor.open_url('http://192.168.0.1')
377-
assert_equal "Couldn't open URL http://192.168.0.1", ingestor.messages.last
378-
assert_raises(RuntimeError) do
379-
ingestor.open_url('http://192.168.0.1', raise: true)
375+
begin
376+
server = TCPServer.new(3005)
377+
thread = Thread.start { server.accept }
378+
with_net_connection do # Allow request through to be caught by private_address_check
379+
assert_nil ingestor.open_url('http://localhost:3005')
380+
assert_equal "Couldn't open URL http://localhost:3005", ingestor.messages.last
381+
assert_raises(RuntimeError) do
382+
ingestor.open_url('http://localhost:3005', raise: true)
383+
end
380384
end
385+
ensure
386+
thread.exit if thread
381387
end
382388

383389
# timeout

0 commit comments

Comments
 (0)