- Timestamp:
- 04/11/10 13:55:40 (10 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test
- Files:
-
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/site-a.ini
r7164 r7698 60 60 61 61 # Specialisation to incorporate ESG Group/Role type 62 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML62 saml.soapbinding.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 63 63 64 64 saml.soapbinding.mountPath = /AttributeAuthority -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/sitea_attributeinterface.py
r7077 r7698 15 15 16 16 from ndg.saml.common.xml import SAMLConstants 17 from ndg.saml.saml2.core import (Assertion, Attribute, AttributeStatement, Issuer,18 SAMLVersion, Subject, NameID, Conditions,19 XSStringAttributeValue)17 from ndg.saml.saml2.core import (Assertion, Attribute, AttributeStatement, 18 Issuer, SAMLVersion, Subject, NameID, 19 Conditions, XSStringAttributeValue) 20 20 21 from ndg.security.common.saml_utils.esgf import (ESGFSamlNamespaces, 22 ESGFGroupRoleAttributeValue) 21 23 from ndg.security.common.X509 import X500DN 22 24 from ndg.security.server.attributeauthority import (AttributeInterface, … … 34 36 35 37 SAML_ATTRIBUTE_NAMES = ATTRIBUTE_NAMES + ( 36 'urn:esg:email:address', 37 'urn:esg:first:name', 38 'urn:esg:last:name' 38 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME, 39 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME, 40 ESGFSamlNamespaces.LASTNAME_ATTRNAME, 41 'urn:esg:sitea:grouprole' 39 42 ) 40 43 … … 43 46 ('p.kershaw@somewhere.ac.uk',), 44 47 ('Philip',), 45 ('Kershaw',) 48 ('Kershaw',), 49 (('siteagroup', 'default'),) 46 50 ) 47 51 … … 49 53 "EmailAddress", 50 54 "FirstName", 51 "LastName" 55 "LastName", 56 "groupRole" 52 57 ) 53 SAML_ATTRIBUTE_FORMATS = (SAMLConstants.XSD_NS+"#"+\ 54 XSStringAttributeValue.TYPE_LOCAL_NAME,) * \ 55 len(SAML_ATTRIBUTE_NAMES) 58 SAML_ATTRIBUTE_FORMATS = ( 59 SAMLConstants.XSD_NS+"#"+XSStringAttributeValue.TYPE_LOCAL_NAME,) * ( 60 len(SAML_ATTRIBUTE_NAMES)-1) + \ 61 (ESGFGroupRoleAttributeValue.TYPE_LOCAL_NAME, ) 62 56 63 SAML_ATTRIBUTES = [] 57 64 65 name, val, vals, format, friendlyName = (None, None, None, None, None) 58 66 for name, vals, format, friendlyName in zip(SAML_ATTRIBUTE_NAMES, 59 SAML_ATTRIBUTE_VALUES,60 SAML_ATTRIBUTE_FORMATS,61 SAML_ATTRIBUTE_FRIENDLY_NAMES):67 SAML_ATTRIBUTE_VALUES, 68 SAML_ATTRIBUTE_FORMATS, 69 SAML_ATTRIBUTE_FRIENDLY_NAMES): 62 70 SAML_ATTRIBUTES.append(Attribute()) 63 71 SAML_ATTRIBUTES[-1].name = name … … 65 73 SAML_ATTRIBUTES[-1].friendlyName = friendlyName 66 74 for val in vals: 67 SAML_ATTRIBUTES[-1].attributeValues.append(XSStringAttributeValue()) 68 SAML_ATTRIBUTES[-1].attributeValues[-1].value = val 75 if isinstance(val, tuple): 76 SAML_ATTRIBUTES[-1].attributeValues.append( 77 ESGFGroupRoleAttributeValue()) 78 SAML_ATTRIBUTES[-1].attributeValues[-1].value = val 79 else: 80 SAML_ATTRIBUTES[-1].attributeValues.append( 81 XSStringAttributeValue()) 82 SAML_ATTRIBUTES[-1].attributeValues[-1].value = val 69 83 70 84 del name, val, vals, format, friendlyName -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/integration/full_system/securityservices.ini
r7517 r7698 377 377 378 378 # Specialisation to incorporate ESG Group/Role type 379 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML379 saml.soapbinding.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 380 380 381 381 saml.soapbinding.mountPath = /AttributeAuthority -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthority/test_attributeauthority.py
r7077 r7698 37 37 StatusCode) 38 38 from ndg.saml.xml import XMLConstants 39 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces39 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 40 40 41 41 THIS_DIR = path.dirname(__file__) … … 139 139 # Define queries for SAML attribute names 140 140 attributeInterface.samlAttribute2SqlQuery_firstName = '"%s" "%s"' % ( 141 E sgSamlNamespaces.FIRSTNAME_ATTRNAME,141 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME, 142 142 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY) 143 143 144 144 setattr(attributeInterface, 145 145 'samlAttribute2SqlQuery.lastName', 146 "%s %s" % (E sgSamlNamespaces.LASTNAME_ATTRNAME,146 "%s %s" % (ESGFSamlNamespaces.LASTNAME_ATTRNAME, 147 147 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY)) 148 148 149 149 attributeInterface.samlAttribute2SqlQuery[ 150 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME] = (150 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME] = ( 151 151 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY) 152 152 … … 170 170 171 171 'samlAttribute2SqlQuery.firstname': '"%s" "%s"' % ( 172 E sgSamlNamespaces.FIRSTNAME_ATTRNAME,172 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME, 173 173 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY), 174 174 175 175 'samlAttribute2SqlQuery.blah': '"%s" "%s"' % ( 176 E sgSamlNamespaces.LASTNAME_ATTRNAME,176 ESGFSamlNamespaces.LASTNAME_ATTRNAME, 177 177 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY), 178 178 179 179 'samlAttribute2SqlQuery.3': '%s "%s"' % ( 180 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME,180 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME, 181 181 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY), 182 182 … … 195 195 self.assert_( 196 196 attributeInterface.samlAttribute2SqlQuery[ 197 E sgSamlNamespaces.FIRSTNAME_ATTRNAME] == \197 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME] == \ 198 198 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY) 199 199 … … 219 219 self.assert_( 220 220 attributeInterface.samlAttribute2SqlQuery[ 221 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME] == \221 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME] == \ 222 222 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY) 223 223 … … 239 239 attributeQuery.subject = Subject() 240 240 attributeQuery.subject.nameID = NameID() 241 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT241 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 242 242 attributeQuery.subject.nameID.value = \ 243 243 SQLAlchemyAttributeInterfaceTestCase.OPENID_URI 244 244 245 245 fnAttribute = Attribute() 246 fnAttribute.name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME246 fnAttribute.name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 247 247 fnAttribute.nameFormat = XSStringAttributeValue.DEFAULT_FORMAT 248 248 fnAttribute.friendlyName = "FirstName" … … 251 251 252 252 lnAttribute = Attribute() 253 lnAttribute.name = E sgSamlNamespaces.LASTNAME_ATTRNAME253 lnAttribute.name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 254 254 lnAttribute.nameFormat = XSStringAttributeValue.DEFAULT_FORMAT 255 255 lnAttribute.friendlyName = "LastName" … … 258 258 259 259 emailAddressAttribute = Attribute() 260 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME260 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 261 261 emailAddressAttribute.nameFormat = XSStringAttributeValue.DEFAULT_FORMAT 262 262 emailAddressAttribute.friendlyName = "EmailAddress" … … 295 295 # Define queries for SAML attribute names 296 296 samlAttribute2SqlQuery = { 297 E sgSamlNamespaces.FIRSTNAME_ATTRNAME:297 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME: 298 298 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY, 299 299 300 E sgSamlNamespaces.LASTNAME_ATTRNAME:300 ESGFSamlNamespaces.LASTNAME_ATTRNAME: 301 301 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY, 302 302 303 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME:303 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME: 304 304 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY, 305 305 … … 357 357 attributeQuery.subject = Subject() 358 358 attributeQuery.subject.nameID = NameID() 359 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT359 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 360 360 attributeQuery.subject.nameID.value = \ 361 361 SQLAlchemyAttributeInterfaceTestCase.OPENID_URI 362 362 363 363 emailAddressAttribute = Attribute() 364 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME364 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 365 365 emailAddressAttribute.nameFormat = "InvalidFormat" 366 366 emailAddressAttribute.friendlyName = "EmailAddress" … … 399 399 # Define queries for SAML attribute names 400 400 samlAttribute2SqlQuery = { 401 E sgSamlNamespaces.FIRSTNAME_ATTRNAME:401 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME: 402 402 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY, 403 403 404 E sgSamlNamespaces.LASTNAME_ATTRNAME:404 ESGFSamlNamespaces.LASTNAME_ATTRNAME: 405 405 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY, 406 406 407 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME:407 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME: 408 408 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY, 409 409 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.cfg
r7164 r7698 34 34 saml.deserialise = ndg.saml.xml.etree:ResponseElementTree.fromXML 35 35 36 [test05AttributeQuerySOAPBindingInterface] 36 [test05AttributeQueryWithESGFAttributeType] 37 uri = http://localhost:5000/AttributeAuthority/ 38 subject = https://openid.localhost/philip.kershaw 39 prefix = saml. 40 saml.serialise = ndg.saml.xml.etree:AttributeQueryElementTree.toXML 41 saml.deserialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.fromXML 42 43 [test06AttributeQuerySOAPBindingInterface] 37 44 uri = http://localhost:5000/AttributeAuthority/ 38 45 subject = https://openid.localhost/philip.kershaw 39 46 40 [test0 6AttributeQueryFromConfig]47 [test07AttributeQueryFromConfig] 41 48 uri = http://localhost:5000/AttributeAuthority/ 42 49 subject = https://openid.localhost/philip.kershaw … … 48 55 attributeQuery.queryAttributes.roles = urn:siteA:security:authz:1.0:attr, , http://www.w3.org/2001/XMLSchema#string 49 56 50 [test0 7AttributeQuerySslSOAPBindingInterface]57 [test08AttributeQuerySslSOAPBindingInterface] 51 58 uri = https://localhost:5443/AttributeAuthority/ 52 59 subject = https://openid.localhost/philip.kershaw -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.py
r7155 r7698 28 28 AttributeQuerySOAPBinding, 29 29 AttributeQuerySslSOAPBinding) 30 from ndg.security.common.saml_utils.esg import (EsgSamlNamespaces, 31 EsgDefaultQueryAttributes) 30 from ndg.security.common.saml_utils.esgf import (ESGFSamlNamespaces, 31 ESGFDefaultQueryAttributes, 32 ESGFGroupRoleAttributeValue) 33 from ndg.security.common.saml_utils.esgf.xml.etree import ( 34 ESGFGroupRoleAttributeValueElementTree, 35 ESGFResponseElementTree) 36 from ndg.security.common.utils.etree import prettyPrint 32 37 from ndg.security.test.unit.attributeauthorityclient import \ 33 38 AttributeAuthorityClientBaseTestCase 34 from ndg.security.common.utils.etree import prettyPrint 35 39 36 40 37 41 class AttributeAuthoritySAMLInterfaceTestCase( … … 64 68 attributeQuery.subject = Subject() 65 69 attributeQuery.subject.nameID = NameID() 66 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT70 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 67 71 attributeQuery.subject.nameID.value = _cfg['subject'] 68 72 xsStringNs = SAMLConstants.XSD_NS+"#"+\ 69 73 XSStringAttributeValue.TYPE_LOCAL_NAME 70 74 fnAttribute = Attribute() 71 fnAttribute.name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME75 fnAttribute.name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 72 76 fnAttribute.nameFormat = xsStringNs 73 77 fnAttribute.friendlyName = "FirstName" … … 76 80 77 81 lnAttribute = Attribute() 78 lnAttribute.name = E sgSamlNamespaces.LASTNAME_ATTRNAME82 lnAttribute.name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 79 83 lnAttribute.nameFormat = xsStringNs 80 84 lnAttribute.friendlyName = "LastName" … … 83 87 84 88 emailAddressAttribute = Attribute() 85 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME89 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 86 90 emailAddressAttribute.nameFormat = xsStringNs 87 91 emailAddressAttribute.friendlyName = "emailAddress" … … 132 136 attributeQuery.subject = Subject() 133 137 attributeQuery.subject.nameID = NameID() 134 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT138 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 135 139 attributeQuery.subject.nameID.value = _cfg['subject'] 136 140 xsStringNs = SAMLConstants.XSD_NS+"#"+\ … … 172 176 attributeQuery.subject = Subject() 173 177 attributeQuery.subject.nameID = NameID() 174 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT178 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 175 179 attributeQuery.subject.nameID.value = _cfg['subject'] 176 180 xsStringNs = SAMLConstants.XSD_NS+"#"+\ … … 212 216 attributeQuery.subject = Subject() 213 217 attributeQuery.subject.nameID = NameID() 214 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT218 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 215 219 attributeQuery.subject.nameID.value = _cfg['subject'] 216 220 xsStringNs = SAMLConstants.XSD_NS+"#"+\ … … 238 242 self.assert_(response.status.statusCode.value==\ 239 243 StatusCode.INVALID_ATTR_NAME_VALUE_URI) 240 241 def test05AttributeQuerySOAPBindingInterface(self): 242 _cfg = self.cfg['test05AttributeQuerySOAPBindingInterface'] 244 245 def test05AttributeQueryWithESGFAttributeType(self): 246 # Test interface with custom ESGF Group/Role attribute type 247 thisSection = 'test05AttributeQueryWithESGFAttributeType' 248 _cfg = self.cfg[thisSection] 249 250 attributeQuery = AttributeQuery() 251 attributeQuery.version = SAMLVersion(SAMLVersion.VERSION_20) 252 attributeQuery.id = str(uuid4()) 253 attributeQuery.issueInstant = datetime.utcnow() 254 255 attributeQuery.issuer = Issuer() 256 attributeQuery.issuer.format = Issuer.X509_SUBJECT 257 attributeQuery.issuer.value = "/CN=Authorisation Service/O=Site A" 258 259 attributeQuery.subject = Subject() 260 attributeQuery.subject.nameID = NameID() 261 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 262 attributeQuery.subject.nameID.value = _cfg['subject'] 263 264 groupRoleAttribute = Attribute() 265 groupRoleAttribute.name = 'urn:esg:sitea:grouprole' 266 groupRoleAttribute.nameFormat = \ 267 ESGFGroupRoleAttributeValue.TYPE_LOCAL_NAME 268 269 attributeQuery.attributes.append(groupRoleAttribute) 270 271 binding = SOAPBinding.fromConfig( 272 AttributeAuthoritySAMLInterfaceTestCase.CONFIG_FILEPATH, 273 prefix='saml.', 274 section=thisSection) 275 276 response = binding.send(attributeQuery, _cfg['uri']) 277 278 samlResponseElem = ResponseElementTree.toXML(response) 279 280 print("SAML Response ...") 281 print(ElementTree.tostring(samlResponseElem)) 282 print("Pretty print SAML Response ...") 283 print(prettyPrint(samlResponseElem)) 284 285 self.assert_(response.assertions[0].attributeStatements[0].attributes[0 286 ].attributeValues[0].value == ('siteagroup', 'default')) 287 288 self.assert_(response.status.statusCode.value == StatusCode.SUCCESS_URI) 289 290 def test06AttributeQuerySOAPBindingInterface(self): 291 _cfg = self.cfg['test06AttributeQuerySOAPBindingInterface'] 243 292 244 293 binding = AttributeQuerySOAPBinding() 245 294 246 295 binding.subjectID = AttributeAuthoritySAMLInterfaceTestCase.OPENID_URI 247 binding.subjectIdFormat = E sgSamlNamespaces.NAMEID_FORMAT296 binding.subjectIdFormat = ESGFSamlNamespaces.NAMEID_FORMAT 248 297 binding.issuerName = \ 249 298 str(AttributeAuthoritySAMLInterfaceTestCase.VALID_REQUESTOR_IDS[0]) 250 299 binding.issuerFormat = Issuer.X509_SUBJECT 251 300 252 binding.queryAttributes = E sgDefaultQueryAttributes.ATTRIBUTES301 binding.queryAttributes = ESGFDefaultQueryAttributes.ATTRIBUTES 253 302 254 303 response = binding.send(uri=_cfg['uri']) … … 262 311 self.assert_(response.status.statusCode.value==StatusCode.SUCCESS_URI) 263 312 264 def test0 6AttributeQueryFromConfig(self):265 thisSection = 'test0 6AttributeQueryFromConfig'313 def test07AttributeQueryFromConfig(self): 314 thisSection = 'test07AttributeQueryFromConfig' 266 315 _cfg = self.cfg[thisSection] 267 316 … … 280 329 self.assert_(response.status.statusCode.value==StatusCode.SUCCESS_URI) 281 330 282 def test0 7AttributeQuerySslSOAPBindingInterface(self):283 thisSection = 'test0 7AttributeQuerySslSOAPBindingInterface'331 def test08AttributeQuerySslSOAPBindingInterface(self): 332 thisSection = 'test08AttributeQuerySslSOAPBindingInterface' 284 333 _cfg = self.cfg[thisSection] 285 334 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/saml_ctx_handler.cfg
r7339 r7698 21 21 saml_ctx_handler.issuerFormat = urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName 22 22 saml_ctx_handler.assertionLifetime = 86400 23 24 # Add Earth System Grid custom types and functions to XACML 25 saml_ctx_handler.xacmlExtFunc = ndg.security.server.xacml.esgf_ext:addEsgfXacmlSupport 23 26 24 27 # -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/saml_pip.cfg
r7358 r7698 23 23 saml_pip.sessionCacheDataDir = %(here)s/query-results-cache 24 24 25 # Timeout cache in 30mins 26 saml_pip.sessionCacheTimeout = 1800 27 25 28 # The attribute ID of the subject value to extract from the XACML request 26 29 # context and pass in the SAML attribute query -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/test_saml_ctx_handler.py
r7339 r7698 56 56 self.assert_(handler.issuerFormat) 57 57 self.assert_(handler.assertionLifetime) 58 self.assert_(handler.xacmlExtFunc) 59 58 60 59 61 if __name__ == "__main__": -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/test_saml_pip.py
r7517 r7698 59 59 60 60 setattr(pip, 'sessionCacheDataDir', 'My data dir') 61 self.assert_(pip.sessionCacheDataDir == 'My data dir') 62 self.assert_(pip.sessionCacheTimeout is None) 63 64 try: 65 pip.sessionCacheTimeout = {} 66 self.fail("pip.sessionCacheTimeout accepts only float/int/long/" 67 "string or None type value") 68 except TypeError: 69 pass 70 71 pip.sessionCacheTimeout = 86400L 72 self.assert_(pip.sessionCacheTimeout == 86400L) 61 73 62 74 def test02ReadMappingFile(self): … … 69 81 print(pip.attribute2AttributeAuthorityMap) 70 82 71 def _createXacmlRequestCtx(self): 83 @classmethod 84 def _createXacmlRequestCtx(cls): 85 """Helper to create a XACML request context""" 72 86 ctx = Request() 73 87 … … 75 89 openidAttr = Attribute() 76 90 ctx.subjects[-1].attributes.append(openidAttr) 77 openidAttr.attributeId = self.__class__.OPENID_ATTR_ID91 openidAttr.attributeId = cls.OPENID_ATTR_ID 78 92 openidAttr.dataType = 'http://www.w3.org/2001/XMLSchema#anyURI' 79 93 80 anyUriAttrValue = self.__class__.attributeValueClassFactory( 81 openidAttr.dataType) 94 anyUriAttrValue = cls.attributeValueClassFactory(openidAttr.dataType) 82 95 83 openidAttrVal = anyUriAttrValue( self.__class__.OPENID_URI)96 openidAttrVal = anyUriAttrValue(cls.OPENID_URI) 84 97 openidAttr.attributeValues.append(openidAttrVal) 85 98 86 99 return ctx 87 100 88 def _createPIP(self): 101 @classmethod 102 def _createPIP(cls): 89 103 """Create PIP from test attribute settings""" 90 104 pip = PIP() 91 pip.mappingFilePath = self.__class__.MAPPING_FILEPATH105 pip.mappingFilePath = cls.MAPPING_FILEPATH 92 106 pip.readMappingFile() 93 pip.subjectAttributeId = self.__class__.OPENID_ATTR_ID107 pip.subjectAttributeId = cls.OPENID_ATTR_ID 94 108 95 109 pip.attributeQueryBinding.issuerName = \ 96 'O=NDG, OU=Security, CN=localhost'110 'O=NDG, OU=Security, CN=localhost' 97 111 pip.attributeQueryBinding.issuerFormat = SamlIssuer.X509_SUBJECT 98 pip.attributeQueryBinding.sslCertFilePath = \ 99 self.__class__.CLNT_CERT_FILEPATH 100 pip.attributeQueryBinding.sslPriKeyFilePath = \ 101 self.__class__.CLNT_PRIKEY_FILEPATH 112 pip.attributeQueryBinding.sslCertFilePath = cls.CLNT_CERT_FILEPATH 113 pip.attributeQueryBinding.sslPriKeyFilePath = cls.CLNT_PRIKEY_FILEPATH 102 114 103 pip.attributeQueryBinding.sslCACertDir = self.__class__.CACERT_DIR115 pip.attributeQueryBinding.sslCACertDir = cls.CACERT_DIR 104 116 105 117 return pip 106 118 107 def _createSubjectAttributeDesignator(self): 119 @classmethod 120 def _createSubjectAttributeDesignator(cls): 108 121 '''Make attribute designator - in practice this would be passed back 109 122 from the PDP via the context handler 110 123 ''' 111 124 designator = SubjectAttributeDesignator() 112 designator.attributeId = self.__class__.NDGS_ATTR_ID125 designator.attributeId = cls.NDGS_ATTR_ID 113 126 designator.dataType = 'http://www.w3.org/2001/XMLSchema#string' 114 127 115 stringAttrValue = self.__class__.attributeValueClassFactory(128 stringAttrValue = cls.attributeValueClassFactory( 116 129 'http://www.w3.org/2001/XMLSchema#string') 117 130 118 131 return designator 119 132 120 def _initQuery(self): 133 @classmethod 134 def _initQuery(cls): 121 135 '''Convenience method to set-up the parameters needed for a query''' 122 pip = self._createPIP()123 designator = self._createSubjectAttributeDesignator()124 ctx = self._createXacmlRequestCtx()136 pip = cls._createPIP() 137 designator = cls._createSubjectAttributeDesignator() 138 ctx = cls._createXacmlRequestCtx() 125 139 return pip, designator, ctx 126 140 … … 129 143 port=self.__class__.SITEA_SSL_ATTRIBUTEAUTHORITY_PORTNUM) 130 144 131 pip, designator, ctx = self._ initQuery()145 pip, designator, ctx = self.__class__._initQuery() 132 146 133 147 # Avoid caching to avoid impacting other tests in this class … … 144 158 pip = PIP.fromConfig(self.__class__.CONFIG_FILEPATH) 145 159 self.assert_(pip.mappingFilePath) 160 self.assert_(pip.sessionCacheTimeout == 1800) 146 161 147 162 # TODO: fix test - left out for now because can't get threading to correctly -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/myproxy/certificate_extapp/test_saml_attribute_assertion.py
r7517 r7698 19 19 import unittest 20 20 21 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces21 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 22 22 from ndg.security.test.unit import BaseTestCase 23 23 from ndg.security.server.myproxy.certificate_extapp.saml_attribute_assertion \ … … 53 53 "/CN=Authorisation Service/O=Site A" 54 54 myProxyCertExtApp.attributeQuery.subjectIdFormat = \ 55 E sgSamlNamespaces.NAMEID_FORMAT55 ESGFSamlNamespaces.NAMEID_FORMAT 56 56 myProxyCertExtApp.attributeQuery.subjectID = \ 57 57 CertExtAppTestCase.OPENID_URI … … 86 86 87 87 myProxyCertExtApp.attributeQuery.subjectIdFormat = \ 88 E sgSamlNamespaces.NAMEID_FORMAT88 ESGFSamlNamespaces.NAMEID_FORMAT 89 89 myProxyCertExtApp.attributeQuery.sslCACertDir = \ 90 90 CertExtAppTestCase.CACERT_DIR -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/attributeauthority/test.ini
r7077 r7698 46 46 47 47 # Specialisation to incorporate ESG Group/Role type 48 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML48 saml.soapbinding.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 49 49 50 50 saml.soapbinding.pathMatchList = /AttributeAuthority -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/attribute-interface.ini
r7153 r7698 28 28 29 29 # Specialisation to incorporate ESG Group/Role type 30 saml.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML30 saml.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 31 31 32 32 #______________________________________________________________________________ -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/policy.xml
r7444 r7698 96 96 </Condition> 97 97 </Rule> 98 <Rule RuleId="Rule with ESGF Custom types" Effect="Permit"> 99 <Target> 100 <Resources> 101 <Resource> 102 <ResourceMatch MatchId="urn:oasis:names:tc:xacml:2.0:function:anyURI-regexp-match"> 103 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">^http://localhost/test_esgf$</AttributeValue> 104 <ResourceAttributeDesignator 105 AttributeId="urn:siteA:security:authz:1.0:attr:resourceURI" 106 DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> 107 </ResourceMatch> 108 </Resource> 109 </Resources> 110 </Target> 111 <Condition> 112 <Apply FunctionId="urn:esg:security:xacml:2.0:function:grouprole-at-least-one-member-of"> 113 <SubjectAttributeDesignator 114 AttributeId="urn:ndg:security:authz:1.0:attr" 115 DataType="grouprole"/> 116 <Apply FunctionId="urn:esg:security:xacml:2.0:function:grouprole-bag"> 117 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">forbidden</AttributeValue> 118 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">keepout</AttributeValue> 119 </Apply> 120 </Apply> 121 </Condition> 122 </Rule> 98 123 </Policy> -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/test_soapattributeinterface.py
r7077 r7698 22 22 23 23 from ndg.security.common.soap.etree import SOAPEnvelope 24 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces24 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 25 25 from ndg.security.test.unit.wsgi.saml import SoapSamlInterfaceMiddlewareTestCase 26 26 … … 44 44 attributeQuery.subject = Subject() 45 45 attributeQuery.subject.nameID = NameID() 46 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT46 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 47 47 attributeQuery.subject.nameID.value = subject 48 48 … … 50 50 # special case handling for 'FirstName' attribute 51 51 fnAttribute = Attribute() 52 fnAttribute.name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME52 fnAttribute.name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 53 53 fnAttribute.nameFormat = "http://www.w3.org/2001/XMLSchema#string" 54 54 fnAttribute.friendlyName = "FirstName" … … 58 58 # special case handling for 'LastName' attribute 59 59 lnAttribute = Attribute() 60 lnAttribute.name = E sgSamlNamespaces.LASTNAME_ATTRNAME60 lnAttribute.name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 61 61 lnAttribute.nameFormat = "http://www.w3.org/2001/XMLSchema#string" 62 62 lnAttribute.friendlyName = "LastName" … … 66 66 # special case handling for 'LastName' attribute 67 67 emailAddressAttribute = Attribute() 68 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME68 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 69 69 emailAddressAttribute.nameFormat = XMLConstants.XSD_NS+"#"+\ 70 70 XSStringAttributeValue.TYPE_LOCAL_NAME -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/test_soapauthzdecisioninterface.py
r7153 r7698 22 22 23 23 from ndg.security.common.soap.etree import SOAPEnvelope 24 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces24 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 25 25 from ndg.security.test.unit.wsgi.saml import SoapSamlInterfaceMiddlewareTestCase 26 26 … … 115 115 query.subject = Subject() 116 116 query.subject.nameID = NameID() 117 query.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT117 query.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 118 118 query.subject.nameID.value = subject 119 119
Note: See TracChangeset
for help on using the changeset viewer.