spec/httpi/adapter/curb_spec.rb in httpi-2.4.0 vs spec/httpi/adapter/curb_spec.rb in httpi-2.4.1
- old
+ new
@@ -1,13 +1,33 @@
require "spec_helper"
require "httpi/adapter/curb"
require "httpi/request"
+require "integration/support/server"
+
# curb does not run on jruby
unless RUBY_PLATFORM =~ /java/
HTTPI::Adapter.load_adapter(:curb)
+ describe "NTLM authentication" do
+ before :all do
+ @server = IntegrationServer.run
+ end
+
+ after :all do
+ @server.stop
+ end
+
+ it "supports ntlm authentication" do
+ request = HTTPI::Request.new(@server.url + "ntlm-auth")
+ adapter = HTTPI::Adapter::Curb.new(request)
+
+ request.auth.ntlm("tester", "vReqSoafRe5O")
+ expect(adapter.request(:get).body).to eq("ntlm-auth")
+ end
+ end
+
describe HTTPI::Adapter::Curb do
let(:adapter) { HTTPI::Adapter::Curb.new(request) }
let(:curb) { Curl::Easy.any_instance }
let(:request) { HTTPI::Request.new("http://example.com") }
@@ -166,19 +186,10 @@
curb.expects(:verbose=).with(false)
adapter.request(:get)
end
end
- describe "NTLM authentication" do
- it "is not supported" do
- request.auth.ntlm("tester", "vReqSoafRe5O")
-
- expect { adapter.request(:get) }.
- to raise_error(HTTPI::NotSupportedError, /does not support NTLM authentication/)
- end
- end
-
describe "http_auth_types" do
it "is set to :basic for HTTP basic auth" do
request.auth.basic "username", "password"
curb.expects(:http_auth_types=).with(:basic)
@@ -196,10 +207,17 @@
request.auth.gssnegotiate
curb.expects(:http_auth_types=).with(:gssnegotiate)
adapter.request(:get)
end
+
+ it "is set to :ntlm for HTTP NTLM auth" do
+ request.auth.ntlm("tester", "vReqSoafRe5O")
+ curb.expects(:http_auth_types=).with(:ntlm)
+
+ adapter.request(:get)
+ end
end
describe "username and password" do
it "is set for HTTP basic auth" do
request.auth.basic "username", "password"
@@ -264,9 +282,10 @@
request
end
it "send certificate regardless of state of SSL verify mode" do
request.auth.ssl.verify_mode = :none
+ curb.expects(:ssl_verify_host=).with(0) # avoid "SSL peer certificate" error
curb.expects(:cert_key=).with(request.auth.ssl.cert_key_file)
curb.expects(:cert=).with(request.auth.ssl.cert_file)
adapter.request(:get)
end