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.
@@ -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 SITE_DOMAIN is configured.
38
+ ## 2a. Ensure site_domain is configured.
38
39
 
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).
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
- SITE_DOMAIN="www.yourdomainname.com"
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
+ */
@@ -0,0 +1,4 @@
1
+ module BcmsCas
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BcmsCas
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -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
@@ -0,0 +1,2 @@
1
+ BcmsCas::Engine.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ group = Group.create!(:name=>"CAS Authenticated Users",
2
+ :code=>"cas_group",
3
+ :group_type=>GroupType.find_by_name("Registered Public User"))
4
+ group.sections = Section.all
@@ -1,4 +1,4 @@
1
- require 'bcms_cas/engine'
2
- require 'bcms_cas/routes'
3
-
1
+ require "bcms_cas/engine"
4
2
 
3
+ module BcmsCas
4
+ end
@@ -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, :only=>[:show]
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://#{SITE_DOMAIN}/")
67
+ Cas::Utils.logout(self, "http://#{Rails.application.config.cms.site_domain}/")
68
68
  end
69
69
  end
70
70
  end
@@ -68,7 +68,7 @@ module Cas
68
68
  private
69
69
 
70
70
  def self.to_absolute_url(path)
71
- "http://#{SITE_DOMAIN}#{path}"
71
+ "http://#{Rails.application.config.cms.site_domain}#{path}"
72
72
  end
73
73
  end
74
74
  end
@@ -1,3 +1,3 @@
1
1
  module BcmsCas
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bcms_cas do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BcmsCasTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, BcmsCas
6
+ end
7
+ end
@@ -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 'mocha'
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
6
 
7
- class ActiveSupport::TestCase
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
- # Add more helper methods to be used by all tests here...
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
- class CasAuthTest < ActiveSupport::TestCase
27
+ module Cms
28
+ class CasAuthTest < ActiveSupport::TestCase
28
29
 
29
- def setup
30
- MyController.expects(:skip_filter).with(:check_access_to_page)
31
- MyController.expects(:skip_filter).with(:try_to_stream_file)
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
- MyController.expects(:before_filter).with(:verify_cas_configured)
34
- MyController.expects(:before_filter).with(CASClient::Frameworks::Rails::GatewayFilter)
35
- MyController.expects(:before_filter).with(:login_from_cas_ticket)
36
- MyController.expects(:before_filter).with(:try_to_stream_file)
37
- MyController.expects(:before_filter).with(:check_access_to_page)
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
- MyController.send(:include, Cas::Authentication)
40
+ MyController.send(:include, Cas::Authentication)
40
41
 
41
- end
42
+ end
42
43
 
43
- def teardown
44
- User.current = nil
45
- end
44
+ def teardown
45
+ User.current = nil
46
+ end
46
47
 
47
48
 
48
- test "adds current_user and login from session to class" do
49
- c = MyController.new
49
+ test "adds current_user and login from session to class" do
50
+ c = MyController.new
50
51
 
51
- assert c.respond_to?(:current_user)
52
- assert c.respond_to?(:login_from_cas_ticket)
52
+ assert c.respond_to?(:current_user)
53
+ assert c.respond_to?(:login_from_cas_ticket)
53
54
 
54
- end
55
+ end
55
56
 
56
57
 
57
- test "login_from_cas_ticket will create and set the current user and User.current if a session attribute was found." do
58
- c = MyController.new
59
- c.session[:cas_user] = "1234"
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
- User.current = Group.find_by_code("guest")
62
+ User.current = Group.find_by_code("guest")
62
63
 
63
- c.login_from_cas_ticket
64
+ c.login_from_cas_ticket
64
65
 
65
- current_user = c.get_at_current_user
66
- assert_equal CasUser, current_user.class
67
- assert_equal "1234", current_user.login
68
- assert_equal current_user, User.current
69
- end
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
- test "Cms::ContentController gets augmented" do
72
- assert (Cms::ContentController.new.respond_to? :login_from_cas_ticket)
73
- end
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
- test "alias_method_chain the normal methods" do
81
- MyController.send(:include, Cas::SingleLogOut)
81
+ test "alias_method_chain the normal methods" do
82
+ MyController.send(:include, Cas::SingleLogOut)
82
83
 
83
- c = MyController.new
84
+ c = MyController.new
84
85
 
85
- assert( c.respond_to? :destroy)
86
- assert( c.respond_to? :destroy_with_cas)
87
- assert( c.respond_to? :destroy_without_cas)
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
- end
90
+ end
90
91
 
91
- test "destroy_with_cas redirects to server and calls logout_user" do
92
- MyController.send(:include, Cas::SingleLogOut)
93
- c = MyController.new
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
- c.expects(:logout_user)
96
+ c.expects(:logout_user)
96
97
 
97
- Cas::Utils.expects(:logout).with(c, "http://#{SITE_DOMAIN}/")
98
+ Cas::Utils.expects(:logout).with(c, "http://#{Rails.application.config.cms.site_domain}/")
98
99
 
