Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Empty Proxy Settings #936

Merged
merged 2 commits into from Mar 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .cane
Expand Up @@ -3,5 +3,6 @@
--abc-exclude Kitchen::ThorTasks#define
--abc-exclude Kitchen::Driver::SSHBase#converge
--abc-exclude Kitchen::Driver::SSHBase#verify
--abc-exclude Kitchen::Configurable#wrap_shell_code
--style-exclude lib/vendor/**/*.rb
--doc-exclude lib/vendor/**/.rb
6 changes: 3 additions & 3 deletions lib/kitchen/configurable.rb
Expand Up @@ -299,19 +299,19 @@ def validate_config!
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
def wrap_shell_code(code)
env = []
if config[:http_proxy]
if config[:http_proxy] && !config[:http_proxy].empty?
env << shell_env_var("http_proxy", config[:http_proxy])
env << shell_env_var("HTTP_PROXY", config[:http_proxy])
else
export_proxy(env, "http")
end
if config[:https_proxy]
if config[:https_proxy] && !config[:https_proxy].empty?
env << shell_env_var("https_proxy", config[:https_proxy])
env << shell_env_var("HTTPS_PROXY", config[:https_proxy])
else
export_proxy(env, "https")
end
if config[:ftp_proxy]
if config[:ftp_proxy] && !config[:ftp_proxy].empty?
env << shell_env_var("ftp_proxy", config[:ftp_proxy])
env << shell_env_var("FTP_PROXY", config[:ftp_proxy])
else
Expand Down
33 changes: 33 additions & 0 deletions spec/kitchen/configurable_spec.rb
Expand Up @@ -833,6 +833,28 @@ class SubclassDefaults < StaticDefaults
CODE
end

it "does not export http_proxy or HTTP_PROXY when :http_proxy is empty" do
config[:http_proxy] = ""

cmd.must_equal(outdent!(<<-CODE.chomp))
sh -c '

mkdir foo
'
CODE
end

it "does not export https_proxy or HTTPS_PROXY when :https_proxy is empty" do
config[:https_proxy] = ""

cmd.must_equal(outdent!(<<-CODE.chomp))
sh -c '

mkdir foo
'
CODE
end

it "exports ftp_proxy & FTP_PROXY from workstation when :ftp_proxy isn't set" do
ENV["ftp_proxy"] = "ftp://proxy"
ENV["FTP_PROXY"] = "ftp://proxy"
Expand All @@ -846,6 +868,17 @@ class SubclassDefaults < StaticDefaults
CODE
end

it "does not export ftp_proxy or FTP_PROXY when :ftp_proxy is empty" do
config[:ftp_proxy] = ""

cmd.must_equal(outdent!(<<-CODE.chomp))
sh -c '

mkdir foo
'
CODE
end

it "exports no_proxy & NO_PROXY from workstation when http_proxy is set from workstation" do
ENV["http_proxy"] = "http://proxy"
ENV["HTTP_PROXY"] = "http://proxy"
Expand Down