Skip to content

Commit 460af12

Browse files
committed
move Service Ticket generation to module method
Signed-off-by: Tyler Pickett <t.pickett66@gmail.com>
1 parent c3d620c commit 460af12

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

lib/rubycas-server-core/tickets.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def self.generate_ticket_granting_ticket(username, client, extra_attributes = {}
4040
end
4141
end
4242

43-
def generate_service_ticket(service, username, tgt, client)
43+
def self.generate_service_ticket(service, username, tgt, client)
4444
st = ServiceTicket.new
4545
st.ticket = "ST-" + Util.random_string
4646
st.service = service

spec/rubycas-server-core/tickets_spec.rb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module RubyCAS::Server::Core
44
describe RubyCAS::Server::Core::Tickets do
55
let(:client_hostname) { 'myhost.test' }
66
let(:username) { 'myuser' }
7+
let(:service) { 'https://myservice.test' }
78

89
before do
910
RubyCAS::Server::Core.setup("spec/config/config.yml")
@@ -62,35 +63,29 @@ module RubyCAS::Server::Core
6263
end
6364
end
6465

65-
describe "#generate_service_ticket(service, username, tgt)" do
66-
before do
67-
@username = 'testuser'
68-
@client_hostname = "myhost.test"
69-
@service = 'myservice.test'
70-
@tgt = @cas.generate_ticket_granting_ticket(@username, @client_hostname)
71-
@st = @cas.generate_service_ticket(@service, @username, @tgt, @client_hostname)
72-
end
66+
describe ".generate_service_ticket(service, username, tgt)" do
67+
let(:tgt) { Tickets.generate_ticket_granting_ticket(username, client_hostname) }
68+
let(:st) { Tickets.generate_service_ticket(service, username, tgt, client_hostname) }
7369

7470
it "should return a ServiceTicket" do
75-
@st.class.should == Tickets::ServiceTicket
71+
st.class.should == Tickets::ServiceTicket
7672
end
7773

7874
it "should not include the service identifer in the ticket string" do
79-
@st.ticket.should_not match /#{@service}/
75+
st.ticket.should_not match /#{service}/
8076
end
8177

8278
it "should not mark the ST as consumed" do
83-
@st.consumed.should be_nil
79+
st.consumed.should be_nil
8480
end
8581

8682
it "must generate a ticket that starts with 'ST-'" do
87-
@st.ticket.should match /^ST-/
83+
st.ticket.should match /^ST-/
8884
end
8985

9086
it "should assoicate the ST with the supplied TGT" do
91-
@st.ticket_granting_ticket.id.should == @tgt.id
87+
st.ticket_granting_ticket.id.should == tgt.id
9288
end
93-
9489
end
9590

9691
describe "#generate_proxy_ticket(target_service, pgt)" do

0 commit comments

Comments
 (0)