99
- c.destroy_with_cas
100
+ c.destroy_with_cas
100
101
 
101
102
 
102
- end
103
+ end
103
104
 
104
- test "that BrowserCMS 3.0.3 installed." do
105
- assert Cms::SessionsController.new.respond_to?(:logout_user), "Need to have BrowserCMS 3.0.3 installed for Cas module to work."
106
- end
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
- test "Cms::SessionController gets augmented" do
109
- assert (Cms::SessionsController.new.respond_to? :destroy_with_cas)
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
@@ -1,39 +1,41 @@
1
1
  require 'test_helper'
2
2
 
3
- class CasUserTest < ActiveSupport::TestCase
4
-
5
- def setup
6
- @viewable_section = Section.create!(:name=>"root", :root=>true, :path=>"/")
7
- @viewable_page = Page.create!(:name=>"Home", :section=>@viewable_section, :path=>"/p")
8
- @cas_group = Group.create!(:name=>"G", :code=>"cas_group")
9
- @cas_group.sections = Section.all
10
- end
11
-
12
- test "group returns the cas_group" do
13
- user = CasUser.new
14
- assert_equal @cas_group, user.group
15
- end
16
-
17
- test "cas_user should be able to view all sections (based on group)" do
18
- user = CasUser.new
19
- assert user.able_to_view?(@viewable_page)
20
- end
21
-
22
- test "setting login" do
23
- user = CasUser.new(:login=>"bob")
24
- assert_equal "bob", user.login
25
- end
26
-
27
- test "that CasUsers are not considered guests" do
28
- user = CasUser.new
29
- assert !user.guest?
30
- end
31
-
32
- test "determine if a user has cms_access" do
33
- user = CasUser.new
34
- user.groups << @cas_group
35
-
36
- @cas_group.expects(:cms_access?).returns(true)
37
- assert_equal true, user.cms_access?
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
@@ -1,83 +1,85 @@
1
1
  require 'test_helper'
2
2
  require 'mocha'
3
3
 
4
- class CasUtilsTest < ActiveSupport::TestCase
4
+ module Cms
5
+ class CasUtilsTest < ActiveSupport::TestCase
5
6
 
6
- def setup
7
- @current_page = Page.new(:path=>"/expected")
8
- @portlet = LoginPortlet.new
9
- end
7
+ def setup
8
+ @current_page = Page.new(:path=>"/expected")
9
+ @portlet = LoginPortlet.new
10
+ end
10
11
 
11
- test "service_url returns absolute success_url if specified" do
12
- @portlet.success_url = "/stuff"
13
- 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."
14
- end
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
- test "service_url returns current page if specified" do
17
- p = LoginPortlet.new
18
- p.current_page = Page.new(:path=>"/expected")
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
- s = Cas::Utils.service_url(p, @current_page)
21
- assert_equal "http://localhost:3000/expected", s
22
- end
21
+ s = Cas::Utils.service_url(p, @current_page)
22
+ assert_equal "http://localhost:3000/expected", s
23
+ end
23
24
 
24
- test "service_url returns redirect_to if available" do
25
- s = Cas::Utils.service_url(@portlet, @current_page, "/redirected")
26
- assert_equal "http://localhost:3000/redirected", s
27
- end
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
- test "Nil page doesn't cause Nil exception" do
30
- s = Cas::Utils.service_url(@portlet, nil, nil)
31
- assert_equal "http://localhost:3000", s
32
- end
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
- test "Portlets work as expected (CMS Core check)" do
35
- p = LoginPortlet.new
35
+ test "Portlets work as expected (CMS Core check)" do
36
+ p = LoginPortlet.new
36
37
 
37
- assert_equal nil, p.success_url, "Validate that LoginPortlet returns nil if no success_url is set (rather than an empty string."
38
- end
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
- test "cas_server_url looks up CAS server from config in environment" do
41
- expected = "https://127.0.0.1"
42
- CASClient::Frameworks::Rails::Filter.expects(:config).returns({:cas_base_url=>expected})
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
- assert_equal expected, Cas::Utils.cas_server_url
45
- end
45
+ assert_equal expected, Cas::Utils.cas_server_url
46
+ end
46
47
 
47
- test "get login ticket" do
48
- expected_host = "https://random.com"
49
- Cas::Utils.expects(:cas_server_url).with.returns(expected_host)
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
- Net::HTTP.any_instance.stubs(:start).returns(mock(:body=>"Ticket 100"))
52
- uri = stub(:path=>"#{expected_host}/loginTicket", :host=>"", :port=>80)
53
- URI.expects(:parse).with("#{expected_host}/loginTicket").returns(uri)
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
- ticket = Cas::Utils.fetch_lt_from_cas
56
- assert_equal "Ticket 100", ticket
57
- end
56
+ ticket = Cas::Utils.fetch_lt_from_cas
57
+ assert_equal "Ticket 100", ticket
58
+ end
58
59
 
