- Timestamp:
- 24/08/10 15:34:07 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/__init__.py
r7350 r7358 210 210 211 211 def __del__(self): 212 self.stopAllServices() 213 214 def stopAllServices(self): 212 215 """Stop any services started with the addService method""" 213 216 if hasattr(self, 'services'): -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/saml_pip.cfg
r7314 r7358 20 20 saml_pip.mappingFilePath = %(here)s/pip-mapping.txt 21 21 22 # Cache assertions retrieved from the Attribute Authority to optimise performance 23 saml_pip.sessionCacheDataDir = %(here)s/query-results-cache 24 22 25 # The attribute ID of the subject value to extract from the XACML request 23 26 # context and pass in the SAML attribute query … … 27 30 saml_pip.attributeQuery.issuerFormat = urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName 28 31 29 # These settings configure SSL mutual authentication for the query to the SAML Attribute Authority 32 # These settings configure SSL mutual authentication for the query to the SAML 33 # Attribute Authority 30 34 saml_pip.attributeQuery.sslCertFilePath = $NDGSEC_TEST_CONFIG_DIR/pki/localhost.crt 31 35 saml_pip.attributeQuery.sslPriKeyFilePath = $NDGSEC_TEST_CONFIG_DIR/pki/localhost.key -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/test_saml_pip.py
r7339 r7358 15 15 from os import path 16 16 import unittest 17 18 from urllib2 import URLError 17 19 18 20 from ndg.xacml.core.attributedesignator import SubjectAttributeDesignator … … 45 47 46 48 attributeValueClassFactory = AttributeValueClassFactory() 47 48 def __init__(self, *arg, **kw): 49 BaseTestCase.__init__(self, *arg, **kw) 50 self.startSiteAAttributeAuthority(withSSL=True, 51 port=self.__class__.SITEA_SSL_ATTRIBUTEAUTHORITY_PORTNUM) 52 49 53 50 def test01CreateAndCheckAttributes(self): 54 51 pip = PIP() … … 60 57 except AttributeError: 61 58 pass 59 60 setattr(pip, 'sessionCacheDataDir', 'My data dir') 62 61 63 62 def test02ReadMappingFile(self): … … 86 85 87 86 return ctx 88 89 def test03Query(self): 87 88 def _createPIP(self): 89 """Create PIP from test attribute settings""" 90 90 pip = PIP() 91 91 pip.mappingFilePath = self.__class__.MAPPING_FILEPATH … … 102 102 103 103 pip.attributeQueryBinding.sslCACertDir = self.__class__.CACERT_DIR 104 105 # Make attribute designator - in practice this would be passed back from 106 # the PDP via the context handler 104 105 return pip 106 107 def _createSubjectAttributeDesignator(self): 108 '''Make attribute designator - in practice this would be passed back 109 from the PDP via the context handler 110 ''' 107 111 designator = SubjectAttributeDesignator() 108 112 designator.attributeId = self.__class__.NDGS_ATTR_ID … … 112 116 'http://www.w3.org/2001/XMLSchema#string') 113 117 118 return designator 119 120 def _initQuery(self): 121 '''Convenience method to set-up the parameters needed for a query''' 122 pip = self._createPIP() 123 designator = self._createSubjectAttributeDesignator() 114 124 ctx = self._createXacmlRequestCtx() 125 return pip, designator, ctx 126 127 def test03Query(self): 128 self.startSiteAAttributeAuthority(withSSL=True, 129 port=self.__class__.SITEA_SSL_ATTRIBUTEAUTHORITY_PORTNUM) 130 131 pip, designator, ctx = self._initQuery() 132 133 # Avoid caching to avoid impacting other tests in this class 134 pip.cacheSessions = False 115 135 116 136 attributeValues = pip.attributeQuery(ctx, designator) … … 118 138 print("PIP retrieved attribute values %r" % attributeValues) 119 139 140 self.stopAllServices() 141 120 142 def test04InitFromConfigFile(self): 121 143 # Initialise from settings in a config file 122 144 pip = PIP.fromConfig(self.__class__.CONFIG_FILEPATH) 123 145 self.assert_(pip.mappingFilePath) 124 146 147 def test05SessionCaching(self): 148 self.startSiteAAttributeAuthority(withSSL=True, 149 port=self.__class__.SITEA_SSL_ATTRIBUTEAUTHORITY_PORTNUM) 150 151 pipA, designator, ctx = self._initQuery() 152 attributeValuesA = pipA.attributeQuery(ctx, designator) 153 154 pipB = self._createPIP() 155 pipB.cacheSessions = False 156 157 attributeValuesB = pipB.attributeQuery(ctx, designator) 158 159 self.stopAllServices() 160 161 attributeValuesA2 = pipA.attributeQuery(ctx, designator) 162 self.assert_(len(attributeValuesA2) > 0) 163 164 try: 165 attributeValuesB2 = pipB.attributeQuery(ctx, designator) 166 self.fail("Expected URLError exception for call with no-caching set") 167 except URLError, e: 168 print("Pass: expected %r error for call with no-caching set" % e) 169 170 125 171 126 172 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.