Skip to content

Commit

Permalink
Merge pull request #1068 from joseivanlopez/fix_release_notes
Browse files Browse the repository at this point in the history
Avoid failure with release notes
  • Loading branch information
joseivanlopez committed Jun 29, 2020
2 parents 1ee67cc + 460c074 commit e20b34c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 30 deletions.
22 changes: 13 additions & 9 deletions library/packages/src/lib/y2packager/release_notes_fetchers/url.rb
Expand Up @@ -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,
"",
Expand All @@ -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
Expand Down
61 changes: 41 additions & 20 deletions library/packages/test/y2packager/release_notes_fetchers/url_test.rb
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jun 29 14:26:44 UTC 2020 - José Iván López González <jlopez@suse.com>

- 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 <jlopez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -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
Expand Down

0 comments on commit e20b34c

Please sign in to comment.