diff options
Diffstat (limited to 'spec/support/shared/functional/http.rb')
-rw-r--r-- | spec/support/shared/functional/http.rb | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb index cfbb8e3689..7b7c17106d 100644 --- a/spec/support/shared/functional/http.rb +++ b/spec/support/shared/functional/http.rb @@ -22,11 +22,11 @@ module ChefHTTPShared def nyan_uncompressed_filename - File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png') + File.join(CHEF_SPEC_DATA, "remote_file", "nyan_cat.png") end def nyan_compressed_filename - File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png.gz') + File.join(CHEF_SPEC_DATA, "remote_file", "nyan_cat.png.gz") end def binread(file) @@ -60,7 +60,7 @@ module ChefHTTPShared # this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies) # (expected_content should be compressed) - @api.get("/nyan_cat.png.gz", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) { + @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) { File.open(nyan_compressed_filename, "rb") do |f| f.read end @@ -68,7 +68,7 @@ module ChefHTTPShared # this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it # (expected_content should be uncompressed) - @api.get("/nyan_cat_compressed.png", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) { + @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) { File.open(nyan_compressed_filename, "rb") do |f| f.read end @@ -81,7 +81,7 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_content_length.png", 200, nil, { - 'Content-Length' => nyan_uncompressed_size.to_s + "Content-Length" => nyan_uncompressed_size.to_s } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -92,9 +92,9 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_content_length_compressed.png", 200, nil, { - 'Content-Length' => nyan_compressed_size.to_s, - 'Content-Type' => 'application/gzip', - 'Content-Encoding' => 'gzip', + "Content-Length" => nyan_compressed_size.to_s, + "Content-Type" => "application/gzip", + "Content-Encoding" => "gzip", } ) { File.open(nyan_compressed_filename, "rb") do |f| @@ -109,7 +109,7 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_truncated.png", 200, nil, { - 'Content-Length' => (nyan_uncompressed_size + 1).to_s + "Content-Length" => (nyan_uncompressed_size + 1).to_s } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -120,9 +120,9 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_truncated_compressed.png", 200, nil, { - 'Content-Length' => (nyan_compressed_size + 1).to_s, - 'Content-Type' => 'application/gzip', - 'Content-Encoding' => 'gzip', + "Content-Length" => (nyan_compressed_size + 1).to_s, + "Content-Type" => "application/gzip", + "Content-Encoding" => "gzip", } ) { File.open(nyan_compressed_filename, "rb") do |f| @@ -137,8 +137,8 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_transfer_encoding.png", 200, nil, { - 'Content-Length' => (nyan_uncompressed_size + 1).to_s, - 'Transfer-Encoding' => 'anything', + "Content-Length" => (nyan_uncompressed_size + 1).to_s, + "Transfer-Encoding" => "anything", } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -149,19 +149,19 @@ module ChefHTTPShared # # 403 with a Content-Length # - @api.get('/forbidden', 403, 'Forbidden', + @api.get("/forbidden", 403, "Forbidden", { - 'Content-Length' => 'Forbidden'.bytesize.to_s + "Content-Length" => "Forbidden".bytesize.to_s } ) - @api.post('/posty', 200, 'Hi!') + @api.post("/posty", 200, "Hi!") # # 400 with an error # - @api.get('/bad_request', 400, '{ "error": [ "Your request is just terrible." ] }') - @api.post('/bad_request', 400, '{ "error": [ "Your request is just terrible." ] }') + @api.get("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }') + @api.post("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }') end @@ -175,14 +175,14 @@ end shared_examples_for "downloading all the things" do describe "when downloading a simple uncompressed file" do - let(:source) { 'http://localhost:9000/nyan_cat.png' } + let(:source) { "http://localhost:9000/nyan_cat.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading a compressed file that should be left compressed" do - let(:source) { 'http://localhost:9000/nyan_cat.png.gz' } + let(:source) { "http://localhost:9000/nyan_cat.png.gz" } let(:expected_content) { binread(nyan_compressed_filename) } # its the callers responsibility to disable_gzip when downloading a .gz url @@ -192,57 +192,57 @@ shared_examples_for "downloading all the things" do end describe "when downloading a file that has been compressed by the webserver" do - let(:source) { 'http://localhost:9000/nyan_cat_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading an uncompressed file with a correct content_length" do - let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading a file that has been compressed by the webserver with a correct content_length" do - let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading an uncompressed file that is truncated" do - let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' } + let(:source) { "http://localhost:9000/nyan_cat_truncated.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "validates content length and throws an exception" end describe "when downloading a file that has been compressed by the webserver that is truncated" do - let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_truncated_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "validates content length and throws an exception" end describe "when downloading a file that has transfer encoding set with a bad content length that should be ignored" do - let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' } + let(:source) { "http://localhost:9000/nyan_cat_transfer_encoding.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading an endpoint that 403s" do - let(:source) { 'http://localhost:9000/forbidden' } + let(:source) { "http://localhost:9000/forbidden" } it_behaves_like "an endpoint that 403s" end describe "when downloading an endpoint that 403s" do - let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } - let(:source2) { 'http://localhost:9000/forbidden' } + let(:source2) { "http://localhost:9000/forbidden" } it_behaves_like "a 403 after a successful request when reusing the request object" end |