Skip to content

Commit

Permalink
Handle also AutoYaST case
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jun 10, 2021
1 parent 5bf338c commit f03cce3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib/installation/clients/proxy_finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def main
"when" => [:installation, :update, :autoinst]
}
elsif @func == "Write"
if Stage.initial && Proxy.to_target
if write_to_target?
proxy_settings = Proxy.Export

log.info("Writing proxy settings to the target system: #{proxy_settings.inspect}")
Expand All @@ -84,5 +84,17 @@ def main
Builtins.y2milestone("proxy_finish finished")
deep_copy(@ret)
end

private

# Whether the configuration should be written to the target system or not
#
# @return [Boolean]
def write_to_target?
return false unless Stage.initial

# In case of AutoYaST the configuration could have been imported but not written yet
Proxy.modified || Proxy.to_target
end
end
end
13 changes: 13 additions & 0 deletions test/lib/clients/proxy_finish_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@
context "when the client is called with the 'Write' argument" do
let(:initial_stage) { true }
let(:to_target) { false }
let(:modified) { false }
let(:args) { ["Write"] }
let(:config) { { "http_proxy" => "http://proxy.example.com:3128/" } }

before do
allow(Yast::Stage).to receive(:initial).and_return(initial_stage)
allow(Yast::Proxy).to receive(:to_target).and_return(to_target)
allow(Yast::Proxy).to receive(:Export).and_return(config)
allow(Yast::Proxy).to receive(:modified).and_return(modified)
end

context "when running on the first stage" do
Expand All @@ -57,6 +59,17 @@
end
end

context "and the proxy settings have been modified but not written yet" do
let(:modified) { true }

it "writes the current sysconfig and curlrc configuration to the target system" do
expect(Yast::Proxy).to receive(:Import).with(config)
expect(Yast::Proxy).to receive(:WriteSysconfig)
expect(Yast::Proxy).to receive(:WriteCurlrc)
client.main
end
end

context "and the proxy settings were written to the inst-sys during the installation" do
let(:to_target) { true }

Expand Down

0 comments on commit f03cce3

Please sign in to comment.