rubycas-client 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -4
- data/Gemfile.lock +16 -8
- data/History.txt +9 -2
- data/Rakefile +20 -14
- data/TODO.md +44 -0
- data/VERSION +1 -1
- data/lib/casclient/responses.rb +1 -3
- data/lib/casclient/tickets/storage/active_record_ticket_store.rb +1 -1
- data/lib/casclient/tickets/storage.rb +2 -2
- data/rubycas-client.gemspec +24 -17
- data/spec/casclient/frameworks/rails/filter_spec.rb +175 -0
- data/spec/casclient/validation_response_spec.rb +39 -0
- data/spec/spec_helper.rb +16 -0
- metadata +99 -122
- data/test/teststrap.rb +0 -10
- data/test/units/casclient/frameworks/rails/filter_test.rb +0 -184
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem "
|
5
|
-
gem "
|
4
|
+
gem "json", "~> 1.6.1"
|
5
|
+
gem "rspec", "~> 2.7.0"
|
6
6
|
gem "bundler", "~> 1.0.0"
|
7
7
|
gem "jeweler", "~> 1.6.2"
|
8
|
-
gem "rcov"
|
9
8
|
gem "actionpack"
|
9
|
+
gem "rake"
|
10
|
+
gem "rcov"
|
10
11
|
end
|
11
12
|
|
12
|
-
gem "activesupport"
|
13
|
+
gem "activesupport", :require => "active_support"
|
13
14
|
|
data/Gemfile.lock
CHANGED
@@ -5,17 +5,24 @@ GEM
|
|
5
5
|
activesupport (= 2.3.11)
|
6
6
|
rack (~> 1.1.0)
|
7
7
|
activesupport (2.3.11)
|
8
|
+
diff-lcs (1.1.3)
|
8
9
|
git (1.2.5)
|
9
|
-
jeweler (1.6.
|
10
|
+
jeweler (1.6.4)
|
10
11
|
bundler (~> 1.0)
|
11
12
|
git (>= 1.2.5)
|
12
13
|
rake
|
14
|
+
json (1.6.1)
|
13
15
|
rack (1.1.2)
|
14
|
-
rake (0.9.2)
|
15
|
-
rcov (0.9.
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
rake (0.9.2.2)
|
17
|
+
rcov (0.9.11)
|
18
|
+
rspec (2.7.0)
|
19
|
+
rspec-core (~> 2.7.0)
|
20
|
+
rspec-expectations (~> 2.7.0)
|
21
|
+
rspec-mocks (~> 2.7.0)
|
22
|
+
rspec-core (2.7.1)
|
23
|
+
rspec-expectations (2.7.0)
|
24
|
+
diff-lcs (~> 1.1.2)
|
25
|
+
rspec-mocks (2.7.0)
|
19
26
|
|
20
27
|
PLATFORMS
|
21
28
|
ruby
|
@@ -25,6 +32,7 @@ DEPENDENCIES
|
|
25
32
|
activesupport
|
26
33
|
bundler (~> 1.0.0)
|
27
34
|
jeweler (~> 1.6.2)
|
35
|
+
json (~> 1.6.1)
|
36
|
+
rake
|
28
37
|
rcov
|
29
|
-
|
30
|
-
rr
|
38
|
+
rspec (~> 2.7.0)
|
data/History.txt
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
= RubyCAS-Client Changelog
|
2
2
|
|
3
|
-
== Version 2.3.
|
3
|
+
== Version 2.3.2 :: 2011-11-11
|
4
|
+
|
5
|
+
* Bug Fixes
|
6
|
+
* Removed a puts that didn't get cleaned up
|
7
|
+
* Fix a bug with parsing extra attributes caused by a strange edge
|
8
|
+
case in active_support
|
9
|
+
|
10
|
+
== Version 2.3.1 :: 2011-10-22
|
4
11
|
|
5
12
|
* New Functionality
|
6
13
|
* Add configuration option to expect complex extra attributes to be encoded
|
@@ -33,7 +40,7 @@ See http://www.opensource.org/licenses/mit-license.php
|
|
33
40
|
|
34
41
|
* New functionality:
|
35
42
|
* Added config parameter force_ssl_verification (self explanatory) [Roberto Klein]
|
36
|
-
* Added explicit
|
43
|
+
* Added explicit SingleSigoutFilter for Rails (convenient?) [Adam Elliot]
|
37
44
|
* Added support for faking out the filter; useful when testing. See
|
38
45
|
http://github.com/gunark/rubycas-client/commit/1eb10cc285d59193eede3d4406f95cad9db9d93a
|
39
46
|
[Brian Hogan]
|
data/Rakefile
CHANGED
@@ -19,28 +19,34 @@ Jeweler::Tasks.new do |gem|
|
|
19
19
|
gem.summary = "Client library for the Central Authentication Service (CAS) protocol."
|
20
20
|
gem.authors = ["Matt Zukowski", "Matt Walker", "Matt Campbell"]
|
21
21
|
gem.rdoc_options = ['--main', 'README.rdoc']
|
22
|
-
gem.files.exclude '.rvmrc', '.infinity_test'
|
22
|
+
gem.files.exclude '.rvmrc', '.infinity_test', '.rbenv-version', '.rbenv-gemsets'
|
23
23
|
# dependencies defined in Gemfile
|
24
24
|
end
|
25
25
|
Jeweler::RubygemsDotOrgTasks.new
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
test.rcov_opts << '--exclude "gems/*"'
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
puts "Hiding rcov tasks because rcov is not available"
|
32
37
|
end
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
begin
|
40
|
+
require 'rspec/core/rake_task'
|
41
|
+
desc 'Run RSpecs to confirm that all functionality is working as expected'
|
42
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
43
|
+
t.pattern = 'spec/**/*_spec.rb'
|
44
|
+
end
|
45
|
+
task :default => :spec
|
46
|
+
rescue LoadError
|
47
|
+
puts "Hiding spec tasks because RSpec is not available"
|
40
48
|
end
|
41
49
|
|
42
|
-
task :default => :test
|
43
|
-
|
44
50
|
require 'rake/rdoctask'
|
45
51
|
Rake::RDocTask.new do |rdoc|
|
46
52
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
data/TODO.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Planned Changes
|
2
|
+
|
3
|
+
Also take a look at the [issues page](/rubycas/rubycas-client/issues)
|
4
|
+
|
5
|
+
## Version 2.4
|
6
|
+
|
7
|
+
1. Support for Ruby 1.9.3
|
8
|
+
1. Integration with travis for CI
|
9
|
+
1. Test against Rails 2.3
|
10
|
+
1. Test without Rails
|
11
|
+
1. Test against 1.8.7, 1.9.2, 1.9.3, jruby
|
12
|
+
|
13
|
+
## Version 3.0
|
14
|
+
|
15
|
+
1. Convert test cases from riot to rspec2 - Done!
|
16
|
+
1. Move Service Callback, PGT Callback and Single Sign Out Callback to
|
17
|
+
a Rack Middleware.
|
18
|
+
|
19
|
+
## Version 3.1
|
20
|
+
|
21
|
+
1. Cleanup the way Ticket Store integration works
|
22
|
+
1. Improve test coverage for CASClient::Client
|
23
|
+
1. Remove dependency on activesupport (expect in Rails specific classes)
|
24
|
+
1. Support for Rails 3.0 and 3.1
|
25
|
+
|
26
|
+
## Future
|
27
|
+
|
28
|
+
1. Support for other Rubies (JRuby, Rubinius, etc.)
|
29
|
+
1. Support for Rails 3.2
|
30
|
+
|
31
|
+
# Documentation Needs
|
32
|
+
|
33
|
+
## Improve/Rewrite Documentation
|
34
|
+
|
35
|
+
The documentation isn't the clearest and is now a bit out of date. That
|
36
|
+
needs addressing
|
37
|
+
|
38
|
+
## Examples
|
39
|
+
|
40
|
+
We could use some new and/or improved examples for
|
41
|
+
|
42
|
+
1. Rails 2.3
|
43
|
+
1. Rails 3.x
|
44
|
+
1. Sinatra
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.2
|
data/lib/casclient/responses.rb
CHANGED
@@ -66,9 +66,7 @@ module CASClient
|
|
66
66
|
|
67
67
|
@extra_attributes = {}
|
68
68
|
@xml.elements.to_a('//cas:authenticationSuccess/cas:attributes/* | //cas:authenticationSuccess/*[local-name() != \'proxies\' and local-name() != \'proxyGrantingTicket\' and local-name() != \'user\' and local-name() != \'attributes\']').each do |el|
|
69
|
-
|
70
|
-
el.namespaces.each {|k,v| el.add_namespace(k,v)}
|
71
|
-
@extra_attributes.merge!(Hash.from_xml(el.to_s))
|
69
|
+
@extra_attributes.merge! el.name => el.text
|
72
70
|
end
|
73
71
|
|
74
72
|
# unserialize extra attributes
|
@@ -63,13 +63,13 @@ module CASClient
|
|
63
63
|
# worker processes have access to a shared file system.
|
64
64
|
#
|
65
65
|
# This ticket store takes the following config parameters
|
66
|
-
# :storage_dir - The directory to store data in. Defaults to
|
66
|
+
# :storage_dir - The directory to store data in. Defaults to Rails.root/tmp
|
67
67
|
# :service_session_lookup_dir - The directory to store Service Ticket/Session ID files in. Defaults to :storage_dir/sessions
|
68
68
|
# :pgt_store_path - The location to store the pgt PStore file. Defaults to :storage_dir/cas_pgt.pstore
|
69
69
|
class LocalDirTicketStore < AbstractTicketStore
|
70
70
|
require 'pstore'
|
71
71
|
|
72
|
-
DEFAULT_TMP_DIR = defined?(
|
72
|
+
DEFAULT_TMP_DIR = defined?(Rails.root) ? "#{Rails.root}/tmp" : "#{Dir.pwd}/tmp"
|
73
73
|
|
74
74
|
def initialize(config={})
|
75
75
|
config ||= {}
|
data/rubycas-client.gemspec
CHANGED
@@ -4,17 +4,19 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "2.3.
|
7
|
+
s.name = "rubycas-client"
|
8
|
+
s.version = "2.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Zukowski", "Matt Walker", "Matt Campbell"]
|
12
|
-
s.date =
|
12
|
+
s.date = "2011-11-11"
|
13
13
|
s.extra_rdoc_files = [
|
14
14
|
"LICENSE.txt",
|
15
15
|
"README.rdoc"
|
16
16
|
]
|
17
17
|
s.files = [
|
18
|
+
".rspec",
|
19
|
+
".travis.yml",
|
18
20
|
"CHANGELOG.txt",
|
19
21
|
"Gemfile",
|
20
22
|
"Gemfile.lock",
|
@@ -22,6 +24,7 @@ Gem::Specification.new do |s|
|
|
22
24
|
"LICENSE.txt",
|
23
25
|
"README.rdoc",
|
24
26
|
"Rakefile",
|
27
|
+
"TODO.md",
|
25
28
|
"VERSION",
|
26
29
|
"examples/rails/README",
|
27
30
|
"examples/rails/app/controllers/advanced_example_controller.rb",
|
@@ -60,44 +63,48 @@ Gem::Specification.new do |s|
|
|
60
63
|
"rails_generators/active_record_ticket_store/templates/README",
|
61
64
|
"rails_generators/active_record_ticket_store/templates/migration.rb",
|
62
65
|
"rubycas-client.gemspec",
|
63
|
-
"
|
64
|
-
"
|
66
|
+
"spec/casclient/frameworks/rails/filter_spec.rb",
|
67
|
+
"spec/casclient/validation_response_spec.rb",
|
68
|
+
"spec/spec_helper.rb"
|
65
69
|
]
|
66
|
-
s.homepage =
|
70
|
+
s.homepage = "http://github.com/rubycas/rubycas-client"
|
67
71
|
s.licenses = ["MIT"]
|
68
72
|
s.rdoc_options = ["--main", "README.rdoc"]
|
69
73
|
s.require_paths = ["lib"]
|
70
|
-
s.rubygems_version =
|
71
|
-
s.summary =
|
74
|
+
s.rubygems_version = "1.8.11"
|
75
|
+
s.summary = "Client library for the Central Authentication Service (CAS) protocol."
|
72
76
|
|
73
77
|
if s.respond_to? :specification_version then
|
74
78
|
s.specification_version = 3
|
75
79
|
|
76
80
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
77
81
|
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
78
|
-
s.add_development_dependency(%q<
|
79
|
-
s.add_development_dependency(%q<
|
82
|
+
s.add_development_dependency(%q<json>, ["~> 1.6.1"])
|
83
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.7.0"])
|
80
84
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
81
85
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
82
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
83
86
|
s.add_development_dependency(%q<actionpack>, [">= 0"])
|
87
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
88
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
84
89
|
else
|
85
90
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
86
|
-
s.add_dependency(%q<
|
87
|
-
s.add_dependency(%q<
|
91
|
+
s.add_dependency(%q<json>, ["~> 1.6.1"])
|
92
|
+
s.add_dependency(%q<rspec>, ["~> 2.7.0"])
|
88
93
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
89
94
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
90
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
91
95
|
s.add_dependency(%q<actionpack>, [">= 0"])
|
96
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
97
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
92
98
|
end
|
93
99
|
else
|
94
100
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
95
|
-
s.add_dependency(%q<
|
96
|
-
s.add_dependency(%q<
|
101
|
+
s.add_dependency(%q<json>, ["~> 1.6.1"])
|
102
|
+
s.add_dependency(%q<rspec>, ["~> 2.7.0"])
|
97
103
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
98
104
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
99
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
100
105
|
s.add_dependency(%q<actionpack>, [">= 0"])
|
106
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
107
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
101
108
|
end
|
102
109
|
end
|
103
110
|
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'casclient/frameworks/rails/filter'
|
4
|
+
|
5
|
+
describe CASClient::Frameworks::Rails::Filter do
|
6
|
+
|
7
|
+
def controller_with_session(request = nil, session={})
|
8
|
+
request ||= mock_post_request
|
9
|
+
controller = double("Controller")
|
10
|
+
controller.stub(:session) {session}
|
11
|
+
controller.stub(:request) {request}
|
12
|
+
controller.stub(:url_for) {"bogusurl"}
|
13
|
+
controller.stub(:params) {{:ticket => "bogusticket", :renew => false}}
|
14
|
+
controller
|
15
|
+
end
|
16
|
+
|
17
|
+
def mock_post_request
|
18
|
+
mock_request = ActionController::Request.new({})
|
19
|
+
mock_request.stub(:post?) {true}
|
20
|
+
mock_request
|
21
|
+
end
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
CASClient::Frameworks::Rails::Filter.configure(
|
25
|
+
:cas_base_url => 'http://test.local/',
|
26
|
+
:logger => double("Logger")
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#fake" do
|
31
|
+
subject { Hash.new }
|
32
|
+
context "faking user without attributes" do
|
33
|
+
before { CASClient::Frameworks::Rails::Filter.fake('tester@test.com') }
|
34
|
+
it 'should set the session user' do
|
35
|
+
CASClient::Frameworks::Rails::Filter.filter(controller_with_session(nil, subject))
|
36
|
+
subject.should eq({:cas_user => 'tester@test.com', :casfilteruser => 'tester@test.com'})
|
37
|
+
end
|
38
|
+
after { CASClient::Frameworks::Rails::Filter.fake(nil,nil) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "faking user with attributes" do
|
42
|
+
before { CASClient::Frameworks::Rails::Filter.fake('tester@test.com', {:test => 'stuff', :this => 'that'}) }
|
43
|
+
it 'should set the session user and attributes' do
|
44
|
+
CASClient::Frameworks::Rails::Filter.filter(controller_with_session(nil, subject))
|
45
|
+
subject.should eq({ :cas_user => 'tester@test.com', :casfilteruser => 'tester@test.com', :cas_extra_attributes => {:test => 'stuff', :this => 'that' }})
|
46
|
+
end
|
47
|
+
after { CASClient::Frameworks::Rails::Filter.fake(nil,nil) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "new valid service ticket" do
|
52
|
+
it "should return successfully from filter" do
|
53
|
+
|
54
|
+
pgt = CASClient::ProxyGrantingTicket.new(
|
55
|
+
"PGT-1308586001r9573FAD5A8C62E134A4AA93273F226BD3F0C3A983DCCCD176",
|
56
|
+
"PGTIOU-1308586001r29DC1F852C95930FE6694C1EFC64232A3359798893BC0B")
|
57
|
+
|
58
|
+
raw_text = "<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">
|
59
|
+
<cas:authenticationSuccess>
|
60
|
+
<cas:user>rich.yarger@vibes.com</cas:user>
|
61
|
+
<cas:proxyGrantingTicket>PGTIOU-1308586001r29DC1F852C95930FE6694C1EFC64232A3359798893BC0B</cas:proxyGrantingTicket>
|
62
|
+
</cas:authenticationSuccess>
|
63
|
+
</cas:serviceResponse>"
|
64
|
+
response = CASClient::ValidationResponse.new(raw_text)
|
65
|
+
|
66
|
+
CASClient::Client.any_instance.stub(:request_cas_response).and_return(response)
|
67
|
+
CASClient::Client.any_instance.stub(:retrieve_proxy_granting_ticket).and_return(pgt)
|
68
|
+
|
69
|
+
controller = controller_with_session()
|
70
|
+
CASClient::Frameworks::Rails::Filter.filter(controller).should eq(true)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "new invalid service ticket" do
|
75
|
+
it "should return failure from filter" do
|
76
|
+
|
77
|
+
raw_text = "<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">
|
78
|
+
<cas:authenticationFailure>Some Error Text</cas:authenticationFailure>
|
79
|
+
</cas:serviceResponse>"
|
80
|
+
response = CASClient::ValidationResponse.new(raw_text)
|
81
|
+
|
82
|
+
CASClient::Client.any_instance.stub(:request_cas_response).and_return(response)
|
83
|
+
CASClient::Frameworks::Rails::Filter.stub(:unauthorized!) {"bogusresponse"}
|
84
|
+
|
85
|
+
controller = controller_with_session()
|
86
|
+
CASClient::Frameworks::Rails::Filter.filter(controller).should eq(false)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "does not have new input service ticket" do
|
91
|
+
context "with last service ticket" do
|
92
|
+
it "should return failure from filter" do
|
93
|
+
|
94
|
+
CASClient::Frameworks::Rails::Filter.stub(:unauthorized!) {"bogusresponse"}
|
95
|
+
|
96
|
+
controller = controller_with_session()
|
97
|
+
controller.stub(:params) {{}}
|
98
|
+
CASClient::Frameworks::Rails::Filter.filter(controller).should eq(false)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "sent through gateway" do
|
103
|
+
context "gatewaying off" do
|
104
|
+
it "should return failure from filter" do
|
105
|
+
|
106
|
+
CASClient::Frameworks::Rails::Filter.stub(:unauthorized!) {"bogusresponse"}
|
107
|
+
|
108
|
+
CASClient::Frameworks::Rails::Filter.config[:use_gatewaying] = false
|
109
|
+
controller = controller_with_session()
|
110
|
+
controller.session[:cas_sent_to_gateway] = true
|
111
|
+
controller.stub(:params) {{}}
|
112
|
+
CASClient::Frameworks::Rails::Filter.filter(controller).should eq(false)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "gatewaying on" do
|
117
|
+
it "should return failure from filter" do
|
118
|
+
|
119
|
+
CASClient::Frameworks::Rails::Filter.config[:use_gatewaying] = true
|
120
|
+
controller = controller_with_session()
|
121
|
+
controller.session[:cas_sent_to_gateway] = true
|
122
|
+
controller.stub(:params) {{}}
|
123
|
+
CASClient::Frameworks::Rails::Filter.filter(controller).should eq(true)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "has new input service ticket" do
|
130
|
+
context "no PGT" do
|
131
|
+
it "should return failure from filter" do
|
132
|
+
|
133
|
+
raw_text = "<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">
|
134
|
+
<cas:authenticationSuccess>
|
135
|
+
<cas:user>rich.yarger@vibes.com</cas:user>
|
136
|
+
<cas:proxyGrantingTicket>PGTIOU-1308586001r29DC1F852C95930FE6694C1EFC64232A3359798893BC0B</cas:proxyGrantingTicket>
|
137
|
+
</cas:authenticationSuccess>
|
138
|
+
</cas:serviceResponse>"
|
139
|
+
response = CASClient::ValidationResponse.new(raw_text)
|
140
|
+
|
141
|
+
CASClient::Client.any_instance.stub(:request_cas_response).and_return(response)
|
142
|
+
CASClient::Client.any_instance.stub(:retrieve_proxy_granting_ticket).and_raise CASClient::CASException
|
143
|
+
|
144
|
+
controller = controller_with_session()
|
145
|
+
expect { CASClient::Frameworks::Rails::Filter.filter(controller) }.to raise_error(CASClient::CASException)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "cannot connect to CASServer" do
|
150
|
+
it "should return failure from filter" do
|
151
|
+
|
152
|
+
CASClient::Client.any_instance.stub(:request_cas_response).and_raise "Some exception"
|
153
|
+
|
154
|
+
controller = controller_with_session()
|
155
|
+
expect { CASClient::Frameworks::Rails::Filter.filter(controller) }.to raise_error(RuntimeError)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "matches existing service ticket" do
|
160
|
+
subject { Hash.new }
|
161
|
+
it "should return successfully from filter" do
|
162
|
+
|
163
|
+
mock_client = CASClient::Client.new()
|
164
|
+
mock_client.should_receive(:request_cas_response).at_most(0).times
|
165
|
+
mock_client.should_receive(:retrieve_proxy_granting_ticket).at_most(0).times
|
166
|
+
CASClient::Frameworks::Rails::Filter.send(:class_variable_set, :@@client, mock_client)
|
167
|
+
|
168
|
+
subject[:cas_last_valid_ticket] = 'bogusticket'
|
169
|
+
subject[:cas_last_valid_ticket_service] = 'bogusurl'
|
170
|
+
controller = controller_with_session(mock_post_request(), subject)
|
171
|
+
CASClient::Frameworks::Rails::Filter.filter(controller).should eq(true)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'casclient/responses.rb'
|
3
|
+
|
4
|
+
describe CASClient::ValidationResponse do
|
5
|
+
context "when parsing extra attributes as JSON" do
|
6
|
+
let(:response_text) do
|
7
|
+
<<RESPONSE_TEXT
|
8
|
+
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
|
9
|
+
<cas:authenticationSuccess>
|
10
|
+
<cas:attributes>
|
11
|
+
<cas:first_name>Jack</cas:first_name>
|
12
|
+
<cas:mobile_phone></cas:mobile_phone>
|
13
|
+
<cas:global_roles><![CDATA[]]></cas:global_roles>
|
14
|
+
<cas:foo_data><![CDATA[{ foo: "bar" }]]></cas:foo_data>
|
15
|
+
</cas:attributes>
|
16
|
+
</cas:authenticationSuccess>
|
17
|
+
</cas:serviceResponse>
|
18
|
+
RESPONSE_TEXT
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:subject) { CASClient::ValidationResponse.new response_text, :encode_extra_attributes_as => :json }
|
22
|
+
|
23
|
+
it "sets the value of non-CDATA escaped empty attribute to nil" do
|
24
|
+
subject.extra_attributes["mobile_phone"].should be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets the value of CDATA escaped empty attribute to nil" do
|
28
|
+
subject.extra_attributes["global_roles"].should be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "sets the value of literal attributes to their value" do
|
32
|
+
subject.extra_attributes["first_name"].should == "Jack"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "sets the value of JSON attributes to their parsed value" do
|
36
|
+
subject.extra_attributes["foo_data"]["foo"].should == "bar"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
Bundler.setup(:default, :test)
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
#config.include Rack::Test::Methods
|
8
|
+
#config.include Webrat::Methods
|
9
|
+
#config.include Webrat::Matchers
|
10
|
+
#config.include TestHelpers
|
11
|
+
#config.include Helpers
|
12
|
+
config.mock_with :rspec
|
13
|
+
config.mock_framework = :rspec
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'rubycas-client'
|
metadata
CHANGED
@@ -1,136 +1,116 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycas-client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 2.3.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Matt Zukowski
|
14
9
|
- Matt Walker
|
15
10
|
- Matt Campbell
|
16
11
|
autorequire:
|
17
12
|
bindir: bin
|
18
13
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Dependency
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
32
|
-
version_requirements: *id001
|
14
|
+
date: 2011-11-11 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
33
17
|
name: activesupport
|
34
|
-
|
35
|
-
type: :runtime
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &70128146526380 !ruby/object:Gem::Requirement
|
38
19
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
- 0
|
45
|
-
version: "0"
|
46
|
-
version_requirements: *id002
|
47
|
-
name: riot
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :runtime
|
48
25
|
prerelease: false
|
49
|
-
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
|
26
|
+
version_requirements: *70128146526380
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: &70128146525800 !ruby/object:Gem::Requirement
|
52
30
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
- 0
|
59
|
-
version: "0"
|
60
|
-
version_requirements: *id003
|
61
|
-
name: rr
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.6.1
|
35
|
+
type: :development
|
62
36
|
prerelease: false
|
37
|
+
version_requirements: *70128146525800
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
requirement: &70128146525180 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.7.0
|
63
46
|
type: :development
|
64
|
-
|
65
|
-
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *70128146525180
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
requirement: &70128146524640 !ruby/object:Gem::Requirement
|
66
52
|
none: false
|
67
|
-
requirements:
|
53
|
+
requirements:
|
68
54
|
- - ~>
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
hash: 23
|
71
|
-
segments:
|
72
|
-
- 1
|
73
|
-
- 0
|
74
|
-
- 0
|
55
|
+
- !ruby/object:Gem::Version
|
75
56
|
version: 1.0.0
|
76
|
-
version_requirements: *id004
|
77
|
-
name: bundler
|
78
|
-
prerelease: false
|
79
57
|
type: :development
|
80
|
-
|
81
|
-
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *70128146524640
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: jeweler
|
62
|
+
requirement: &70128146524100 !ruby/object:Gem::Requirement
|
82
63
|
none: false
|
83
|
-
requirements:
|
64
|
+
requirements:
|
84
65
|
- - ~>
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
hash: 11
|
87
|
-
segments:
|
88
|
-
- 1
|
89
|
-
- 6
|
90
|
-
- 2
|
66
|
+
- !ruby/object:Gem::Version
|
91
67
|
version: 1.6.2
|
92
|
-
version_requirements: *id005
|
93
|
-
name: jeweler
|
94
|
-
prerelease: false
|
95
68
|
type: :development
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
hash: 3
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
version: "0"
|
106
|
-
version_requirements: *id006
|
107
|
-
name: rcov
|
108
69
|
prerelease: false
|
70
|
+
version_requirements: *70128146524100
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: actionpack
|
73
|
+
requirement: &70128146523500 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
109
79
|
type: :development
|
110
|
-
|
111
|
-
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *70128146523500
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rake
|
84
|
+
requirement: &70128146522900 !ruby/object:Gem::Requirement
|
112
85
|
none: false
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
|
117
|
-
|
118
|
-
- 0
|
119
|
-
version: "0"
|
120
|
-
version_requirements: *id007
|
121
|
-
name: actionpack
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
122
91
|
prerelease: false
|
92
|
+
version_requirements: *70128146522900
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rcov
|
95
|
+
requirement: &70128146522320 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
123
101
|
type: :development
|
102
|
+
prerelease: false
|
103
|
+
version_requirements: *70128146522320
|
124
104
|
description:
|
125
105
|
email:
|
126
106
|
executables: []
|
127
|
-
|
128
107
|
extensions: []
|
129
|
-
|
130
|
-
extra_rdoc_files:
|
108
|
+
extra_rdoc_files:
|
131
109
|
- LICENSE.txt
|
132
110
|
- README.rdoc
|
133
|
-
files:
|
111
|
+
files:
|
112
|
+
- .rspec
|
113
|
+
- .travis.yml
|
134
114
|
- CHANGELOG.txt
|
135
115
|
- Gemfile
|
136
116
|
- Gemfile.lock
|
@@ -138,6 +118,7 @@ files:
|
|
138
118
|
- LICENSE.txt
|
139
119
|
- README.rdoc
|
140
120
|
- Rakefile
|
121
|
+
- TODO.md
|
141
122
|
- VERSION
|
142
123
|
- examples/rails/README
|
143
124
|
- examples/rails/app/controllers/advanced_example_controller.rb
|
@@ -176,41 +157,37 @@ files:
|
|
176
157
|
- rails_generators/active_record_ticket_store/templates/README
|
177
158
|
- rails_generators/active_record_ticket_store/templates/migration.rb
|
178
159
|
- rubycas-client.gemspec
|
179
|
-
-
|
180
|
-
-
|
160
|
+
- spec/casclient/frameworks/rails/filter_spec.rb
|
161
|
+
- spec/casclient/validation_response_spec.rb
|
162
|
+
- spec/spec_helper.rb
|
181
163
|
homepage: http://github.com/rubycas/rubycas-client
|
182
|
-
licenses:
|
164
|
+
licenses:
|
183
165
|
- MIT
|
184
166
|
post_install_message:
|
185
|
-
rdoc_options:
|
167
|
+
rdoc_options:
|
186
168
|
- --main
|
187
169
|
- README.rdoc
|
188
|
-
require_paths:
|
170
|
+
require_paths:
|
189
171
|
- lib
|
190
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
191
173
|
none: false
|
192
|
-
requirements:
|
193
|
-
- -
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
|
196
|
-
segments:
|
174
|
+
requirements:
|
175
|
+
- - ! '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
segments:
|
197
179
|
- 0
|
198
|
-
|
199
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
hash: 631183831459328070
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
182
|
none: false
|
201
|
-
requirements:
|
202
|
-
- -
|
203
|
-
- !ruby/object:Gem::Version
|
204
|
-
|
205
|
-
segments:
|
206
|
-
- 0
|
207
|
-
version: "0"
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
208
187
|
requirements: []
|
209
|
-
|
210
188
|
rubyforge_project:
|
211
|
-
rubygems_version: 1.
|
189
|
+
rubygems_version: 1.8.11
|
212
190
|
signing_key:
|
213
191
|
specification_version: 3
|
214
192
|
summary: Client library for the Central Authentication Service (CAS) protocol.
|
215
193
|
test_files: []
|
216
|
-
|
data/test/teststrap.rb
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
require 'teststrap'
|
2
|
-
require 'casclient/frameworks/rails/filter'
|
3
|
-
require 'action_controller'
|
4
|
-
|
5
|
-
context CASClient::Frameworks::Rails::Filter do
|
6
|
-
|
7
|
-
helper(:controller_with_session) do |session, request|
|
8
|
-
controller = Object.new
|
9
|
-
stub(controller).session {session}
|
10
|
-
stub(controller).request {request}
|
11
|
-
stub(controller).url_for {"bogusurl"}
|
12
|
-
stub(controller).params {{:ticket => "bogusticket", :renew => false}}
|
13
|
-
controller
|
14
|
-
end
|
15
|
-
|
16
|
-
setup do
|
17
|
-
CASClient::Frameworks::Rails::Filter.configure(
|
18
|
-
:cas_base_url => 'http://test.local/',
|
19
|
-
:logger => stub!
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
context "fake user without attributes" do
|
24
|
-
setup { CASClient::Frameworks::Rails::Filter.fake('tester@test.com') }
|
25
|
-
should 'set the session user on #filter' do
|
26
|
-
setup { Hash.new }
|
27
|
-
CASClient::Frameworks::Rails::Filter.filter(controller_with_session(topic,nil))
|
28
|
-
topic
|
29
|
-
end.equals :cas_user => 'tester@test.com', :casfilteruser => 'tester@test.com'
|
30
|
-
teardown { CASClient::Frameworks::Rails::Filter.fake(nil,nil) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context "fake user with attributes" do
|
34
|
-
setup { CASClient::Frameworks::Rails::Filter.fake('tester@test.com', {:test => 'stuff', :this => 'that'}) }
|
35
|
-
should 'set the session user and attributes on #filter' do
|
36
|
-
setup { Hash.new }
|
37
|
-
CASClient::Frameworks::Rails::Filter.filter(controller_with_session(topic,nil))
|
38
|
-
topic
|
39
|
-
end.equals :cas_user => 'tester@test.com', :casfilteruser => 'tester@test.com', :cas_extra_attributes => {:test => 'stuff', :this => 'that' }
|
40
|
-
teardown { CASClient::Frameworks::Rails::Filter.fake(nil,nil) }
|
41
|
-
end
|
42
|
-
|
43
|
-
context "new service ticket successfully" do
|
44
|
-
should("return successfully from filter") do
|
45
|
-
setup { Hash.new }
|
46
|
-
mock_request = ActionController::Request.new({})
|
47
|
-
mock(mock_request).post? {true}
|
48
|
-
|
49
|
-
pgt = CASClient::ProxyGrantingTicket.new(
|
50
|
-
"PGT-1308586001r9573FAD5A8C62E134A4AA93273F226BD3F0C3A983DCCCD176",
|
51
|
-
"PGTIOU-1308586001r29DC1F852C95930FE6694C1EFC64232A3359798893BC0B")
|
52
|
-
|
53
|
-
raw_text = "<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">
|
54
|
-
<cas:authenticationSuccess>
|
55
|
-
<cas:user>rich.yarger@vibes.com</cas:user>
|
56
|
-
<cas:proxyGrantingTicket>PGTIOU-1308586001r29DC1F852C95930FE6694C1EFC64232A3359798893BC0B</cas:proxyGrantingTicket>
|
57
|
-
</cas:authenticationSuccess>
|
58
|
-
</cas:serviceResponse>"
|
59
|
-
response = CASClient::ValidationResponse.new(raw_text)
|
60
|
-
|
61
|
-
any_instance_of(CASClient::Client, :request_cas_response => response)
|
62
|
-
any_instance_of(CASClient::Client, :retrieve_proxy_granting_ticket => pgt)
|
63
|
-
|
64
|
-
controller = controller_with_session(topic,mock_request)
|
65
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
66
|
-
end.equals(true)
|
67
|
-
end
|
68
|
-
|
69
|
-
context "new service ticket with invalid service ticket" do
|
70
|
-
should("return failure from filter") do
|
71
|
-
setup { Hash.new }
|
72
|
-
mock_request = ActionController::Request.new({})
|
73
|
-
mock(mock_request).post? {true}
|
74
|
-
|
75
|
-
raw_text = "<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">
|
76
|
-
<cas:authenticationFailure>Some Error Text</cas:authenticationFailure>
|
77
|
-
</cas:serviceResponse>"
|
78
|
-
response = CASClient::ValidationResponse.new(raw_text)
|
79
|
-
|
80
|
-
any_instance_of(CASClient::Client, :request_cas_response => response)
|
81
|
-
stub(CASClient::Frameworks::Rails::Filter).unauthorized!{"bogusresponse"}
|
82
|
-
|
83
|
-
controller = controller_with_session(topic,mock_request)
|
84
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
85
|
-
end.equals(false)
|
86
|
-
end
|
87
|
-
|
88
|
-
context "no new service ticket but with last service ticket" do
|
89
|
-
should("return failure from filter") do
|
90
|
-
setup { Hash.new }
|
91
|
-
mock_request = ActionController::Request.new({})
|
92
|
-
mock(mock_request).post? {true}
|
93
|
-
|
94
|
-
stub(CASClient::Frameworks::Rails::Filter).unauthorized!{"bogusresponse"}
|
95
|
-
|
96
|
-
controller = controller_with_session(topic,mock_request)
|
97
|
-
stub(controller).params {{}}
|
98
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
99
|
-
end.equals(false)
|
100
|
-
end
|
101
|
-
|
102
|
-
context "no new service ticket sent through gateway, gatewaying off" do
|
103
|
-
should("return failure from filter") do
|
104
|
-
setup { Hash.new }
|
105
|
-
mock_request = ActionController::Request.new({})
|
106
|
-
mock(mock_request).post? {true}
|
107
|
-
|
108
|
-
stub(CASClient::Frameworks::Rails::Filter).unauthorized!{"bogusresponse"}
|
109
|
-
|
110
|
-
CASClient::Frameworks::Rails::Filter.config[:use_gatewaying] = false
|
111
|
-
controller = controller_with_session(topic,mock_request)
|
112
|
-
controller.session[:cas_sent_to_gateway] = true
|
113
|
-
stub(controller).params {{}}
|
114
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
115
|
-
end.equals(false)
|
116
|
-
end
|
117
|
-
|
118
|
-
context "no new service ticket sent through gateway, gatewaying on" do
|
119
|
-
should("return failure from filter") do
|
120
|
-
setup { Hash.new }
|
121
|
-
mock_request = ActionController::Request.new({})
|
122
|
-
mock(mock_request).post? {true}
|
123
|
-
|
124
|
-
CASClient::Frameworks::Rails::Filter.config[:use_gatewaying] = true
|
125
|
-
controller = controller_with_session(topic,mock_request)
|
126
|
-
controller.session[:cas_sent_to_gateway] = true
|
127
|
-
stub(controller).params {{}}
|
128
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
129
|
-
end.equals(true)
|
130
|
-
end
|
131
|
-
|
132
|
-
context "new service ticket with no PGT" do
|
133
|
-
should("return failure from filter") do
|
134
|
-
setup { Hash.new }
|
135
|
-
mock_request = ActionController::Request.new({})
|
136
|
-
mock(mock_request).post? {true}
|
137
|
-
|
138
|
-
raw_text = "<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">
|
139
|
-
<cas:authenticationSuccess>
|
140
|
-
<cas:user>rich.yarger@vibes.com</cas:user>
|
141
|
-
<cas:proxyGrantingTicket>PGTIOU-1308586001r29DC1F852C95930FE6694C1EFC64232A3359798893BC0B</cas:proxyGrantingTicket>
|
142
|
-
</cas:authenticationSuccess>
|
143
|
-
</cas:serviceResponse>"
|
144
|
-
response = CASClient::ValidationResponse.new(raw_text)
|
145
|
-
|
146
|
-
any_instance_of(CASClient::Client, :request_cas_response => response)
|
147
|
-
any_instance_of(CASClient::Client, :retrieve_proxy_granting_ticket => lambda{raise CASClient::CASException})
|
148
|
-
|
149
|
-
controller = controller_with_session(topic,mock_request)
|
150
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
151
|
-
end.raises(CASClient::CASException)
|
152
|
-
end
|
153
|
-
|
154
|
-
context "new service ticket, but cannot connect to CASServer" do
|
155
|
-
should("return failure from filter") do
|
156
|
-
setup { Hash.new }
|
157
|
-
mock_request = ActionController::Request.new({})
|
158
|
-
mock(mock_request).post? {true}
|
159
|
-
|
160
|
-
any_instance_of(CASClient::Client, :request_cas_response => lambda{raise "Some exception"})
|
161
|
-
|
162
|
-
controller = controller_with_session(topic,mock_request)
|
163
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
164
|
-
end.raises(RuntimeError)
|
165
|
-
end
|
166
|
-
|
167
|
-
context "reuse service ticket successfully" do
|
168
|
-
should("return successfully from filter") do
|
169
|
-
setup { Hash.new }
|
170
|
-
mock_request = ActionController::Request.new({})
|
171
|
-
mock(mock_request).post? {true}
|
172
|
-
|
173
|
-
mock_client = CASClient::Client.new()
|
174
|
-
mock(mock_client).request_cas_response().never
|
175
|
-
mock(mock_client).retrieve_proxy_granting_ticket().never
|
176
|
-
CASClient::Frameworks::Rails::Filter.send(:class_variable_set, :@@client, mock_client)
|
177
|
-
|
178
|
-
topic[:cas_last_valid_ticket] = 'bogusticket'
|
179
|
-
topic[:cas_last_valid_ticket_service] = 'bogusurl'
|
180
|
-
controller = controller_with_session(topic,mock_request)
|
181
|
-
CASClient::Frameworks::Rails::Filter.filter(controller)
|
182
|
-
end.equals(true)
|
183
|
-
end
|
184
|
-
end
|