Re-use custom socket class for FASP requests (#37925)
This commit is contained in:
@@ -29,7 +29,7 @@ class Fasp::Request
|
|||||||
response = HTTP
|
response = HTTP
|
||||||
.headers(headers)
|
.headers(headers)
|
||||||
.use(http_signature: { key:, covered_components: COVERED_COMPONENTS })
|
.use(http_signature: { key:, covered_components: COVERED_COMPONENTS })
|
||||||
.send(verb, url, body:)
|
.send(verb, url, body:, socket_class: ::Request::Socket)
|
||||||
|
|
||||||
validate!(response)
|
validate!(response)
|
||||||
@provider.delivery_failure_tracker.track_success!
|
@provider.delivery_failure_tracker.track_success!
|
||||||
|
|||||||
@@ -349,5 +349,5 @@ class Request
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private_constant :ClientLimit, :Socket, :ProxySocket
|
private_constant :ClientLimit
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -78,6 +78,24 @@ RSpec.describe Fasp::Request do
|
|||||||
expect(provider.delivery_failure_tracker.failures).to eq 1
|
expect(provider.delivery_failure_tracker.failures).to eq 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the provider host name resolves to a private address' do
|
||||||
|
around do |example|
|
||||||
|
WebMock.disable!
|
||||||
|
example.run
|
||||||
|
WebMock.enable!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'raises Mastodon::ValidationError' do
|
||||||
|
resolver = instance_double(Resolv::DNS)
|
||||||
|
|
||||||
|
allow(resolver).to receive(:getaddresses).with('reqprov.example.com').and_return(%w(0.0.0.0 2001:db8::face))
|
||||||
|
allow(resolver).to receive(:timeouts=).and_return(nil)
|
||||||
|
allow(Resolv::DNS).to receive(:open).and_yield(resolver)
|
||||||
|
|
||||||
|
expect { subject.send(method, '/test_path') }.to raise_error(Mastodon::ValidationError)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#get' do
|
describe '#get' do
|
||||||
|
|||||||
Reference in New Issue
Block a user