Sha256: 1e07cb7df18cde7be3891307af22cf5fcbf980c5edceac1b33f16b12a5d05c1a

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

# Copyright 2010 Bert Meerman
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))

# Dummy code for overriding the default current_user behavior
module Cbac
  def current_user
    1
  end
end

###
# Tests the Cbac system for authorization with generic roles
#
class CbacAuthorizeGenericRolesTest <  ActiveSupport::TestCase
  #self.fixture_path = File.join(File.dirname(__FILE__), "fixtures")
  #fixtures :all

  # Setup defines the PrivilegeSet that is being used by all PrivilegeTest methods
  def setup
    return if PrivilegeSet.sets.include?(:cbac_generic_role)
    PrivilegeSet.add :cbac_generic_role, ""
    PrivilegeSet.add :cbac_generic_role_incorrect, ""
    Privilege.resource  :cbac_generic_role, "authorize/generic/roles", :get
    Privilege.resource  :cbac_generic_role_incorrect, "authorize/generic/roles_incorrect", :get
  end

  # Check to see if action is correctly authorized
  def test_authorize_ok
    assert_equal true, authorization_check("authorize/generic", "roles", :get)
  end

  # Run authorization with incorrect authorization
  def test_authorize_incorrect_privilege
    assert_equal false, authorization_check("authorize/generic", "roles_incorrect", :get)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cbac-0.8.0 test/test_cbac_authorize_generic_roles.rb
cbac-0.7.0 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.10 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.9 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.8 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.7 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.5 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.4 test/test_cbac_authorize_generic_roles.rb
cbac-0.6.2 test/test_cbac_authorize_generic_roles.rb