Skip to content

Commit

Permalink
Merge pull request #936 from tacchino/empty_proxy
Browse files Browse the repository at this point in the history
Support Empty Proxy Settings
  • Loading branch information
robbkidd committed Mar 24, 2016
2 parents 8af00c5 + 45648e0 commit cde7943
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
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

0 comments on commit cde7943

Please sign in to comment.