Skip to content

Commit

Permalink
Refs #33881 - Drop deprecated HttpDownload parameters
Browse files Browse the repository at this point in the history
Version 3.1.0 (3d87c6f) deprecated
these parameters.

Signed-off-by: Lukas Zapletal <[email protected]>
  • Loading branch information
lzap authored and ekohl committed Aug 29, 2022
1 parent 4f457dc commit 3e2217d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
5 changes: 1 addition & 4 deletions lib/proxy/http_download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ class HttpDownload < Proxy::Util::CommandTask
include Util
DEFAULT_CONNECT_TIMEOUT = 10

def initialize(src, dst, read_timeout = nil, connect_timeout = nil, dns_timeout = nil, verify_server_cert = false)
def initialize(src, dst, connect_timeout: DEFAULT_CONNECT_TIMEOUT, verify_server_cert: false)
@dst = dst
logger.warn('Deprecated: HttpDownload read_timeout is deprecated and will be removed in 4.0') if read_timeout
logger.warn('Deprecated: HttpDownload dns_timeout is deprecated and will be removed in 4.0') if dns_timeout
connect_timeout ||= DEFAULT_CONNECT_TIMEOUT
args = [which('curl')]

# no cert verification if set
Expand Down
9 changes: 3 additions & 6 deletions modules/tftp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,9 @@ def self.fetch_boot_file(dst, src)
def self.choose_protocol_and_fetch(src, destination)
case URI(src).scheme
when 'http', 'https', 'ftp'
::Proxy::HttpDownload.new(src.to_s,
destination.to_s,
nil,
Proxy::TFTP::Plugin.settings.tftp_connect_timeout,
nil,
Proxy::TFTP::Plugin.settings.verify_server_cert).start
::Proxy::HttpDownload.new(src.to_s, destination.to_s,
connect_timeout: Proxy::TFTP::Plugin.settings.tftp_connect_timeout,
verify_server_cert: Proxy::TFTP::Plugin.settings.verify_server_cert).start

when 'nfs'
logger.debug "NFS as a protocol for installation medium detected."
Expand Down
17 changes: 17 additions & 0 deletions test/http_download_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ def test_regular_call
assert_equal expected, Proxy::HttpDownload.new('src', 'dst').command
end

def test_regular_call_with_ssl_verify
expected = [
"/usr/bin/curl",
"--silent", "--show-error",
"--connect-timeout", "10",
"--retry", "3",
"--retry-delay", "10",
"--max-time", "3600",
"--remote-time",
"--time-cond", "dst",
"--write-out", "Task done, result: %{http_code}, size downloaded: %{size_download}b, speed: %{speed_download}b/s, time: %{time_total}ms",
"--output", "dst",
"--location", "src"
]
assert_equal expected, Proxy::HttpDownload.new('src', 'dst', verify_server_cert: true).command
end

def test_should_skip_download_if_one_is_in_progress
Dir.mktmpdir do |tmpdir|
Proxy::FileLock.try_locking("#{tmpdir}/.dst.lock")
Expand Down
2 changes: 1 addition & 1 deletion test/tftp/tftp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_choose_protocol_and_fetch_wget_with_timeout
)

::Proxy::HttpDownload.expects(:new).returns(stub('tftp', :start => true)).
with(src, dst, nil, tftp_connect_timeout, nil, verify_server_cert)
with(src, dst, connect_timeout: tftp_connect_timeout, verify_server_cert: verify_server_cert)

Proxy::TFTP.choose_protocol_and_fetch src, dst
end
Expand Down

0 comments on commit 3e2217d

Please sign in to comment.