summaryrefslogtreecommitdiff
path: root/spec/unit/http/authenticator_spec.rb
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2017-03-29 09:34:09 +0100
committerThom May <thom@chef.io>2017-03-29 13:25:00 +0100
commitd6dc0b04c6f3c3d8a1461778c0c2604f879b505b (patch)
tree129eacaa80dd104f542d60b775fd1b665ebb425c /spec/unit/http/authenticator_spec.rb
parent50808ca1b1691e45c4017e6e117764ddd617e93f (diff)
downloadchef-d6dc0b04c6f3c3d8a1461778c0c2604f879b505b.tar.gz
Retry API requests if using an unsupported versiontm/retryable_api
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/unit/http/authenticator_spec.rb')
-rw-r--r--spec/unit/http/authenticator_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb
index 7fd2bdc821..5de39523cf 100644
--- a/spec/unit/http/authenticator_spec.rb
+++ b/spec/unit/http/authenticator_spec.rb
@@ -38,6 +38,26 @@ describe Chef::HTTP::Authenticator do
to include({ "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION })
end
+ context "when version_class is provided" do
+ class V0Class; extend Chef::Mixin::VersionedAPI; minimum_api_version 0; end
+ class V2Class; extend Chef::Mixin::VersionedAPI; minimum_api_version 2; end
+
+ class AuthFactoryClass
+ extend Chef::Mixin::VersionedAPIFactory
+ add_versioned_api_class V0Class
+ add_versioned_api_class V2Class
+ end
+
+ let(:class_instance) { Chef::HTTP::Authenticator.new({ version_class: AuthFactoryClass }) }
+
+ it "uses it to select the correct http version" do
+ Chef::ServerAPIVersions.instance.reset!
+ expect(AuthFactoryClass).to receive(:best_request_version).and_call_original
+ expect(class_instance.handle_request(method, url, headers, data)[2]).
+ to include({ "X-Ops-Server-API-Version" => "2" })
+ end
+ end
+
context "when api_version is set to something other than the default" do
let(:class_instance) { Chef::HTTP::Authenticator.new({ :api_version => "-10" }) }