Sha256: 9f539f5d756f69855599f89864b8ebca434209a1cacca3d3f538194f46603a65
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../test/test_helper')) require 'test/unit' require 'rubygems' # Dummy code for overriding the default current_user behavior module Cbac def current_user 1 end end ### # Tests the Cbac system for authorization with context roles # class CbacAuthorizeContextRolesTest < ActiveSupport::TestCase include Cbac self.fixture_path = File.join(File.dirname(__FILE__), "fixtures") fixtures :all attr_accessor :authorize_context_eval_string attr_accessor :session # Setup defines the PrivilegeSet that is being used by all PrivilegeTest methods def setup return if PrivilegeSet.sets.include?(:cbac_context_role) PrivilegeSet.add :cbac_context_role, "" Privilege.resource :cbac_context_role, "authorize/context/roles", :get ContextRole.add :authorize_context_role, "context[:authorize_context_eval_string]" end # Check to see if action is correctly authorized def test_authorize_ok assert_equal true, authorization_check("authorize/context", "roles", :get, {:authorize_context_eval_string => true}) end # Run authorization with incorrect authorization def test_authorize_incorrect_privilege assert_equal false, authorization_check("authorize/context", "roles", :get, {:authorize_context_eval_string => false}) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cbac-0.5.4 | test/test_cbac_authorize_context_roles.rb |