diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-07-20 10:25:19 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-07-20 10:25:19 -0700 |
commit | df6dd3768d5fcc99a348bd52d7e6ffeaa1c391db (patch) | |
tree | 8e79fe5fd7b9102ed71a8a731b1492f4d1bd212c /spec/spec_helper.rb | |
parent | 020c42b59503692742e6298a35d1bf4b1d2b491c (diff) | |
download | chef-df6dd3768d5fcc99a348bd52d7e6ffeaa1c391db.tar.gz |
fix retries on JSON POST requests when negotiating protocol version
on the first pass through the JSON middleware it encodes the
body. if there's a retry, it re-encodes the body as a string
with all its metacharacters escaped.
this is a particular issue when doing a first request that is
a POST that requires negotiating the API version. when doing a
GET it isn't a problem because there's no body payload -- but a
POST or a PUT which requires a retry will get garbled and will
cause a 500.
this happens on hosted right now if trying to POST with a v2
API since hosted is only v1, so there's a retry to downgrade.
i also made the same kind of changes to the streaming download
requests, but since they're GETs its unclear to me if there was
any impact there -- but middleware could have been double-mangling
headers on a retry.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1a897ef95f..bace94fcbe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,8 @@ $:.unshift File.expand_path("../..", __FILE__) require "rubygems" require "rspec/mocks" +require "webmock/rspec" + $:.unshift(File.join(File.dirname(__FILE__), "..", "lib")) $:.unshift(File.expand_path("../lib", __FILE__)) $:.unshift(File.dirname(__FILE__)) @@ -215,6 +217,11 @@ RSpec.configure do |config| config.run_all_when_everything_filtered = true config.before(:each) do + # it'd be nice to run this with connections blocked or only to localhost, but we do make lots + # of real connections, so cannot. we reset it to allow connections every time to avoid + # tests setting connections to be disabled and that state leaking into other tests. + WebMock.allow_net_connect! + Chef.reset! Chef::ChefFS::FileSystemCache.instance.reset! |