summaryrefslogtreecommitdiff
path: root/spec/unit/http/authenticator_spec.rb
diff options
context:
space:
mode:
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" }) }