bcms_cas 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +5 -7
- data/app/assets/javascripts/bcms_cas/application.js +15 -0
- data/app/assets/stylesheets/bcms_cas/application.css +13 -0
- data/app/controllers/bcms_cas/application_controller.rb +4 -0
- data/app/helpers/bcms_cas/application_helper.rb +4 -0
- data/app/models/cas_user.rb +1 -1
- data/config/routes.rb +2 -0
- data/db/bcms_cas.seeds.rb +4 -0
- data/lib/bcms_cas.rb +3 -3
- data/lib/bcms_cas/authentication.rb +3 -3
- data/lib/bcms_cas/utils.rb +1 -1
- data/lib/bcms_cas/version.rb +1 -1
- data/lib/tasks/bcms_cas_tasks.rake +4 -0
- data/test/bcms_cas_test.rb +7 -0
- data/test/test_helper.rb +10 -10
- data/test/unit/cas/cas_authentication_test.rb +56 -54
- data/test/unit/cas_user_test.rb +38 -36
- data/test/unit/cas_utils_test.rb +61 -59
- data/test/unit/cms/temporary_user_test.rb +56 -54
- metadata +23 -12
- data/app/controllers/application_controller.rb +0 -3
- data/app/helpers/application_helper.rb +0 -2
- data/test/performance/browsing_test.rb +0 -9
data/README.markdown
CHANGED
@@ -17,6 +17,7 @@ Here are the necessary steps to install this module.
|
|
17
17
|
|
18
18
|
Install the module by running the following command in your project.
|
19
19
|
|
20
|
+
$ gem install bcms_cas
|
20
21
|
$ rails g cms:install bcms_cas
|
21
22
|
$ rake db:seed
|
22
23
|
|
@@ -34,17 +35,14 @@ If you are using the same cas server for each environment (development, producti
|
|
34
35
|
|
35
36
|
Go to your CAS domain and test that you can log in.
|
36
37
|
|
37
|
-
## 2a. Ensure
|
38
|
+
## 2a. Ensure site_domain is configured.
|
38
39
|
|
39
|
-
Edit the production.rb to make sure your
|
40
|
+
Edit the production.rb to make sure your site_domain configuration 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).
|
40
41
|
|
41
|
-
|
42
|
+
config.cms.site_domain = "www.your_site_domiain.com"
|
42
43
|
|
43
44
|
## 3. Configure the 'CAS Authenticated User' Group
|
44
|
-
When you run rake db:migrate, this module will add a new group to the CMS called 'CAS Authenticated Users'. All users that
|
45
|
-
log in successfully will be assigned to members of this group. You will potentially want to rename this group to something
|
46
|
-
that more accurately reflects who these users are (i.e. Members, Staff, etc) and then set which sections of the website this
|
47
|
-
group can visit.
|
45
|
+
When you run rake db:migrate, this module will add a new group to the CMS called 'CAS Authenticated Users'. All users that log in successfully will be assigned to members of this group. You will potentially want to rename this group to something that more accurately reflects who these users are (i.e. Members, Staff, etc) and then set which sections of the website this group can visit.
|
48
46
|
|
49
47
|
## 4. Create a Login Form
|
50
48
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
data/app/models/cas_user.rb
CHANGED
@@ -19,6 +19,6 @@ class CasUser < Cms::TemporaryUser
|
|
19
19
|
# @deprecated
|
20
20
|
# This exists only for backwards compatibility for when this used to inherit from GuestUser. It should be removed in 1.2.
|
21
21
|
def group
|
22
|
-
Group.find_by_code(GROUP_NAME)
|
22
|
+
Cms::Group.find_by_code(GROUP_NAME)
|
23
23
|
end
|
24
24
|
end
|
data/config/routes.rb
ADDED
data/lib/bcms_cas.rb
CHANGED
@@ -19,7 +19,7 @@ module Cas
|
|
19
19
|
controller_class.before_filter :verify_cas_configured
|
20
20
|
controller_class.before_filter CASClient::Frameworks::Rails::GatewayFilter
|
21
21
|
controller_class.before_filter :login_from_cas_ticket
|
22
|
-
controller_class.before_filter :try_to_stream_file
|
22
|
+
controller_class.before_filter :try_to_stream_file
|
23
23
|
controller_class.before_filter :check_access_to_page
|
24
24
|
|
25
25
|
end
|
@@ -42,7 +42,7 @@ module Cas
|
|
42
42
|
|
43
43
|
# Having to set both of these feels very duplicative. Ideally I would like a way
|
44
44
|
# to set only once, but calling current_user= has side effects.
|
45
|
-
@current_user = User.current = user
|
45
|
+
@current_user = Cms::User.current = user
|
46
46
|
|
47
47
|
logger.debug "CasUser information found in session. Setting current_user as '#{user.login}" if @current_user
|
48
48
|
end
|
@@ -64,7 +64,7 @@ module Cas
|
|
64
64
|
def destroy_with_cas
|
65
65
|
logger.debug "Logging user out of both cms and CAS server."
|
66
66
|
logout_user
|
67
|
-
Cas::Utils.logout(self, "http://#{
|
67
|
+
Cas::Utils.logout(self, "http://#{Rails.application.config.cms.site_domain}/")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
data/lib/bcms_cas/utils.rb
CHANGED
data/lib/bcms_cas/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
1
2
|
ENV["RAILS_ENV"] = "test"
|
2
|
-
require File.expand_path('../../config/environment', __FILE__)
|
3
|
-
require 'rails/test_help'
|
4
3
|
|
5
|
-
require
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
6
|
|
7
|
-
|
8
|
-
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
9
|
-
#
|
10
|
-
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
11
|
-
# -- they do not yet inherit this setting
|
12
|
-
fixtures :all
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
13
8
|
|
14
|
-
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
15
|
end
|
@@ -24,88 +24,90 @@ class MyController < ActionController::Base
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
module Cms
|
28
|
+
class CasAuthTest < ActiveSupport::TestCase
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def setup
|
31
|
+
MyController.expects(:skip_filter).with(:check_access_to_page)
|
32
|
+
MyController.expects(:skip_filter).with(:try_to_stream_file)
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
MyController.expects(:before_filter).with(:verify_cas_configured)
|
35
|
+
MyController.expects(:before_filter).with(CASClient::Frameworks::Rails::GatewayFilter)
|
36
|
+
MyController.expects(:before_filter).with(:login_from_cas_ticket)
|
37
|
+
MyController.expects(:before_filter).with(:try_to_stream_file)
|
38
|
+
MyController.expects(:before_filter).with(:check_access_to_page)
|
38
39
|
|
39
|
-
|
40
|
+
MyController.send(:include, Cas::Authentication)
|
40
41
|
|
41
|
-
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
def teardown
|
45
|
+
User.current = nil
|
46
|
+
end
|
46
47
|
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
test "adds current_user and login from session to class" do
|
50
|
+
c = MyController.new
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
assert c.respond_to?(:current_user)
|
53
|
+
assert c.respond_to?(:login_from_cas_ticket)
|
53
54
|
|
54
|
-
|
55
|
+
end
|
55
56
|
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
test "login_from_cas_ticket will create and set the current user and User.current if a session attribute was found." do
|
59
|
+
c = MyController.new
|
60
|
+
c.session[:cas_user] = "1234"
|
60
61
|
|
61
|
-
|
62
|
+
User.current = Group.find_by_code("guest")
|
62
63
|
|
63
|
-
|
64
|
+
c.login_from_cas_ticket
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
current_user = c.get_at_current_user
|
67
|
+
assert_equal CasUser, current_user.class
|
68
|
+
assert_equal "1234", current_user.login
|
69
|
+
assert_equal current_user, User.current
|
70
|
+
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
test "Cms::ContentController gets augmented" do
|
73
|
+
assert (Cms::ContentController.new.respond_to? :login_from_cas_ticket)
|
74
|
+
end
|
74
75
|
|
75
|
-
end
|
76
|
+
end
|
76
77
|
|
77
|
-
class CasSessionControllerTest < ActiveSupport::TestCase
|
78
|
+
class CasSessionControllerTest < ActiveSupport::TestCase
|
78
79
|
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
test "alias_method_chain the normal methods" do
|
82
|
+
MyController.send(:include, Cas::SingleLogOut)
|
82
83
|
|
83
|
-
|
84
|
+
c = MyController.new
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
assert( c.respond_to? :destroy)
|
87
|
+
assert( c.respond_to? :destroy_with_cas)
|
88
|
+
assert( c.respond_to? :destroy_without_cas)
|
88
89
|
|
89
|
-
|
90
|
+
end
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
test "destroy_with_cas redirects to server and calls logout_user" do
|
93
|
+
MyController.send(:include, Cas::SingleLogOut)
|
94
|
+
c = MyController.new
|
94
95
|
|
95
|
-
|
96
|
+
c.expects(:logout_user)
|
96
97
|
|
97
|
-
|
98
|
+
Cas::Utils.expects(:logout).with(c, "http://#{Rails.application.config.cms.site_domain}/")
|
98
99
|
|
99
|
-
|
100
|
+
c.destroy_with_cas
|
100
101
|
|
101
102
|
|
102
|
-
|
103
|
+
end
|
103
104
|
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
test "that BrowserCMS 3.0.3 installed." do
|
106
|
+
assert Cms::SessionsController.new.respond_to?(:logout_user), "Need to have BrowserCMS 3.0.3 installed for Cas module to work."
|
107
|
+
end
|
107
108
|
|
108
|
-
|
109
|
-
|
109
|
+
test "Cms::SessionController gets augmented" do
|
110
|
+
assert (Cms::SessionsController.new.respond_to? :destroy_with_cas)
|
111
|
+
end
|
110
112
|
end
|
111
|
-
end
|
113
|
+
end
|
data/test/unit/cas_user_test.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
user
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
3
|
+
module Cms
|
4
|
+
class CasUserTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@viewable_section = Section.create!(:name=>"root", :root=>true, :path=>"/")
|
8
|
+
@viewable_page = Page.create!(:name=>"Home", :section=>@viewable_section, :path=>"/p")
|
9
|
+
@cas_group = Group.create!(:name=>"G", :code=>"cas_group")
|
10
|
+
@cas_group.sections = Section.all
|
11
|
+
end
|
12
|
+
|
13
|
+
test "group returns the cas_group" do
|
14
|
+
user = CasUser.new
|
15
|
+
assert_equal @cas_group, user.group
|
16
|
+
end
|
17
|
+
|
18
|
+
test "cas_user should be able to view all sections (based on group)" do
|
19
|
+
user = CasUser.new
|
20
|
+
assert user.able_to_view?(@viewable_page)
|
21
|
+
end
|
22
|
+
|
23
|
+
test "setting login" do
|
24
|
+
user = CasUser.new(:login=>"bob")
|
25
|
+
assert_equal "bob", user.login
|
26
|
+
end
|
27
|
+
|
28
|
+
test "that CasUsers are not considered guests" do
|
29
|
+
user = CasUser.new
|
30
|
+
assert !user.guest?
|
31
|
+
end
|
32
|
+
|
33
|
+
test "determine if a user has cms_access" do
|
34
|
+
user = CasUser.new
|
35
|
+
user.groups << @cas_group
|
36
|
+
|
37
|
+
@cas_group.expects(:cms_access?).returns(true)
|
38
|
+
assert_equal true, user.cms_access?
|
39
|
+
end
|
38
40
|
end
|
39
|
-
end
|
41
|
+
end
|
data/test/unit/cas_utils_test.rb
CHANGED
@@ -1,83 +1,85 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'mocha'
|
3
3
|
|
4
|
-
|
4
|
+
module Cms
|
5
|
+
class CasUtilsTest < ActiveSupport::TestCase
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def setup
|
8
|
+
@current_page = Page.new(:path=>"/expected")
|
9
|
+
@portlet = LoginPortlet.new
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
test "service_url returns absolute success_url if specified" do
|
13
|
+
@portlet.success_url = "/stuff"
|
14
|
+
assert_equal "http://localhost:3000/stuff", Cas::Utils.service_url(@portlet, @current_page), "This really need to be an absolute path for it work w/ CAS."
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
test "service_url returns current page if specified" do
|
18
|
+
p = LoginPortlet.new
|
19
|
+
p.current_page = Page.new(:path=>"/expected")
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
s = Cas::Utils.service_url(p, @current_page)
|
22
|
+
assert_equal "http://localhost:3000/expected", s
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
test "service_url returns redirect_to if available" do
|
26
|
+
s = Cas::Utils.service_url(@portlet, @current_page, "/redirected")
|
27
|
+
assert_equal "http://localhost:3000/redirected", s
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
test "Nil page doesn't cause Nil exception" do
|
31
|
+
s = Cas::Utils.service_url(@portlet, nil, nil)
|
32
|
+
assert_equal "http://localhost:3000", s
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
test "Portlets work as expected (CMS Core check)" do
|
36
|
+
p = LoginPortlet.new
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
assert_equal nil, p.success_url, "Validate that LoginPortlet returns nil if no success_url is set (rather than an empty string."
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
test "cas_server_url looks up CAS server from config in environment" do
|
42
|
+
expected = "https://127.0.0.1"
|
43
|
+
CASClient::Frameworks::Rails::Filter.expects(:config).returns({:cas_base_url=>expected})
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
assert_equal expected, Cas::Utils.cas_server_url
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
test "get login ticket" do
|
49
|
+
expected_host = "https://random.com"
|
50
|
+
Cas::Utils.expects(:cas_server_url).with.returns(expected_host)
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
Net::HTTP.any_instance.stubs(:start).returns(mock(:body=>"Ticket 100"))
|
53
|
+
uri = stub(:path=>"#{expected_host}/loginTicket", :host=>"", :port=>80)
|
54
|
+
URI.expects(:parse).with("#{expected_host}/loginTicket").returns(uri)
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
ticket = Cas::Utils.fetch_lt_from_cas
|
57
|
+
assert_equal "Ticket 100", ticket
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
# Verification test of CasClient API behavior.
|
61
|
+
test "[CASClient] Verify expected behavior of CASClient#logout_url" do
|
62
|
+
destination_url = "localhost"
|
62
63
|
|
63
|
-
|
64
|
+
client = CASClient::Client.new({:cas_base_url=>"/", :logout_url=>"/"})
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
logout_url = client.logout_url(destination_url, destination_url)
|
67
|
+
assert_equal "/?destination=localhost&url=localhost", logout_url, "Verifies that logout_url generates a correct URL."
|
68
|
+
assert_equal String, logout_url.class
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
test "Cas::Utils#logout redirects and attaches gateway=true to logout_url" do
|
72
|
+
destination_url = "localhost"
|
73
|
+
logout_url = "/?destination=localhost&url=localhost"
|
73
74
|
|
74
|
-
|
75
|
-
|
75
|
+
CASClient::Frameworks::Rails::Filter.expects(:client).returns(CASClient::Client.new({:cas_base_url=>""}))
|
76
|
+
CASClient::Client.any_instance.expects(:logout_url).with(destination_url, destination_url).returns(logout_url)
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
78
|
+
controller = stub()
|
79
|
+
controller.expects(:redirect_to).with("#{logout_url}&gateway=true")
|
80
|
+
Cas::Utils.expects(:reset_session_and_get_referrer).returns(destination_url)
|
80
81
|
|
81
|
-
|
82
|
+
Cas::Utils.logout(controller, "/")
|
83
|
+
end
|
82
84
|
end
|
83
|
-
end
|
85
|
+
end
|
@@ -1,81 +1,83 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
3
|
+
module Cms
|
4
|
+
class TemporaryUserTest < ActiveSupport::TestCase
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
MINIMUM_VALID_ATTRIBUTES = {:login=>"abc@bm.com", :password=>"123", :password_confirmation=>"123", :email=>"abc@bm.com"}
|
7
|
+
def setup
|
8
|
+
@user = Cms::TemporaryUser.new(MINIMUM_VALID_ATTRIBUTES)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
def teardown
|
11
12
|
|
12
|
-
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
test "Should not be able to save or save!" do
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
assert_equal false, @user.save
|
18
|
+
assert_equal true, @user.valid?
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
assert_raise NotImplementedError do
|
21
|
+
@user.save!
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
end
|
25
|
+
test "Shouldn't be able to update attributes" do
|
26
|
+
assert_equal false, @user.update_attribute(:login, "OTHER")
|
27
|
+
assert_equal false, @user.update_attributes({:login =>"OTHER"})
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
test "Should belong to no groups by default" do
|
31
|
+
assert_equal 0, @user.groups.size
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
test "Temp users should be able to view sections their groups have permissions to" do
|
35
|
+
group = Group.create!(:name=>"My Group")
|
36
|
+
section = Section.create!(:name=>"My Section", :path=>"/mysection")
|
37
|
+
section.groups << group
|
38
|
+
section.save!
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
user = Cms::TemporaryUser.new
|
41
|
+
user.groups << group
|
41
42
|
|
42
|
-
|
43
|
+
assert user.able_to_view?(section)
|
43
44
|
|
44
45
|
|
45
|
-
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
test "Viewable sections" do
|
49
|
+
group = Group.create!(:name=>"Group 1")
|
50
|
+
first_section = Section.create!(:name=>"Section1", :path=>"/section1")
|
51
|
+
first_section.groups << group
|
52
|
+
first_section.save!
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
group2 = Group.create!(:name=>"Group 2")
|
55
|
+
second_section = Section.create!(:name=>"Section 2", :path=>"/section2")
|
56
|
+
second_section.groups << group2
|
57
|
+
second_section.save!
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
user = Cms::TemporaryUser.new
|
60
|
+
user.groups << group << group2
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
assert_equal [first_section, second_section], user.viewable_sections
|
63
|
+
assert user.able_to_view?(first_section)
|
64
|
+
assert user.able_to_view?(second_section)
|
64
65
|
|
65
|
-
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
test "A user with no groups should not have CMS access" do
|
69
|
+
user = Cms::TemporaryUser.new
|
70
|
+
assert_equal false, user.cms_access?
|
71
|
+
end
|
70
72
|
end
|
71
|
-
end
|
72
73
|
|
73
74
|
|
74
|
-
class GuestUserTest <ActiveSupport::TestCase
|
75
|
+
class GuestUserTest <ActiveSupport::TestCase
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
test "Verify save behavior of Guest is similar to TemporaryUser" do
|
78
|
+
guest = GuestUser.new(TemporaryUserTest::MINIMUM_VALID_ATTRIBUTES)
|
79
|
+
assert_equal false, guest.save()
|
80
|
+
assert_equal true, guest.valid?
|
81
|
+
end
|
80
82
|
end
|
81
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_cas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: browsercms
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - <
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.
|
21
|
+
version: 3.6.0
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.5.0
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
none: false
|
26
29
|
requirements:
|
27
|
-
- -
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.6.0
|
33
|
+
- - ! '>='
|
28
34
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.
|
35
|
+
version: 3.5.0
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
37
|
name: rubycas-client
|
32
38
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,12 +57,16 @@ extensions: []
|
|
51
57
|
extra_rdoc_files:
|
52
58
|
- README.markdown
|
53
59
|
files:
|
54
|
-
- app/
|
55
|
-
- app/
|
60
|
+
- app/assets/javascripts/bcms_cas/application.js
|
61
|
+
- app/assets/stylesheets/bcms_cas/application.css
|
62
|
+
- app/controllers/bcms_cas/application_controller.rb
|
63
|
+
- app/helpers/bcms_cas/application_helper.rb
|
56
64
|
- app/models/cas_user.rb
|
57
65
|
- app/models/cms/temporary_user.rb
|
58
66
|
- app/portlets/helpers/login_portlet_helper.rb
|
59
67
|
- app/views/portlets/login/render.html.erb
|
68
|
+
- config/routes.rb
|
69
|
+
- db/bcms_cas.seeds.rb
|
60
70
|
- lib/bcms_cas/acts_as_content_page_extention.rb
|
61
71
|
- lib/bcms_cas/authentication.rb
|
62
72
|
- lib/bcms_cas/configuration.rb
|
@@ -72,12 +82,13 @@ files:
|
|
72
82
|
- lib/generators/bcms_cas/install/templates/login_portlet_helper.rb
|
73
83
|
- lib/generators/bcms_cas/install/templates/render.html.erb
|
74
84
|
- lib/generators/bcms_cas/install/USAGE
|
85
|
+
- lib/tasks/bcms_cas_tasks.rake
|
75
86
|
- README.markdown
|
76
87
|
- Gemfile
|
77
88
|
- LICENSE.txt
|
78
89
|
- COPYRIGHT.txt
|
79
90
|
- GPL.txt
|
80
|
-
- test/
|
91
|
+
- test/bcms_cas_test.rb
|
81
92
|
- test/test_helper.rb
|
82
93
|
- test/unit/cas/cas_authentication_test.rb
|
83
94
|
- test/unit/cas/configuration_test.rb
|
@@ -100,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
111
|
version: '0'
|
101
112
|
segments:
|
102
113
|
- 0
|
103
|
-
hash:
|
114
|
+
hash: 754055201174339068
|
104
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
116
|
none: false
|
106
117
|
requirements:
|
@@ -109,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
120
|
version: '0'
|
110
121
|
segments:
|
111
122
|
- 0
|
112
|
-
hash:
|
123
|
+
hash: 754055201174339068
|
113
124
|
requirements: []
|
114
125
|
rubyforge_project:
|
115
126
|
rubygems_version: 1.8.24
|
@@ -117,7 +128,7 @@ signing_key:
|
|
117
128
|
specification_version: 3
|
118
129
|
summary: A CAS Module for BrowserCMS
|
119
130
|
test_files:
|
120
|
-
- test/
|
131
|
+
- test/bcms_cas_test.rb
|
121
132
|
- test/test_helper.rb
|
122
133
|
- test/unit/cas/cas_authentication_test.rb
|
123
134
|
- test/unit/cas/configuration_test.rb
|