Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable HTTP auth for WSDLRequest #369

Merged
merged 2 commits into from
Jan 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/savon/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def initialize(globals, http_request = nil)
def build
configure_timeouts
configure_ssl
configure_auth

@http_request
end
Expand All @@ -31,6 +32,11 @@ def configure_ssl
@http_request.auth.ssl.ca_cert_file = @globals[:ssl_ca_cert_file] if @globals.include? :ssl_ca_cert_file
end

def configure_auth
@http_request.auth.basic(*@globals[:basic_auth]) if @globals.include? :basic_auth
@http_request.auth.digest(*@globals[:digest_auth]) if @globals.include? :digest_auth
end

end

class SOAPRequest
Expand Down
28 changes: 28 additions & 0 deletions spec/savon/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ def new_wsdl_request
new_wsdl_request.build
end
end

describe "basic auth" do
it "is set when specified" do
globals.basic_auth("luke", "secret")
http_request.auth.expects(:basic).with("luke", "secret")

new_wsdl_request.build
end

it "is not set otherwise" do
http_request.auth.expects(:basic).never
new_wsdl_request.build
end
end

describe "digest auth" do
it "is set when specified" do
globals.digest_auth("lea", "top-secret")
http_request.auth.expects(:digest).with("lea", "top-secret")

new_wsdl_request.build
end

it "is not set otherwise" do
http_request.auth.expects(:digest).never
new_wsdl_request.build
end
end
end

end
Expand Down