diff options
author | Sander van Harmelen <svanharmelen@schubergphilis.com> | 2014-05-01 01:02:10 +0200 |
---|---|---|
committer | Sander van Harmelen <svanharmelen@schubergphilis.com> | 2014-05-13 09:40:25 +0200 |
commit | c84b5a23a17a19eba57cb5d62eb4f4e549eda35e (patch) | |
tree | e9b4d74f52030327e413d038955fb47d51f391ac /spec | |
parent | b7ef4738811d9bc77d004c690115b234b4e88ea2 (diff) | |
download | chef-c84b5a23a17a19eba57cb5d62eb4f4e549eda35e.tar.gz |
COOK-5261 Added some formatting to prevent malformed URLs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/http_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/unit/http_spec.rb b/spec/unit/http_spec.rb index d747482260..1cd226b4ee 100644 --- a/spec/unit/http_spec.rb +++ b/spec/unit/http_spec.rb @@ -21,8 +21,31 @@ require 'spec_helper' require 'chef/http' require 'chef/http/basic_client' +class Chef::HTTP + public :create_url +end + describe Chef::HTTP do + describe "create_url" do + + it 'should return a correctly formatted url 1/3 CHEF-5261' do + http = Chef::HTTP.new('http://www.getchef.com') + http.create_url('api/endpoint').should eql(URI.parse('http://www.getchef.com/api/endpoint')) + end + + it 'should return a correctly formatted url 2/3 CHEF-5261' do + http = Chef::HTTP.new('http://www.getchef.com/') + http.create_url('/organization/org/api/endpoint/').should eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint/')) + end + + it 'should return a correctly formatted url 3/3 CHEF-5261' do + http = Chef::HTTP.new('http://www.getchef.com/organization/org///') + http.create_url('///api/endpoint?url=http://foo.bar').should eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar')) + end + + end # create_url + describe "head" do it 'should return nil for a "200 Success" response (CHEF-4762)' do |