Skip to content

Commit

Permalink
Unit test curl_proxy_args
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Mar 7, 2017
1 parent cb23804 commit f6ee636
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion test/lib/inst_download_release_notes_test.rb
Expand Up @@ -177,7 +177,7 @@

context "when called twice" do
let(:language) { "en" }
let(:curl_code) { 22 }
let(:curl_code) { CURL_NOT_FOUND_CODE }

it "does not try to download again already failed release notes" do
expect(Yast::SCR).to receive(:Execute).once
Expand All @@ -196,4 +196,48 @@
end
end
end

describe "#curl_proxy_args" do
before do
stub_const("Yast::Proxy", double("proxy"))
allow(Yast::Proxy).to receive(:Read)
end

it "returns an empty string when no proxy is needed" do
expect(Yast::Proxy).to receive(:enabled).and_return(false)
expect(client.curl_proxy_args).to eq ""
end

context "when a proxy is needed " do
before do
expect(Yast::Proxy).to receive(:enabled).and_return(true)
expect(Yast::Proxy).to receive(:http).twice
.and_return("http://proxy.example.com")
test = {
"HTTP" => {
"tested" => true,
"exit" => 0
}
}
expect(Yast::Proxy).to receive(:RunTestProxy).and_return(test)

end

it "returns correct args for an unauthenticated proxy" do
allow(Yast::Proxy).to receive(:user).and_return("")
allow(Yast::Proxy).to receive(:pass).and_return("")

expect(client.curl_proxy_args)
.to eq "--proxy http://proxy.example.com"
end

it "returns correct args for an authenticated proxy" do
allow(Yast::Proxy).to receive(:user).and_return("baggins")
allow(Yast::Proxy).to receive(:pass).and_return("thief")

expect(client.curl_proxy_args)
.to eq "--proxy http://proxy.example.com --proxy-user 'baggins:thief'"
end
end
end
end

0 comments on commit f6ee636

Please sign in to comment.