- Timestamp:
- 02/09/10 09:28:06 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/__init__.py
r7358 r7413 13 13 import logging 14 14 import socket 15 15 16 logging.basicConfig() 16 17 log = logging.getLogger(__name__) -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/authz/request-filter.xml
r7364 r7413 35 35 </Resources> 36 36 </Target> 37 <Rule RuleId="Catch all" Effect="Deny"></Rule> 37 38 </Policy> -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/authz/saml-test.ini
r7354 r7413 24 24 pep.authzServiceURI = https://localhost:9443/authorisation-service 25 25 pep.cacheDecisions = True 26 pep.localPolicyFilePath = %(here)s/request-filter.xml 26 27 27 28 # Settings for Policy Information Point used by the Policy Decision Point to -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/authz/test_authz.py
r7287 r7413 15 15 import unittest 16 16 import os 17 import time 17 18 from urlparse import urlunsplit 18 19 19 20 from os import path 20 21 from ConfigParser import SafeConfigParser 22 from urllib2 import URLError 23 24 from uuid import uuid4 25 from datetime import datetime, timedelta 21 26 22 27 import paste.fixture 23 28 from paste.deploy import loadapp 29 30 from ndg.saml.saml2.core import (SAMLVersion, Subject, NameID, Issuer, 31 AuthzDecisionQuery, AuthzDecisionStatement, 32 Status, StatusCode, StatusMessage, 33 DecisionType, Action, Conditions, Assertion) 34 from ndg.saml.xml.etree import (AuthzDecisionQueryElementTree, 35 ResponseElementTree) 24 36 25 37 from ndg.security.test.unit import BaseTestCase … … 30 42 HTTPRedirectPEPResultHandlerMiddleware 31 43 from ndg.security.server.wsgi.authz.pep import SamlPepFilterConfigError 32 33 34 from uuid import uuid435 from datetime import datetime, timedelta36 37 from ndg.saml.saml2.core import (SAMLVersion, Subject, NameID, Issuer,38 AuthzDecisionQuery, AuthzDecisionStatement,39 Status, StatusCode, StatusMessage,40 DecisionType, Action, Conditions, Assertion)41 from ndg.saml.xml.etree import (AuthzDecisionQueryElementTree,42 ResponseElementTree)43 44 44 45 … … 155 156 156 157 def __call__(self, environ, start_response): 157 158 response = self.__class__.RESPONSE 158 159 if environ['PATH_INFO'] == '/test_401': 159 160 status = "401 Unauthorized" … … 172 173 elif environ['PATH_INFO'] == '/test_accessGrantedToSecuredURI': 173 174 status = "200 OK" 175 176 elif environ['PATH_INFO'].startswith('/layout'): 177 status = "200 OK" 178 response += ("\n\nAny calls to this path or sub-path should be " 179 "publicly accessible") 174 180 else: 175 181 status = "404 Not found" … … 177 183 start_response(status, 178 184 [('Content-length', 179 str(len( TestAuthZMiddleware.RESPONSE))),185 str(len(response))), 180 186 ('Content-type', 'text/plain')]) 181 187 … … 216 222 217 223 self.startAuthorisationService() 218 224 219 225 220 226 class SamlPepFilterTestCase(BaseAuthzFilterTestCase): … … 272 278 273 279 def test05Catch401WithNotLoggedInAndSecuredURI(self): 274 # AuthZ middleware grants access because the URI requested has no275 # subject restriction set in the policy rule280 # User is not logged in and a secured resource has been requested so 401 281 # response is returned 276 282 277 283 # AuthZ middleware checks for username key in session set by AuthN 278 284 # handler 279 extra_environ ={self.__class__.SESSION_KEYNAME:BeakerSessionStub()}285 extra_environ = {self.__class__.SESSION_KEYNAME: BeakerSessionStub()} 280 286 response = self.app.get('/test_accessDeniedToSecuredURI', 281 287 extra_environ=extra_environ, … … 284 290 285 291 def test06AccessDeniedForSecuredURI(self): 286 287 292 # User is logged in but doesn't have the required credentials for 288 293 # access … … 298 303 print response 299 304 300 def test07AccessGrantedForSecuredURI(self): 301 305 def test07AccessGrantedForSecuredURI(self): 302 306 # User is logged in and has credentials for access to a URI secured 303 307 # by the policy file … … 313 317 self.assert_(TestAuthZMiddleware.RESPONSE in response) 314 318 print response 315 319 320 def test08LocalPolicyFiltersOutRequest(self): 321 # The local PDP filters out the incoming request as not applicable so 322 # that the authorisation service is never invoked. 323 extra_environ = {self.__class__.SESSION_KEYNAME: BeakerSessionStub()} 324 response = self.app.get('/layout/my.css', extra_environ=extra_environ, 325 status=200) 326 self.assert_(response.body) 327 316 328 317 329 class PEPResultHandlerTestCase(BaseAuthzFilterTestCase):
Note: See TracChangeset
for help on using the changeset viewer.