Changeset 1145

Show
Ignore:
Timestamp:
09/25/08 03:59:35 (2 months ago)
Author:
bermiferrer
Message:

Adding tests for actions access restriction on controllers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/AkActionController.php

    r1140 r1145  
    150150        $this->Response =& $Response; 
    151151        $this->params = $this->Request->getParams(); 
    152         $this->_action_name = $this->Request->getAction(); 
    153  
     152        $this->_action_name = $this->getActionName(); 
    154153        $this->_ensureActionExists(); 
    155154 
     
    247246        return array(); 
    248247    } 
    249          
     248 
    250249    function getModuleHelper() 
    251250    { 
     
    259258        return array(); 
    260259    } 
    261      
    262      
     260 
     261 
    263262    function _validateGeneratedXhtml() 
    264263    { 
     
    300299 
    301300        unset($this->model, $this->models); 
    302                  
     301 
    303302        foreach ($models as $model){ 
    304303            $this->instantiateModelClass($model, (empty($this->finder_options[$model])?array():$this->finder_options[$model])); 
     
    27192718    function _ensureActionExists() 
    27202719    { 
    2721         if(!method_exists($this, $this->_action_name)){ 
     2720        $action = $this->getActionName(); 
     2721        if(!method_exists($this, $action) || $this->_isActionForbidden()){ 
    27222722            if(AK_ENVIRONMENT == 'development'){ 
    2723                 AK_LOG_EVENTS && !empty($this->_Logger) ? $this->_Logger->error('Action '.$this->_action_name.' not found on '.$this->getControllerName()) : null; 
     2723                AK_LOG_EVENTS && !empty($this->_Logger) ? $this->_Logger->error('Action '.$action.' not found on '.$this->getControllerName()) : null; 
    27242724                trigger_error(Ak::t('Controller <i>%controller_name</i> can\'t handle action %action_name', 
    27252725                array( 
    27262726                '%controller_name' => $this->getControllerName(), 
    2727                 '%action_name' => $this->_action_name
     2727                '%action_name' => $action
    27282728                )), E_USER_ERROR); 
    27292729            }elseif(@include(AK_PUBLIC_DIR.DS.'405.php')){ 
     
    27342734            } 
    27352735        } 
     2736    } 
     2737 
     2738    function _isActionForbidden() 
     2739    { 
     2740        $methods = get_class_methods('AkActionController'); 
     2741        $action = $this->getActionName(); 
     2742        return empty($action) || in_array($action , $methods) || $action != AkInflector::underscore($action) || $action[0] == '_'; 
    27362743    } 
    27372744} 
  • trunk/test/unit/lib/AkActionController.php

    r443 r1145  
    1515 
    1616$partial_tests = array( 
     17'forbidden_actions', 
    1718'filters', 
    1819'locale_detection',