diff options
| author | Claire McQuin <claire@getchef.com> | 2014-05-27 12:52:54 -0700 |
|---|---|---|
| committer | Claire McQuin <claire@getchef.com> | 2014-06-03 09:16:53 -0700 |
| commit | 2ee87e92abbf710b5ed5d932ed84f9cb804d350c (patch) | |
| tree | d6bd4c5f7745cf0e036322e7951bf3a809b5e85c /spec/unit/application_spec.rb | |
| parent | 5020264ab9a5f33da30a569eff6bb06516f7159c (diff) | |
| download | chef-2ee87e92abbf710b5ed5d932ed84f9cb804d350c.tar.gz | |
percent encode @, : in proxy user/pass
Diffstat (limited to 'spec/unit/application_spec.rb')
| -rw-r--r-- | spec/unit/application_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index efde6d6690..698999b8dc 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -303,6 +303,12 @@ describe Chef::Application do @env['HTTP_PROXY'].should == "http://hostname:port" end + it "should percent encode the proxy, if necessary" do + Chef::Config[:http_proxy] = "http://needs\\some escaping:1234" + @app.configure_environment_variables + @env['HTTP_PROXY'].should == "http://needs%5Csome%20escaping:1234" + end + describe "when Chef::Config[:http_proxy_user] is set" do before do Chef::Config[:http_proxy_user] = "username" @@ -313,6 +319,12 @@ describe Chef::Application do @env['HTTP_PROXY'].should == "http://username@hostname:port" end + it "should percent encode the username, including @ and : characters" do + Chef::Config[:http_proxy_user] = "K:tty C@t" + @app.configure_environment_variables + @env['HTTP_PROXY'].should == "http://K%3Atty%20C%40t@hostname:port" + end + describe "when Chef::Config[:http_proxy_pass] is set" do before do Chef::Config[:http_proxy_pass] = "password" @@ -322,6 +334,12 @@ describe Chef::Application do @app.configure_environment_variables @env['HTTP_PROXY'].should == "http://username:password@hostname:port" end + + it "should fully percent escape the password, including @ and : characters" do + Chef::Config[:http_proxy_pass] = ":P@ssword101" + @app.configure_environment_variables + @env['HTTP_PROXY'].should == "http://username:%3AP%40ssword101@hostname:port" + end end end |
