Patch #44597 ยป 0001-Use-1-as-the-unreachable-address-in-webhook-executor.patch
| test/unit/webhook_test.rb | ||
|---|---|---|
| 349 | 349 |
test "executor tries the next IP when a connection fails" do |
| 350 | 350 |
with_webhook_server do |port, received| |
| 351 | 351 |
executor = Webhook::Executor.new("http://127.0.0.1:#{port}/hook", 'payload', nil)
|
| 352 |
# nothing listens on 127.0.0.2:<port>, so the first connection is refused
|
|
| 353 |
executor.stubs(:valid_ips).returns(['127.0.0.2', '127.0.0.1'])
|
|
| 352 |
# nothing listens on [::1]:<port>, so the first connection fails immediately
|
|
| 353 |
executor.stubs(:valid_ips).returns(['::1', '127.0.0.1'])
|
|
| 354 | 354 |
response = executor.call |
| ... | ... | |
| 362 | 362 |
test "executor raises a SocketError when no IP can be connected to" do |
| 363 | 363 |
with_webhook_server do |port, received| |
| 364 | 364 |
executor = Webhook::Executor.new("http://127.0.0.1:#{port}/hook", 'payload', nil)
|
| 365 |
executor.stubs(:valid_ips).returns(['127.0.0.2'])
|
|
| 365 |
executor.stubs(:valid_ips).returns(['::1'])
|
|
| 366 | 366 |
error = assert_raises(SocketError) { executor.call }
|
| 367 | 367 |
assert_equal 'Could not connect to any IP', error.message |