Skip to content
Open
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
9 changes: 7 additions & 2 deletions lib/casclient/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Client
attr_reader :log, :username_session_key, :extra_attributes_session_key
attr_reader :ticket_store
attr_reader :proxy_host, :proxy_port
attr_writer :login_url, :validate_url, :proxy_url, :logout_url, :service_url
attr_writer :login_url, :validate_url, :proxy_url, :logout_url, :service_url, :ticket_url
attr_accessor :proxy_callback_url, :proxy_retrieval_url

def initialize(conf = nil)
Expand All @@ -28,6 +28,7 @@ def configure(conf)

@login_url = conf[:login_url]
@logout_url = conf[:logout_url]
@ticket_url = conf[:ticket_url]
@validate_url = conf[:validate_url]
@proxy_url = conf[:proxy_url]
@service_url = conf[:service_url]
Expand Down Expand Up @@ -70,6 +71,10 @@ def validate_url
@validate_url || (cas_base_url + "/proxyValidate")
end

def ticket_url
@ticket_url || (cas_base_url + '/loginTicket')
end

# Returns the CAS server's logout url.
#
# If a logout_url has not been explicitly configured,
Expand Down Expand Up @@ -182,7 +187,7 @@ def login_to_service(credentials, service)
# This only works with RubyCAS-Server, since obtaining login
# tickets in this manner is not part of the official CAS spec.
def request_login_ticket
uri = URI.parse(login_url+'Ticket')
uri = URI.parse(ticket_url)
https = https_connection(uri)
res = https.post(uri.path, ';')

Expand Down
4 changes: 2 additions & 2 deletions spec/casclient/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@

context "request login ticket" do
it "raises an exception when the request was not a success" do
session.stub(:post).with("/Ticket", ";").and_return(response)
session.stub(:post).with("/loginTicket", ";").and_return(response)
response.stub :kind_of? => false
lambda {
client.request_login_ticket
}.should raise_error(CASClient::CASException)
end

it "returns the response body when the request is a success" do
session.stub(:post).with("/Ticket", ";").and_return(response)
session.stub(:post).with("/loginTicket", ";").and_return(response)
response.stub :kind_of? => true
client.request_login_ticket.should == "HTTP BODY"
end
Expand Down