Skip to content

Commit

Permalink
Fixed the last change not to crash with "internal error in WriteCurlrc"
Browse files Browse the repository at this point in the history
when installing with a proxy (boo#929868).

In 7302ee6 the change from Ops.add to +
broke it because I did not think of getting an explicit nil via Import:

InstallInfConvertor#write_proxy makes ProxyClass#user nil:
https://github.com/yast/yast-network/blob/5595e2ece959cdadf144e095d1b0e0d1bb7059e2/src/lib/network/install_inf_convertor.rb#L251
  • Loading branch information
mvidner committed Jun 12, 2015
1 parent 3f701be commit 72e0cf5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/Proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ def EscapeForCurlrc(s)

def WriteCurlrc
proxyuser = nil
if @user != ""
if @user && !@user.empty?
proxyuser = @user
proxyuser = @user + ":" + @pass if @pass != ""
proxyuser << ":" << @pass if @pass && !@pass.empty?
end

options = {
Expand Down
29 changes: 29 additions & 0 deletions test/write_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@
expect(subject.WriteCurlrc).to be true
end

it "writes proxy settings, and a comment, when proxy is enabled via InstallInfConvertor" do
subject.Import({ "enabled" => true,
"http_proxy" => "proxy.example.org:3128",
"proxy_user" => nil,
"proxy_password" => nil })

expect(Yast::SCR).to receive(:Write).
with(path_matching(/^\.root\.curlrc\..*\."comment"/), /Changed/).
once.and_return true

expect(Yast::SCR).to receive(:Write).
with(path(".root.curlrc.\"--proxy\""), "proxy.example.org:3128").
once.and_return true

expect(Yast::SCR).to receive(:Write).
with(path(".root.curlrc.\"--noproxy\""), "localhost").
once.and_return true

allow(Yast::SCR).to receive(:Write).
with(path_matching(/^\.root\.curlrc/), nil).
and_return true

expect(Yast::SCR).to receive(:Write).
with(path(".root.curlrc"), nil).
once.and_return true

expect(subject.WriteCurlrc).to be true
end

it "writes a no-proxy setting" do
subject.Import({ "enabled" => true,
"http_proxy" => "proxy.example.org:3128",
Expand Down

0 comments on commit 72e0cf5

Please sign in to comment.