diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-04-22 11:33:37 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-04-22 11:33:37 -0700 |
commit | 5b8788c64898a0cb101d30c97e3529ebc878d384 (patch) | |
tree | 4122f769deb7d84399be2df6e7da5699ace0f80d /spec/functional/http | |
parent | 480aeb8b5cda4292411d0bc66e1f05614000acfe (diff) | |
download | chef-5b8788c64898a0cb101d30c97e3529ebc878d384.tar.gz |
CHEF-5100: moar func tests
This tests the reuse of the content length validation object and
the situation where the content length of a previous download is
retained while a 403 or other HTTP error fails to re-init the
content length to zero. The result is the 403 is turned into an
inaccurate content length exception, masking the real error.
Diffstat (limited to 'spec/functional/http')
-rw-r--r-- | spec/functional/http/simple_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb index 2df40b6272..9afd57e93f 100644 --- a/spec/functional/http/simple_spec.rb +++ b/spec/functional/http/simple_spec.rb @@ -54,6 +54,30 @@ describe Chef::HTTP::Simple do end end + shared_examples_for "an endpoint that 403s" do + it "fails with a Net::HTTPServerException for a streaming request" do + expect { http_client.streaming_request(source) }.to raise_error(Net::HTTPServerException) + end + + it "fails with a Net::HTTPServerException for a GET request" do + expect { http_client.get(source) }.to raise_error(Net::HTTPServerException) + end + end + + shared_examples_for "a 403 after a successful request when reusing the request object" do + it "fails with a Net::HTTPServerException for a streaming request" do + tempfile = http_client.streaming_request(source) + tempfile.close + Digest::MD5.hexdigest(binread(tempfile.path)).should == Digest::MD5.hexdigest(expected_content) + expect { http_client.streaming_request(source2) }.to raise_error(Net::HTTPServerException) + end + + it "fails with a Net::HTTPServerException for a GET request" do + Digest::MD5.hexdigest(http_client.get(source)).should == Digest::MD5.hexdigest(expected_content) + expect { http_client.get(source2) }.to raise_error(Net::HTTPServerException) + end + end + it_behaves_like "downloading all the things" end |