59
- # Verification test of CasClient API behavior.
60
- test "[CASClient] Verify expected behavior of CASClient#logout_url" do
61
- destination_url = "localhost"
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
- client = CASClient::Client.new({:cas_base_url=>"/", :logout_url=>"/"})
64
+ client = CASClient::Client.new({:cas_base_url=>"/", :logout_url=>"/"})
64
65
 
65
- logout_url = client.logout_url(destination_url, destination_url)
66
- assert_equal "/?destination=localhost&url=localhost", logout_url, "Verifies that logout_url generates a correct URL."
67
- assert_equal String, logout_url.class
68
- end
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
- test "Cas::Utils#logout redirects and attaches gateway=true to logout_url" do
71
- destination_url = "localhost"
72
- logout_url = "/?destination=localhost&url=localhost"
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
- CASClient::Frameworks::Rails::Filter.expects(:client).returns(CASClient::Client.new({:cas_base_url=>""}))
75
- CASClient::Client.any_instance.expects(:logout_url).with(destination_url, destination_url).returns(logout_url)
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
- controller = stub()
78
- controller.expects(:redirect_to).with("#{logout_url}&gateway=true")
79
- Cas::Utils.expects(:reset_session_and_get_referrer).returns(destination_url)
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
- Cas::Utils.logout(controller, "/")
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
- class TemporaryUserTest < ActiveSupport::TestCase
3
+ module Cms
4
+ class TemporaryUserTest < ActiveSupport::TestCase
4
5
 
5
- MINIMUM_VALID_ATTRIBUTES = {:login=>"abc@bm.com", :password=>"123", :password_confirmation=>"123", :email=>"abc@bm.com"}
6
- def setup
7
- @user = Cms::TemporaryUser.new(MINIMUM_VALID_ATTRIBUTES)
8
- end
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
- def teardown
11
+ def teardown
11
12
 
12
- end
13
+ end
13
14
 
14
- test "Should not be able to save or save!" do
15
+ test "Should not be able to save or save!" do
15
16
 
16
- assert_equal false, @user.save
17
- assert_equal true, @user.valid?
17
+ assert_equal false, @user.save
18
+ assert_equal true, @user.valid?
18
19
 
19
- assert_raise NotImplementedError do
20
- @user.save!
21
- end
20
+ assert_raise NotImplementedError do
21
+ @user.save!
22
+ end
22
23
 
23
- end
24
- test "Shouldn't be able to update attributes" do
25
- assert_equal false, @user.update_attribute(:login, "OTHER")
26
- assert_equal false, @user.update_attributes({:login =>"OTHER"})
27
- end
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
- test "Should belong to no groups by default" do
30
- assert_equal 0, @user.groups.size
31
- end
30
+ test "Should belong to no groups by default" do
31
+ assert_equal 0, @user.groups.size
32
+ end
32
33
 
33
- test "Temp users should be able to view sections their groups have permissions to" do
34
- group = Group.create!(:name=>"My Group")
35
- section = Section.create!(:name=>"My Section", :path=>"/mysection")
36
- section.groups << group
37
- section.save!
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
- user = Cms::TemporaryUser.new
40
- user.groups << group
40
+ user = Cms::TemporaryUser.new
41
+ user.groups << group
41
42
 
42
- assert user.able_to_view?(section)
43
+ assert user.able_to_view?(section)
43
44
 
44
45
 
45
- end
46
+ end
46
47
 
47
- test "Viewable sections" do
48
- group = Group.create!(:name=>"Group 1")
49
- first_section = Section.create!(:name=>"Section1", :path=>"/section1")
50
- first_section.groups << group
51
- first_section.save!
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
- group2 = Group.create!(:name=>"Group 2")
54
- second_section = Section.create!(:name=>"Section 2", :path=>"/section2")
55
- second_section.groups << group2
56
- second_section.save!
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
- user = Cms::TemporaryUser.new
59
- user.groups << group << group2
59
+ user = Cms::TemporaryUser.new
60
+ user.groups << group << group2
60
61
 
61
- assert_equal [first_section, second_section], user.viewable_sections
62
- assert user.able_to_view?(first_section)
63
- assert user.able_to_view?(second_section)
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
- end
66
+ end
66
67
 
67
- test "A user with no groups should not have CMS access" do
68
- user = Cms::TemporaryUser.new
69
- assert_equal false, user.cms_access?
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
- test "Verify save behavior of Guest is similar to TemporaryUser" do
77
- guest = GuestUser.new(TemporaryUserTest::MINIMUM_VALID_ATTRIBUTES)
78
- assert_equal false, guest.save()
79
- assert_equal true, guest.valid?
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.2.2
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-08-31 00:00:00.000000000 Z
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.3.4
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.3.4
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/controllers/application_controller.rb
55
- - app/helpers/application_helper.rb
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/performance/browsing_test.rb
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: 3576433894796172697
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: 3576433894796172697
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/performance/browsing_test.rb
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
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/performance_test_help'
3
-
4
- # Profiling results for each test method are written to tmp/performance.
5
- class BrowsingTest < ActionDispatch::PerformanceTest
6
- def test_homepage
7
- get '/'
8
- end
9
- end