diff options
author | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
---|---|---|
committer | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
commit | d4b83be375ac1dead058e091191ee7c7b7c24c8a (patch) | |
tree | dc825687392ae3068de5b764be60c53122d9e02a /spec/unit/util/http_proxy_spec.rb | |
parent | 229cbb976fe0f70f5f30548b83517b415840f9bb (diff) | |
parent | 1681684857c6e39d60d87b0b3520d8783977ceff (diff) | |
download | puppet-upstream/3.7.0.tar.gz |
Imported Upstream version 3.7.0upstream/3.7.0
Diffstat (limited to 'spec/unit/util/http_proxy_spec.rb')
-rw-r--r-- | spec/unit/util/http_proxy_spec.rb | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/spec/unit/util/http_proxy_spec.rb b/spec/unit/util/http_proxy_spec.rb index bc6b4d2b7..59f39c511 100644 --- a/spec/unit/util/http_proxy_spec.rb +++ b/spec/unit/util/http_proxy_spec.rb @@ -4,7 +4,7 @@ require 'puppet/util/http_proxy' describe Puppet::Util::HttpProxy do - host, port = 'some.host', 1234 + host, port, user, password = 'some.host', 1234, 'user1', 'pAssw0rd' describe ".http_proxy_env" do it "should return nil if no environment variables" do @@ -80,4 +80,46 @@ describe Puppet::Util::HttpProxy do end + describe ".http_proxy_user" do + it "should return a proxy user if set in environment" do + Puppet::Util.withenv('HTTP_PROXY' => "http://#{user}:#{password}@#{host}:#{port}") do + subject.http_proxy_user.should == user + end + end + + it "should return a proxy user if set in config" do + Puppet.settings[:http_proxy_user] = user + subject.http_proxy_user.should == user + end + + it "should use environment variable before puppet settings" do + Puppet::Util.withenv('HTTP_PROXY' => "http://#{user}:#{password}@#{host}:#{port}") do + Puppet.settings[:http_proxy_user] = 'clownpants' + subject.http_proxy_user.should == user + end + end + + end + + describe ".http_proxy_password" do + it "should return a proxy password if set in environment" do + Puppet::Util.withenv('HTTP_PROXY' => "http://#{user}:#{password}@#{host}:#{port}") do + subject.http_proxy_password.should == password + end + end + + it "should return a proxy password if set in config" do + Puppet.settings[:http_proxy_user] = user + Puppet.settings[:http_proxy_password] = password + subject.http_proxy_password.should == password + end + + it "should use environment variable before puppet settings" do + Puppet::Util.withenv('HTTP_PROXY' => "http://#{user}:#{password}@#{host}:#{port}") do + Puppet.settings[:http_proxy_password] = 'clownpants' + subject.http_proxy_password.should == password + end + end + + end end |