Changeset 5329


Ignore:
Timestamp:
21/05/09 14:20:25 (10 years ago)
Author:
pjkersha
Message:
  • Added AuthorizationMiddleware? unit tests: ndg.security.test.unit.wsgi.authz
  • Added check for ndg.security.server.wsgi.authz.PEPFilter to catch beaker session not set in a custom PEPFilter exception type
Location:
TI12-security/trunk/python
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/authz.py

    r5322 r5329  
    8080            return self._setErrorResponse(code=403, msg=response) 
    8181 
     82class PEPFilterError(Exception): 
     83    """Base class for PEPFilter exception types""" 
     84     
     85class PEPFilterConfigError(PEPFilterError): 
     86    """Configuration related error for PEPFilter""" 
    8287 
    8388class PEPFilter(NDGSecurityMiddlewareBase): 
     
    130135        log.debug("PEPFilter.__call__ ...") 
    131136         
    132         session = environ[self.sessionKey] 
     137        session = environ.get(self.sessionKey) 
     138        if session is None: 
     139            raise PEPFilterConfigError('No beaker session key "%s" found in ' 
     140                                       'environ' % self.sessionKey) 
     141             
    133142        resourceURI = self.pathInfo 
    134143         
     
    140149                     "target was found in the policy for URI path [%s]",  
    141150                     resourceURI) 
    142             return self._app(environ, start_response)        
     151            return self._app(environ, start_response) 
    143152 
    144153        log.info("PEPFilter found matching target(s):\n\n %s\n" 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/integration/authz/securedapp.py

    r5254 r5329  
    1212__revision__ = "$Id$" 
    1313 
    14      
     14    
    1515def app_factory(globalConfig, **localConfig): 
     16    '''AuthZTestMiddleware factory for Paste app pattern''' 
    1617    return AuthZTestMiddleware(None, globalConfig, **localConfig) 
    1718 
    1819def filter_app_factory(app, globalConfig, **localConfig): 
     20    '''AuthZTestMiddleware factory for Paste filter app pattern''' 
    1921    return AuthZTestMiddleware(app, globalConfig, **localConfig) 
    2022 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/wsgi/authn/test_authn.py

    r5292 r5329  
    99__license__ = "BSD - see LICENSE file in top-level directory" 
    1010__contact__ = "Philip.Kershaw@stfc.ac.uk" 
    11 __revision__ = '$Id: test_sessionmanagerclient.py 4437 2008-11-18 12:34:25Z pjkersha $' 
     11__revision__ = '$Id$' 
    1212import logging 
    1313 
Note: See TracChangeset for help on using the changeset viewer.