summaryrefslogtreecommitdiff
path: root/chef/spec/unit/rest_spec.rb
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2012-05-24 11:48:41 -0700
committerDaniel DeLeo <dan@opscode.com>2012-05-24 11:49:26 -0700
commit15b8e712d10bf482e9af2985eb901e39cfb95cf2 (patch)
tree83d44e7932471204e6c8979ac15bdf8cc4929770 /chef/spec/unit/rest_spec.rb
parent3844ff617908a8ae4a41225d13a526bf61d3627b (diff)
downloadchef-15b8e712d10bf482e9af2985eb901e39cfb95cf2.tar.gz
[CHEF-3140] regression test for gzip disable
Diffstat (limited to 'chef/spec/unit/rest_spec.rb')
-rw-r--r--chef/spec/unit/rest_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/chef/spec/unit/rest_spec.rb b/chef/spec/unit/rest_spec.rb
index 4514642492..92a0efcfe6 100644
--- a/chef/spec/unit/rest_spec.rb
+++ b/chef/spec/unit/rest_spec.rb
@@ -221,6 +221,25 @@ describe Chef::REST do
end
end
+ # CHEF-3140
+ context "when configured to disable compression" do
+ before do
+ @rest = Chef::REST.new(@base_url, nil, nil, :disable_gzip => true)
+ end
+
+ it "does not accept encoding gzip" do
+ @rest.send(:build_headers, :GET, @url, {}).should_not have_key("Accept-Encoding")
+ end
+
+ it "does not decompress a response encoded as gzip" do
+ @http_response.add_field("content-encoding", "gzip")
+ request = Net::HTTP::Get.new(@url.path)
+ Net::HTTP::Get.should_receive(:new).and_return(request)
+ # will raise a Zlib error if incorrect
+ @rest.api_request(:GET, @url, {}).should == "ninja"
+ end
+ end
+
it "should show the JSON error message on an unsuccessful request" do
http_response = Net::HTTPServerError.new("1.1", "500", "drooling from inside of mouth")
http_response.add_field("content-type", "application/json")