bcms_cas 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYRIGHT.txt +23 -0
- data/GPL.txt +674 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +165 -0
- data/README.markdown +29 -34
- data/app/controllers/application_controller.rb +3 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/portlets/helpers/login_portlet_helper.rb +3 -0
- data/app/views/portlets/login/render.html.erb +17 -0
- data/lib/bcms_cas/acts_as_content_page_extention.rb +0 -1
- data/lib/bcms_cas/authentication.rb +8 -2
- data/lib/bcms_cas/engine.rb +57 -0
- data/lib/bcms_cas/routes.rb +1 -3
- data/lib/bcms_cas/version.rb +3 -0
- data/lib/bcms_cas.rb +2 -4
- data/lib/generators/bcms_cas/install/USAGE +10 -0
- data/lib/generators/bcms_cas/install/install_generator.rb +15 -0
- data/lib/generators/bcms_cas/install/templates/bcms_cas.seeds.rb +4 -0
- data/{rails_generators/bcms_cas → lib/generators/bcms_cas/install}/templates/initializer.rb +0 -0
- data/{rails_generators/bcms_cas → lib/generators/bcms_cas/install}/templates/login_portlet_helper.rb +0 -0
- data/{rails_generators/bcms_cas → lib/generators/bcms_cas/install}/templates/render.html.erb +0 -0
- data/test/performance/browsing_test.rb +2 -2
- data/test/test_helper.rb +4 -27
- data/test/unit/cas/cas_authentication_test.rb +9 -2
- metadata +64 -73
- data/db/migrate/20091002162550_add_cas_user_group.rb +0 -9
- data/rails/init.rb +0 -6
- data/rails_generators/bcms_cas/bcms_cas_generator.rb +0 -16
data/LICENSE.txt
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.markdown
CHANGED
@@ -1,65 +1,60 @@
|
|
1
1
|
# Central Authentication Server Module
|
2
2
|
|
3
|
-
This module allows BrowserCMS to integrate with a Central Authentication Server (CAS) to allow users to log in to a BrowserCMS site,
|
4
|
-
using credentials stored in an external system. This module requires an existing CAS server to be running (See http://code.google.com/p/rubycas-server/)
|
5
|
-
as an example of a server.
|
3
|
+
This module allows BrowserCMS to integrate with a Central Authentication Server (CAS) to allow users to log in to a BrowserCMS site, using credentials stored in an external system. This module requires an existing CAS server to be running (See http://code.google.com/p/rubycas-server/) as an example of a server.
|
6
4
|
|
7
|
-
This module will allow user to login to the public area of the CMS, using the Login Form Portlet. It does not handle users that need to
|
8
|
-
|
5
|
+
This module will allow user to login to the public area of the CMS, using the Login Form Portlet. It does not handle users that need to log into the CMS administrative area. It also handles single logout by redirecting the user to cas /logout service.
|
6
|
+
|
7
|
+
## Installation Instructions
|
9
8
|
|
10
|
-
## A. Instructions
|
11
9
|
Here are the necessary steps to install this module.
|
12
10
|
|
13
|
-
1.
|
14
|
-
2.
|
15
|
-
3.
|
16
|
-
4.
|
17
|
-
|
11
|
+
1. Install the bcms_cas module, and configure it to point to your CAS server (see B below).
|
12
|
+
2. Configure your CAS server and test that you can login directly via their /login page.
|
13
|
+
3. Migrate the database to add the CAS Group
|
14
|
+
4. Create a Login Form to submit to the CAS server.
|
15
|
+
|
16
|
+
## 1. Installing the Module
|
17
|
+
|
18
|
+
Install the module by running the following command in your project.
|
19
|
+
|
20
|
+
$ rails g cms:install bcms_cas
|
21
|
+
$ rake db:seed
|
18
22
|
|
19
|
-
|
20
|
-
This project depends on RubyCAS-client (http://code.google.com/p/rubycas-client/). RubyCAS-Client is a standard Rails PluginGem, and the instructions
|
21
|
-
for installing in into a Rails project can be found on their website. The following command will probably work though:
|
23
|
+
This should install the bcms_cas gem along with all its dependencies. The db:seed will add a new group to the CMS
|
22
24
|
|
23
|
-
|
25
|
+
See http://www.browsercms.org/doc/guides/html/installing_modules.html for more information on how to install modules generally.
|
24
26
|
|
25
|
-
|
26
|
-
make any configuration changes in your rails project.
|
27
|
+
## 2. Configure the CAS server
|
27
28
|
|
28
|
-
|
29
|
-
To install a BrowserCMS module see the following instructions http://www.browsercms.org/doc/guides/html/installing_modules.html . After you add the gem to your
|
30
|
-
environment.rb, run the following command to generate the necessary configuration files.
|
29
|
+
Edit the config/environments/development.rb file to include the following:
|
31
30
|
|
32
|
-
|
31
|
+
config.bcms_cas_server = "https://cas.some-domain.com"
|
32
|
+
|
33
|
+
If you are using the same cas server for each environment (development, production, testing) you can configure this once in the config/application.rb, otherwise edit each environment file separate.
|
33
34
|
|
34
|
-
|
35
|
-
value to whatever domain name your cas server is located at. The file should look similar to this:
|
35
|
+
Go to your CAS domain and test that you can log in.
|
36
36
|
|
37
|
-
|
38
|
-
config.server_url = "https://cas.yourdomainname.com"
|
39
|
-
end
|
37
|
+
## 2a. Ensure SITE_DOMAIN is configured.
|
40
38
|
|
41
|
-
|
42
|
-
to allow redirects between the servers to happen correctly (it requires Absolute URLs).
|
39
|
+
Edit the production.rb to make sure your SITE_DOMAIN variable in production is correctly set to the right top level domain. This will be needed to allow redirects between the servers to happen correctly (it requires Absolute URLs).
|
43
40
|
|
44
41
|
SITE_DOMAIN="www.yourdomainname.com"
|
45
42
|
|
46
|
-
##
|
43
|
+
## 3. Configure the 'CAS Authenticated User' Group
|
47
44
|
When you run rake db:migrate, this module will add a new group to the CMS called 'CAS Authenticated Users'. All users that
|
48
45
|
log in successfully will be assigned to members of this group. You will potentially want to rename this group to something
|
49
46
|
that more accurately reflects who these users are (i.e. Members, Staff, etc) and then set which sections of the website this
|
50
47
|
group can visit.
|
51
48
|
|
52
|
-
##
|
49
|
+
## 4. Create a Login Form
|
53
50
|
|
54
|
-
Via the BrowserCMS UI, create a page and place a Login Form portlet on it. It should use the newly generated login view created by the bcms_cas generator. If
|
55
|
-
the module is configured correctly, then logging in should correctly establish a CAS session.
|
51
|
+
Via the BrowserCMS UI, create a page and place a Login Form portlet on it. It should use the newly generated login view created by the bcms_cas generator. If the module is configured correctly, then logging in should correctly establish a CAS session.
|
56
52
|
|
57
|
-
|
53
|
+
## Known Issues
|
58
54
|
|
59
55
|
* Every page is secured by the CASClient Gateway Filter, which means a lot of redirects. This is potentially a big performance hit, and would require modifying the filter so it only handles checking login_tickets, rather than redirects.
|
60
56
|
* A user logged in using CAS will be assigned to a single group. There is no way to map a user to different groups (i.e. Platnium or Gold Members). Could potentially be done via cas extra info.
|
61
57
|
* The internal CMS User database is bypassed/not used for login for front end pages. This means it would fail the cmsadmin user tried to login via the Login Form.
|
62
|
-
* [Low] LoginPortlet Form tag should pull from CAS automatically (requires changes to CMS core)
|
63
58
|
* [Low] username/login field is different between CMS and CAS (requires core changes)
|
64
59
|
* The CAS Login page has to be styled to match the look and feel of the site.
|
65
60
|
* If the user types in wrong username/pw on CMS login form, they will be left on the CAS Login page, with message.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% form_tag login_url_tag do %>
|
2
|
+
<%= login_ticket_tag %>
|
3
|
+
<%= service_url_tag %>
|
4
|
+
<p>
|
5
|
+
<%= label_tag :login %>
|
6
|
+
<%= text_field_tag :username, @login %>
|
7
|
+
</p>
|
8
|
+
<p>
|
9
|
+
<%= label_tag :password %>
|
10
|
+
<%= password_field_tag :password %>
|
11
|
+
</p>
|
12
|
+
<p>
|
13
|
+
<%= label_tag :remember_me %>
|
14
|
+
<%= check_box_tag :remember_me, '1', @remember_me %>
|
15
|
+
</p>
|
16
|
+
<p><%= submit_tag "Login" %></p>
|
17
|
+
<% end %>
|
@@ -16,6 +16,7 @@ module Cas
|
|
16
16
|
controller_class.skip_filter :check_access_to_page
|
17
17
|
controller_class.skip_filter :try_to_stream_file
|
18
18
|
|
19
|
+
controller_class.before_filter :verify_cas_configured
|
19
20
|
controller_class.before_filter CASClient::Frameworks::Rails::GatewayFilter
|
20
21
|
controller_class.before_filter :login_from_cas_ticket
|
21
22
|
controller_class.before_filter :try_to_stream_file
|
@@ -26,6 +27,13 @@ module Cas
|
|
26
27
|
# Each instance of the controller will gain these methods.
|
27
28
|
module InstanceMethods
|
28
29
|
|
30
|
+
# Provide a more helpful warning if developers forgot to configure the server correctly.
|
31
|
+
def verify_cas_configured
|
32
|
+
unless BcmsCas::Engine.configured?
|
33
|
+
BcmsCas::Engine.raise_configuration_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
# Attempts to set the current user based on the session attribute set by CAS.
|
30
38
|
def login_from_cas_ticket
|
31
39
|
logger.debug "Checking for cas login. The current_user is '#{@current_user.login}'." if @current_user
|
@@ -42,7 +50,6 @@ module Cas
|
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|
45
|
-
Cms::ContentController.send(:include, Cas::Authentication)
|
46
53
|
|
47
54
|
|
48
55
|
# Extends the core SessionController to properly destroy the local session on logout, and redirect to CAS for Single Log out.
|
@@ -61,5 +68,4 @@ module Cas
|
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
64
|
-
Cms::SessionsController.send(:include, Cas::SingleLogOut)
|
65
71
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'browsercms'
|
2
|
+
module BcmsCas
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
include Cms::Module
|
5
|
+
|
6
|
+
NOT_CONFIGURED = "https://localhost:3000/cas-not-configured"
|
7
|
+
|
8
|
+
# Delay loading until Rails and BrowserCMS app directory has been loaded
|
9
|
+
initializer 'bcms_cas.load_dependencies' do
|
10
|
+
require 'bcms_cas/configuration'
|
11
|
+
require 'bcms_cas/authentication'
|
12
|
+
require 'bcms_cas/login_portlet_extension'
|
13
|
+
require 'bcms_cas/acts_as_content_page_extention'
|
14
|
+
end
|
15
|
+
|
16
|
+
config.after_initialize do
|
17
|
+
CASClient::Frameworks::Rails::Filter.configure(
|
18
|
+
:cas_base_url => BcmsCas::Engine.cas_server,
|
19
|
+
:extra_attributes_session_key => :cas_extra_attributes
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
config.to_prepare do
|
24
|
+
Cms::ContentController.send(:include, Cas::Authentication)
|
25
|
+
Cms::SessionsController.send(:include, Cas::SingleLogOut)
|
26
|
+
Cms::Acts::ContentPage.send(:include, Cas::Acts::ContentPage)
|
27
|
+
|
28
|
+
Cms::ContentController.class_eval do
|
29
|
+
helper Cas::LoginPortlet
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.cas_server
|
34
|
+
if Rails.configuration.respond_to? :bcms_cas_server
|
35
|
+
Rails.configuration.bcms_cas_server
|
36
|
+
else
|
37
|
+
NOT_CONFIGURED
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.configured?
|
42
|
+
NOT_CONFIGURED != cas_server
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.raise_configuration_error
|
46
|
+
error_message = <<message
|
47
|
+
|
48
|
+
Configuration Issue: You must configure a CAS server for the bcms_cas module to work.
|
49
|
+
Add the following to 'config/environments/#{Rails.env}.rb'
|
50
|
+
|
51
|
+
config.bcms_cas_server = "https://cas.some-domain.com"
|
52
|
+
|
53
|
+
message
|
54
|
+
raise error_message
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/bcms_cas/routes.rb
CHANGED
data/lib/bcms_cas.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'cms/module_installation'
|
2
|
+
|
3
|
+
class BcmsCas::InstallGenerator < Cms::ModuleInstallation
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
def add_seeds
|
7
|
+
template "bcms_cas.seeds.rb", "db/bcms_cas.seeds.rb"
|
8
|
+
append_file "db/seeds.rb", "\nrequire File.expand_path('../bcms_cas.seeds.rb', __FILE__)\n"
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def override_login_form_template
|
13
|
+
template "render.html.erb", "app/views/portlets/login/render.html.erb"
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
data/{rails_generators/bcms_cas → lib/generators/bcms_cas/install}/templates/login_portlet_helper.rb
RENAMED
File without changes
|
data/{rails_generators/bcms_cas → lib/generators/bcms_cas/install}/templates/render.html.erb
RENAMED
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'performance_test_help'
|
2
|
+
require 'rails/performance_test_help'
|
3
3
|
|
4
4
|
# Profiling results for each test method are written to tmp/performance.
|
5
|
-
class BrowsingTest <
|
5
|
+
class BrowsingTest < ActionDispatch::PerformanceTest
|
6
6
|
def test_homepage
|
7
7
|
get '/'
|
8
8
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,33 +1,10 @@
|
|
1
1
|
ENV["RAILS_ENV"] = "test"
|
2
|
-
require File.expand_path(
|
3
|
-
require 'test_help'
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
4
|
|
5
|
-
|
6
|
-
# Transactional fixtures accelerate your tests by wrapping each test method
|
7
|
-
# in a transaction that's rolled back on completion. This ensures that the
|
8
|
-
# test database remains unchanged so your fixtures don't have to be reloaded
|
9
|
-
# between every test method. Fewer database queries means faster tests.
|
10
|
-
#
|
11
|
-
# Read Mike Clark's excellent walkthrough at
|
12
|
-
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
13
|
-
#
|
14
|
-
# Every Active Record database supports transactions except MyISAM tables
|
15
|
-
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
16
|
-
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
17
|
-
# is recommended.
|
18
|
-
#
|
19
|
-
# The only drawback to using transactional fixtures is when you actually
|
20
|
-
# need to test transactions. Since your test is bracketed by a transaction,
|
21
|
-
# any transactions started in your code will be automatically rolled back.
|
22
|
-
self.use_transactional_fixtures = true
|
23
|
-
|
24
|
-
# Instantiated fixtures are slow, but give you @david where otherwise you
|
25
|
-
# would need people(:david). If you don't want to migrate your existing
|
26
|
-
# test cases which use the @david style and don't mind the speed hit (each
|
27
|
-
# instantiated fixtures translates to a database query per test method),
|
28
|
-
# then set this back to true.
|
29
|
-
self.use_instantiated_fixtures = false
|
5
|
+
require 'mocha'
|
30
6
|
|
7
|
+
class ActiveSupport::TestCase
|
31
8
|
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
32
9
|
#
|
33
10
|
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
@@ -12,6 +12,13 @@ class MyController < ActionController::Base
|
|
12
12
|
{}
|
13
13
|
end
|
14
14
|
|
15
|
+
def session
|
16
|
+
unless @custom_session
|
17
|
+
@custom_session = {}
|
18
|
+
end
|
19
|
+
@custom_session
|
20
|
+
end
|
21
|
+
|
15
22
|
def destroy
|
16
23
|
"Exists only to be alias_method_chained"
|
17
24
|
end
|
@@ -22,7 +29,8 @@ class CasAuthTest < ActiveSupport::TestCase
|
|
22
29
|
def setup
|
23
30
|
MyController.expects(:skip_filter).with(:check_access_to_page)
|
24
31
|
MyController.expects(:skip_filter).with(:try_to_stream_file)
|
25
|
-
|
32
|
+
|
33
|
+
MyController.expects(:before_filter).with(:verify_cas_configured)
|
26
34
|
MyController.expects(:before_filter).with(CASClient::Frameworks::Rails::GatewayFilter)
|
27
35
|
MyController.expects(:before_filter).with(:login_from_cas_ticket)
|
28
36
|
MyController.expects(:before_filter).with(:try_to_stream_file)
|
@@ -48,7 +56,6 @@ class CasAuthTest < ActiveSupport::TestCase
|
|
48
56
|
|
49
57
|
test "login_from_cas_ticket will create and set the current user and User.current if a session attribute was found." do
|
50
58
|
c = MyController.new
|
51
|
-
c.session = {}
|
52
59
|
c.session[:cas_user] = "1234"
|
53
60
|
|
54
61
|
User.current = Group.find_by_code("guest")
|