Home | Trees | Indices | Help |
|
---|
|
1 """NDG XACML PDP tests with nested policy sets 2 3 NERC DataGrid 4 """ 5 __author__ = "R B Wilkinson" 6 __date__ = "02/11/11" 7 __copyright__ = "(C) 2011 Science and Technology Facilities Council" 8 __contact__ = "Philip.Kershaw@stfc.ac.uk" 9 __license__ = "BSD - see LICENSE file in top-level directory" 10 __contact__ = "Philip.Kershaw@stfc.ac.uk" 11 __revision__ = "$Id$" 12 13 import logging 14 import os.path 15 import time 16 import unittest 17 18 from ndg.xacml.parsers.etree.factory import ReaderFactory 19 from ndg.xacml.core.context.pdp import PDP 20 from ndg.xacml.core.context.result import Decision 21 from ndg.xacml.test import THIS_DIR 22 from ndg.xacml.test.context import XacmlContextBaseTestCase 23 24 25 logging.basicConfig(level=logging.ERROR) 2628 29 RESOURCE_DL_ID = 'http://localhost/download/action-and-single-subject-role-restricted' 30 RESOURCE_VIEW1_ID = 'http://localhost/view/set1/action-and-single-subject-role-restricted-1' 31 RESOURCE_VIEW2_ID = 'http://localhost/view/set2/action-and-single-subject-role-restricted-2' 32 XACML_POLICY_SET_FILENAME = 'policy_set_nested_only.xml' 33 XACML_POLICY_SET_FILEPATH = os.path.join(THIS_DIR, XACML_POLICY_SET_FILENAME) 3479 80 81 if __name__ == "__main__": 82 unittest.main() 8336 print "Setting up" 37 self.pdp = PDP.fromPolicySource(self.__class__.XACML_POLICY_SET_FILEPATH, ReaderFactory) 38 print "Setup complete"39 4042 request = self._createRequestCtx( 43 self.__class__.RESOURCE_DL_ID, 44 subjectRoles=('staff',)) 45 print "Starting request" 46 start_time = time.time() 47 response = self.pdp.evaluate(request) 48 print("Response received after %fs" % (time.time() - start_time)) 49 self.failIf(response is None, "Null response") 50 for result in response.results: 51 self.failIf(result.decision != Decision.PERMIT, 52 "Expecting Permit decision")5355 request = self._createRequestCtx( 56 self.__class__.RESOURCE_VIEW1_ID, 57 subjectRoles=('admin',)) 58 print "Starting request" 59 start_time = time.time() 60 response = self.pdp.evaluate(request) 61 print("Response received after %fs" % (time.time() - start_time)) 62 self.failIf(response is None, "Null response") 63 for result in response.results: 64 self.failIf(result.decision != Decision.DENY, 65 "Expecting Deny decision")6668 request = self._createRequestCtx( 69 self.__class__.RESOURCE_VIEW2_ID, 70 subjectRoles=('staff',)) 71 print "Starting request" 72 start_time = time.time() 73 response = self.pdp.evaluate(request) 74 print("Response received after %fs" % (time.time() - start_time)) 75 self.failIf(response is None, "Null response") 76 for result in response.results: 77 self.failIf(result.decision != Decision.PERMIT, 78 "Expecting Permit decision")
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Apr 5 08:44:41 2012 | http://epydoc.sourceforge.net |