diff --git a/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb b/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb index 3c6c9b8cf..2151b3928 100644 --- a/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb +++ b/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb @@ -256,13 +256,15 @@ def curl_proxy_args return @curl_proxy_args if @curl_proxy_args @curl_proxy_args = "" - # proxy should be set by inst_install_inf if set via Linuxrc + + # Proxy should be set by inst_install_inf if set via Linuxrc Yast::Proxy.Read - # Test if proxy works return @curl_proxy_args unless Yast::Proxy.enabled - # it is enough to test http proxy, release notes are downloaded via http + # Test if proxy works + # + # It is enough to test http proxy, release notes are downloaded via http proxy_ret = Yast::Proxy.RunTestProxy( Yast::Proxy.http, "", @@ -272,13 +274,15 @@ def curl_proxy_args ) http_ret = proxy_ret.fetch("HTTP", {}) - if http_ret.fetch("tested", true) == true && http_ret.fetch("exit", 1) == 0 - user_pass = (Yast::Proxy.user != "") ? "#{Yast::Proxy.user}:#{Yast::Proxy.pass}" : "" - proxy = "--proxy #{Yast::Proxy.http}" - proxy << " --proxy-user '#{user_pass}'" unless user_pass.empty? - end + proxy_ok = http_ret.fetch("tested", true) == true && http_ret.fetch("exit", 1) == 0 + + return @curl_proxy_args unless proxy_ok + + user_pass = (Yast::Proxy.user != "") ? "#{Yast::Proxy.user}:#{Yast::Proxy.pass}" : "" + @curl_proxy_args = "--proxy #{Yast::Proxy.http}" + @curl_proxy_args << " --proxy-user '#{user_pass}'" unless user_pass.empty? - @curl_proxy_args = proxy + @curl_proxy_args end # Release notes index for the given product diff --git a/library/packages/test/y2packager/release_notes_fetchers/url_test.rb b/library/packages/test/y2packager/release_notes_fetchers/url_test.rb index 90e3bbb64..ef913967a 100755 --- a/library/packages/test/y2packager/release_notes_fetchers/url_test.rb +++ b/library/packages/test/y2packager/release_notes_fetchers/url_test.rb @@ -226,36 +226,57 @@ allow(Yast::Proxy).to receive(:http).twice.and_return("http://proxy.example.com") allow(Yast::Proxy).to receive(:user).and_return(proxy_user) allow(Yast::Proxy).to receive(:pass).and_return(proxy_pass) - test = { - "HTTP" => { - "tested" => true, - "exit" => 0 - } - } - allow(Yast::Proxy).to receive(:RunTestProxy).and_return(test) + allow(Yast::Proxy).to receive(:RunTestProxy).and_return(test_result) end - context "and no user or password are specified" do - let(:proxy_user) { "" } - let(:proxy_pass) { "" } + let(:proxy_user) { "" } + let(:proxy_pass) { "" } - it "uses an unauthenticated proxy" do - expect(Yast::SCR).to receive(:Execute) do |_path, cmd| - expect(cmd).to include("--proxy http://proxy.example.com") - expect(cmd).to_not include("--proxy-user") + context "and the proxy is working" do + let(:test_result) do + { + "HTTP" => { + "tested" => true, + "exit" => 0 + } + } + end + + context "and no user or password are specified" do + let(:proxy_user) { "" } + let(:proxy_pass) { "" } + + it "uses an unauthenticated proxy" do + expect(Yast::SCR).to receive(:Execute) do |_path, cmd| + expect(cmd).to include("--proxy http://proxy.example.com") + expect(cmd).to_not include("--proxy-user") + end + + fetcher.release_notes(prefs) end + end - fetcher.release_notes(prefs) + context "and user and password are specified" do + let(:proxy_user) { "baggins" } + let(:proxy_pass) { "thief" } + + it "uses an authenticated proxy" do + expect(Yast::SCR).to receive(:Execute) do |_path, cmd| + expect(cmd).to include("--proxy http://proxy.example.com --proxy-user 'baggins:thief'") + end + + fetcher.release_notes(prefs) + end end end - context "and user and password are specified" do - let(:proxy_user) { "baggins" } - let(:proxy_pass) { "thief" } + context "when the proxy is not working" do + let(:test_result) { {} } - it "uses an authenticated proxy" do + it "does not use any specific proxy" do expect(Yast::SCR).to receive(:Execute) do |_path, cmd| - expect(cmd).to include("--proxy http://proxy.example.com --proxy-user 'baggins:thief'") + expect(cmd).to_not match(/--proxy/) + expect(cmd).to_not match(/--proxy-user/) end fetcher.release_notes(prefs) diff --git a/package/yast2.changes b/package/yast2.changes index bc3b0d4f5..9e177ab82 100644 --- a/package/yast2.changes +++ b/package/yast2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Jun 29 14:26:44 UTC 2020 - José Iván López González + +- Avoid failure when downloading release notes from an inoperative + proxy (bsc#1173447). +- 4.2.85 + ------------------------------------------------------------------- Fri Jun 5 15:13:42 UTC 2020 - José Iván López González diff --git a/package/yast2.spec b/package/yast2.spec index 770304f79..acd0e5f49 100644 --- a/package/yast2.spec +++ b/package/yast2.spec @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.2.84 +Version: 4.2.85 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only