Changeset 6575 for TI12-security/trunk/NDGSecurity
- Timestamp:
- 15/02/10 12:39:45 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python
- Files:
-
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/authz/__init__.py
r6570 r6575 753 753 Information Point interface. This retrieves attributes over the SOAP/SAML 754 754 Attribute Authority interface 755 (ndg.security.server.wsgi.saml. SOAPAttributeInterfaceMiddleware) and caches755 (ndg.security.server.wsgi.saml.attributeinterface.SOAPAttributeInterfaceMiddleware) and caches 756 756 SAML Assertions in a 757 757 ndg.security.common.credentialWallet.SAMLCredentialWallet -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/saml/attributeinterface.py
r6573 r6575 39 39 40 40 class SOAPAttributeInterfaceMiddleware(SOAPMiddleware, NDGSecurityPathFilter): 41 """Implementation of SAML 2.0 SOAP Binding for Assertion Query/Request 42 Profile 41 """Implementation of SAML 2.0 SOAP Binding for Attribute Query 43 42 44 43 @type PATH_OPTNAME: basestring -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/saml/authzinterface.py
r6573 r6575 36 36 37 37 38 class SOAPAuthzDecisionInterfaceMiddleware(SOAPMiddleware, NDGSecurityPathFilter):39 """Implementation of SAML 2.0 SOAP Binding for Assertion Query/Request40 Profile38 class SOAPAuthzDecisionInterfaceMiddleware(SOAPMiddleware, 39 NDGSecurityPathFilter): 40 """Implementation of SAML 2.0 SOAP Binding for Authorisation Decision Query 41 41 42 42 @type PATH_OPTNAME: basestring … … 54 54 QUERY_INTERFACE_KEYNAME_OPTNAME = "queryInterfaceKeyName" 55 55 DEFAULT_QUERY_INTERFACE_KEYNAME = ("ndg.security.server.wsgi.saml." 56 "SOAPAuthzDecisionInterfaceMiddleware.queryInterface") 56 "SOAPAuthzDecisionInterfaceMiddleware." 57 "queryInterface") 57 58 58 59 def __init__(self, app): … … 76 77 self.__queryInterfaceKeyName = None 77 78 78 self.pathMatchList = app_conf.get(79 prefix + SOAPAuthzDecisionInterfaceMiddleware.PATH_OPTNAME, ['/'])79 cls = SOAPAuthzDecisionInterfaceMiddleware 80 self.pathMatchList = app_conf.get(prefix + cls.PATH_OPTNAME, ['/']) 80 81 81 self.queryInterfaceKeyName = app_conf.get(prefix + \ 82 SOAPAuthzDecisionInterfaceMiddleware.QUERY_INTERFACE_KEYNAME_OPTNAME, 83 prefix + \ 84 SOAPAuthzDecisionInterfaceMiddleware.DEFAULT_QUERY_INTERFACE_KEYNAME) 82 self.queryInterfaceKeyName = app_conf.get( 83 prefix + cls.QUERY_INTERFACE_KEYNAME_OPTNAME, 84 prefix + cls.DEFAULT_QUERY_INTERFACE_KEYNAME) 85 85 86 86 @classmethod … … 109 109 def _setQueryInterfaceKeyName(self, value): 110 110 if not isinstance(value, basestring): 111 raise TypeError('Expecting string type for "queryInterfaceKeyName" '112 ' 111 raise TypeError('Expecting string type for "queryInterfaceKeyName" ' 112 'got %r' % value) 113 113 114 114 self.__queryInterfaceKeyName = value … … 116 116 queryInterfaceKeyName = property(fget=_getQueryInterfaceKeyName, 117 117 fset=_setQueryInterfaceKeyName, 118 doc="environ keyname for A ttribute Query"119 " interface")118 doc="environ keyname for Authorisation " 119 "Decision Query interface") 120 120 121 121 def _getIssuerName(self): … … 150 150 soapRequestStream = environ.get('wsgi.input') 151 151 if soapRequestStream is None: 152 raise SOAPAuthzDecisionInterfaceMiddlewareError('No "wsgi.input" in'153 'environ')152 raise SOAPAuthzDecisionInterfaceMiddlewareError('No "wsgi.input" ' 153 'in environ') 154 154 155 155 # TODO: allow for chunked data 156 156 contentLength = environ.get('CONTENT_LENGTH') 157 157 if contentLength is None: 158 raise SOAPAuthzDecisionInterfaceMiddlewareError( 'No "CONTENT_LENGTH" '159 'in environ')158 raise SOAPAuthzDecisionInterfaceMiddlewareError( 159 'No "CONTENT_LENGTH" in environ') 160 160 161 161 contentLength = int(contentLength) … … 166 166 soapRequest.parse(StringIO(soapRequestTxt)) 167 167 168 # Filter based on SOAP Body content - expecting an A ttributeQuery168 # Filter based on SOAP Body content - expecting an AuthzDecisionQuery 169 169 # element 170 if not SOAPAuthzDecisionInterfaceMiddleware.isA ttributeQuery(170 if not SOAPAuthzDecisionInterfaceMiddleware.isAuthzDecisionQuery( 171 171 soapRequest.body): 172 172 # Reset wsgi.input for middleware and app downstream … … 174 174 return self._app(environ, start_response) 175 175 176 log.debug("SOAPAuthzDecisionInterfaceMiddleware.__call__: received SAML"177 "S OAP AttributeQuery ...")176 log.debug("SOAPAuthzDecisionInterfaceMiddleware.__call__: received " 177 "SAML SOAP AuthzDecisionQuery ...") 178 178 179 a ttributeQueryElem = soapRequest.body.elem[0]179 authzDecisionQueryElem = soapRequest.body.elem[0] 180 180 181 181 try: 182 a ttributeQuery = AttributeQueryElementTree.fromXML(183 attributeQueryElem)182 authzDecisionQuery = AuthzDecisionQueryElementTree.fromXML( 183 authzDecisionQueryElem) 184 184 except UnknownAttrProfile, e: 185 log.exception("Parsing incoming a ttributequery: " % e)185 log.exception("Parsing incoming authorisation decision query: " % e) 186 186 samlResponse = self._makeErrorResponse( 187 187 StatusCode.UNKNOWN_ATTR_PROFILE_URI) … … 195 195 196 196 # Call query interface 197 samlResponse = queryInterface(a ttributeQuery)197 samlResponse = queryInterface(authzDecisionQuery) 198 198 199 199 # Add mapping for ESG Group/Role Attribute Value to enable ElementTree … … 216 216 response = soapResponse.serialize() 217 217 218 log.debug("SOAPAuthzDecisionInterfaceMiddleware.__call__: sending response"219 " ...\n\n%s",218 log.debug("SOAPAuthzDecisionInterfaceMiddleware.__call__: " 219 "sending response ...\n\n%s", 220 220 response) 221 221 start_response("200 OK", … … 225 225 226 226 @classmethod 227 def isA ttributeQuery(cls, soapBody):228 """Check for A ttributeQuery in the SOAP Body"""227 def isAuthzDecisionQuery(cls, soapBody): 228 """Check for AuthzDecisionQuery in the SOAP Body""" 229 229 230 230 if len(soapBody.elem) != 1: 231 231 # TODO: Change to a SOAP Fault? 232 raise SOAPAuthzDecisionInterfaceMiddlewareError("Expecting single " 233 "child element in the " 234 "request SOAP " 235 "Envelope body") 232 raise SOAPAuthzDecisionInterfaceMiddlewareError( 233 "Expecting single child element in the request SOAP " 234 "Envelope body") 236 235 237 236 inputQName = QName(soapBody.elem[0].tag) 238 a ttributeQueryQName = QName.fromGeneric(239 A ttributeQuery.DEFAULT_ELEMENT_NAME)240 return inputQName == a ttributeQueryQName237 authzDecisionQueryQName = QName.fromGeneric( 238 AuthzDecisionQuery.DEFAULT_ELEMENT_NAME) 239 return inputQName == authzDecisionQueryQName 241 240 242 241 def _makeErrorResponse(self, code): -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/attributeCertificateLog/ac.xml
r6440 r6575 3 3 <acInfo> 4 4 <version>1.0</version> 5 <holder> </holder>5 <holder>/CN=client/O=NDG Security Test/OU=WS-Security Unittest</holder> 6 6 <issuer>/CN=AttributeAuthority/O=NDG Security Test/OU=Site A</issuer> 7 7 <issuerName>Site A</issuerName> 8 8 <issuerSerialNumber>253</issuerSerialNumber> 9 <userId> ndg-user</userId>9 <userId>system</userId> 10 10 <validity> 11 <notBefore>2010 0 1 20 08 54 54</notBefore>12 <notAfter>2010 0 1 20 16 54 54</notAfter>11 <notBefore>2010 02 15 11 31 46</notBefore> 12 <notAfter>2010 02 15 19 31 46</notAfter> 13 13 </validity> 14 14 <attributes> … … 33 33 <provenance>original</provenance> 34 34 </acInfo> 35 <ds:Signature><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="ds"></ec:InclusiveNamespaces></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="xmlns"></ec:InclusiveNamespaces></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod><ds:DigestValue> s1dB/p8Cl1SmY0/Jcq+2z2biXHs=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>Sw36kLKRjSro9409KGZ5YPsQrU9FcvkzwO5n3WJ1WQkgDTS2IhGHCW5OB64bL8e3Ub3gdM1WlHC436 ybGYfPOuuVfQ4ZHHfLqQMWA9p5ALRmUTAglSt9/uTPYzc8yk7wCWHNYqMDVPHbHwy5MWyAToCHGx 37 rqJRs9WgozMJMugslJk=</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIICBTCCAW6gAwIBAgICAP0wDQYJKoZIhvcNAQEEBQAwLzEMMAoGA1UEChMDTkRH35 <ds:Signature><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="ds"></ec:InclusiveNamespaces></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="xmlns"></ec:InclusiveNamespaces></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod><ds:DigestValue>el2WOCy3XQ04rzELN8C+GufvDC4=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>mlKZJckdKXhwpOq0ZsKekoFneVP6T38iLBSgsgSwDUwHqxTTOlBqdkTywaL4lu2Jo1KlzZbeUH/r 36 dUilnOs1zAZcl8BAynbXj2LJuGamxLIEFFQJFT7n7ZxAjVwbhbnajscHe3HEYDOxtQrfv5BDvyb/ 37 lgddNkepm2vHbayEH0c=</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIICBTCCAW6gAwIBAgICAP0wDQYJKoZIhvcNAQEEBQAwLzEMMAoGA1UEChMDTkRH 38 38 MQ0wCwYDVQQLEwRCQURDMRAwDgYDVQQDEwdUZXN0IENBMB4XDTA4MTIxNTE2MzUy 39 39 NFoXDTEzMTIxNDE2MzUyNFowSjEaMBgGA1UEChMRTkRHIFNlY3VyaXR5IFRlc3Qx -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/site-a.ini
r5741 r6575 104 104 # SAML SOAP Binding to the Attribute Authority 105 105 [filter:AttributeAuthoritySamlSoapBindingFilter] 106 paste.filter_app_factory = ndg.security.server.wsgi.saml :SOAPAttributeInterfaceMiddleware.filter_app_factory106 paste.filter_app_factory = ndg.security.server.wsgi.saml.attributeinterface:SOAPAttributeInterfaceMiddleware.filter_app_factory 107 107 prefix = saml.soapbinding. 108 108 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/siteb/attributeCertificateLog
- Property svn:ignore
-
old new 1 1 ac.xml 2 2 ac.xml.1 3 ac.xml.10 4 ac.xml.11 5 ac.xml.12 6 ac.xml.13 7 ac.xml.14 8 ac.xml.15 9 ac.xml.16 10 ac.xml.2 11 ac.xml.3 12 ac.xml.4 13 ac.xml.5 14 ac.xml.6 15 ac.xml.7 16 ac.xml.8 17 ac.xml.9
-
- Property svn:ignore
-
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/siteb/site-b.ini
r5678 r6575 100 100 # SAML SOAP Binding to the Attribute Authority 101 101 [filter:AttributeAuthoritySamlSoapBindingFilter] 102 paste.filter_app_factory = ndg.security.server.wsgi.saml :SOAPAttributeInterfaceMiddleware.filter_app_factory102 paste.filter_app_factory = ndg.security.server.wsgi.saml.attributeinterface:SOAPAttributeInterfaceMiddleware.filter_app_factory 103 103 prefix = saml.soapbinding. 104 104 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/integration/authz_lite/securityservices.ini
r6441 r6575 406 406 # SAML SOAP Binding to the Attribute Authority 407 407 [filter:AttributeAuthoritySamlSoapBindingFilter] 408 paste.filter_app_factory = ndg.security.server.wsgi.saml :SOAPAttributeInterfaceMiddleware.filter_app_factory408 paste.filter_app_factory = ndg.security.server.wsgi.saml.attributeinterface:SOAPAttributeInterfaceMiddleware.filter_app_factory 409 409 prefix = saml.soapbinding. 410 410 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.cfg
r6572 r6575 11 11 # use a separate test case class in the test module and is 12 12 # included here 13 [test01 SAMLAttributeQuery]13 [test01AttributeQuery] 14 14 uri = http://localhost:5000/AttributeAuthority/saml 15 15 subject = https://openid.localhost/philip.kershaw 16 16 siteAttributeName = urn:siteA:security:authz:1.0:attr 17 17 18 [test02 SAMLAttributeQueryInvalidIssuer]18 [test02AttributeQueryInvalidIssuer] 19 19 uri = http://localhost:5000/AttributeAuthority/saml 20 20 subject = https://openid.localhost/philip.kershaw 21 21 siteAttributeName = urn:siteA:security:authz:1.0:attr 22 22 23 [test03 SAMLAttributeQueryUnknownSubject]23 [test03AttributeQueryUnknownSubject] 24 24 uri = http://localhost:5000/AttributeAuthority/saml 25 25 subject = https://openid.localhost/unknown 26 26 siteAttributeName = urn:siteA:security:authz:1.0:attr 27 27 28 [test04 SAMLAttributeQueryInvalidAttrName]28 [test04AttributeQueryInvalidAttrName] 29 29 uri = http://localhost:5000/AttributeAuthority/saml 30 30 subject = https://openid.localhost/philip.kershaw -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.py
r6572 r6575 12 12 import logging 13 13 logging.basicConfig(level=logging.DEBUG) 14 import os 14 15 from datetime import datetime 15 16 from uuid import uuid4 … … 37 38 """NDG Attribute Authority SAML SOAP Binding client unit tests""" 38 39 CONFIG_FILENAME = 'test_samlattributeauthorityclient.cfg' 40 CONFIG_FILEPATH = os.path.join(os.environ['NDGSEC_AACLNT_UNITTEST_DIR'], 41 CONFIG_FILENAME) 39 42 40 43 def __init__(self, *arg, **kw): … … 46 49 self.startSiteAAttributeAuthority(withSSL=True, port=5443) 47 50 48 def test01 SAMLAttributeQuery(self):49 _cfg = self.cfg['test01 SAMLAttributeQuery']51 def test01AttributeQuery(self): 52 _cfg = self.cfg['test01AttributeQuery'] 50 53 51 54 attributeQuery = AttributeQuery() … … 114 117 print(prettyPrint(samlResponseElem)) 115 118 116 def test02 SAMLAttributeQueryInvalidIssuer(self):117 _cfg = self.cfg['test02 SAMLAttributeQueryInvalidIssuer']119 def test02AttributeQueryInvalidIssuer(self): 120 _cfg = self.cfg['test02AttributeQueryInvalidIssuer'] 118 121 119 122 attributeQuery = AttributeQuery() … … 154 157 response.status.statusCode.value==StatusCode.REQUEST_DENIED_URI) 155 158 156 def test03 SAMLAttributeQueryUnknownSubject(self):157 _cfg = self.cfg['test03 SAMLAttributeQueryUnknownSubject']159 def test03AttributeQueryUnknownSubject(self): 160 _cfg = self.cfg['test03AttributeQueryUnknownSubject'] 158 161 159 162 attributeQuery = AttributeQuery() … … 193 196 response.status.statusCode.value==StatusCode.UNKNOWN_PRINCIPAL_URI) 194 197 195 def test04 SAMLAttributeQueryInvalidAttrName(self):196 thisSection = 'test04 SAMLAttributeQueryInvalidAttrName'198 def test04AttributeQueryInvalidAttrName(self): 199 thisSection = 'test04AttributeQueryInvalidAttrName' 197 200 _cfg = self.cfg[thisSection] 198 201 … … 220 223 221 224 binding = SOAPBinding.fromConfig( 222 AttributeAuthoritySAMLInterfaceTestCase.CONFIG_FILE NAME,225 AttributeAuthoritySAMLInterfaceTestCase.CONFIG_FILEPATH, 223 226 prefix='saml.', 224 227 section=thisSection) … … 294 297 295 298 self.assert_(response.status.statusCode.value==StatusCode.SUCCESS_URI) 296 297 299 300 def test08AuthzDecisionQuery(self): 301 _cfg = self.cfg['test02AuthzDecisionQuery'] 302 303 query = AuthzDecisionQuery() 304 query.version = SAMLVersion(SAMLVersion.VERSION_20) 305 query.id = str(uuid4()) 306 query.issueInstant = datetime.utcnow() 307 308 query.issuer = Issuer() 309 query.issuer.format = Issuer.X509_SUBJECT 310 query.issuer.value = str( 311 AttributeAuthoritySAMLInterfaceTestCase.VALID_REQUESTOR_IDS[0]) 312 313 query.subject = Subject() 314 query.subject.nameID = NameID() 315 query.subject.nameID.format = EsgSamlNamespaces.NAMEID_FORMAT 316 query.subject.nameID.value = _cfg['subject'] 317 318 binding = SOAPBinding() 319 binding.serialise = AuthzDecisionQueryElementTree.toXML 320 binding.deserialise = ResponseElementTree.fromXML 321 response = binding.send(query, _cfg['uri']) 322 323 samlResponseElem = ResponseElementTree.toXML(response) 324 325 print("SAML Response ...") 326 print(ElementTree.tostring(samlResponseElem)) 327 print("Pretty print SAML Response ...") 328 print(prettyPrint(samlResponseElem)) 329 330 self.assert_( 331 response.status.statusCode.value==StatusCode.REQUEST_DENIED_URI) 332 333 298 334 if __name__ == "__main__": 299 335 unittest.main() -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/__init__.py
r6574 r6575 9 9 __contact__ = "Philip.Kershaw@stfc.ac.uk" 10 10 __revision__ = '$Id: $' 11 import unittest12 11 import os 13 12 import paste.fixture 14 13 from paste.deploy import loadapp 15 14 15 from ndg.security.test.unit import BaseTestCase 16 16 17 17 class TestApp(object): … … 28 28 29 29 30 class S OAPAttributeInterfaceMiddlewareTestCase(unittest.TestCase):30 class SoapSamlInterfaceMiddlewareTestCase(BaseTestCase): 31 31 HERE_DIR = os.path.dirname(os.path.abspath(__file__)) 32 32 CONFIG_FILENAME = 'test.ini' 33 33 34 34 def __init__(self, *args, **kwargs): 35 wsgiapp = loadapp( 36 'config:%s' % \ 37 SOAPAttributeInterfaceMiddlewareTestCase.CONFIG_FILENAME, 38 relative_to=SOAPAttributeInterfaceMiddlewareTestCase.HERE_DIR) 35 wsgiapp = loadapp('config:%s' % self.__class__.CONFIG_FILENAME, 36 relative_to=self.__class__.HERE_DIR) 39 37 40 38 self.app = paste.fixture.TestApp(wsgiapp) -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/attribute-interface.ini
r6574 r6575 18 18 19 19 [app:TestApp] 20 paste.app_factory = ndg.security.test.unit.wsgi.saml .test_soapattributeinterface:TestApp20 paste.app_factory = ndg.security.test.unit.wsgi.saml:TestApp 21 21 22 22 [filter:SAMLSoapAttributeInterfaceFilter] -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/authz-decision-interface.ini
r6574 r6575 18 18 19 19 [app:TestApp] 20 paste.app_factory = ndg.security.test.unit.wsgi.saml .test_soapattributeinterface:TestApp20 paste.app_factory = ndg.security.test.unit.wsgi.saml:TestApp 21 21 22 22 [filter:SAMLSoapAttributeInterfaceFilter] -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/test_soapauthzdecisioninterface.py
r6574 r6575 22 22 from ndg.security.common.soap.etree import SOAPEnvelope 23 23 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces 24 25 26 class SOAPAttributeInterfaceMiddlewareTestCase(unittest.TestCase): 27 CONFIG_FILENAME = 'authz-decision-interface.ini 28 29 def _createAttributeQuery(self, 24 from ndg.security.test.unit.wsgi.saml import SoapSamlInterfaceMiddlewareTestCase 25 26 27 class SOAPAuthzDecisionInterfaceMiddlewareTestCase(unittest.TestCase): 28 CONFIG_FILENAME = 'authz-decision-interface.ini' 29 30 def _createAuthzDecisionQuery(self, 30 31 issuer="/O=Site A/CN=Authorisation Service", 31 32 subject="https://openid.localhost/philip.kershaw"): 32 attributeQuery = AttributeQuery()33 attributeQuery.version = SAMLVersion(SAMLVersion.VERSION_20)34 attributeQuery.id = str(uuid4())35 attributeQuery.issueInstant = datetime.utcnow()36 37 attributeQuery.issuer = Issuer()38 attributeQuery.issuer.format = Issuer.X509_SUBJECT39 attributeQuery.issuer.value = issuer33 query = AttributeQuery() 34 query.version = SAMLVersion(SAMLVersion.VERSION_20) 35 query.id = str(uuid4()) 36 query.issueInstant = datetime.utcnow() 37 38 query.issuer = Issuer() 39 query.issuer.format = Issuer.X509_SUBJECT 40 query.issuer.value = issuer 40 41 41 attributeQuery.subject = Subject()42 attributeQuery.subject.nameID = NameID()43 attributeQuery.subject.nameID.format = EsgSamlNamespaces.NAMEID_FORMAT44 attributeQuery.subject.nameID.value = subject42 query.subject = Subject() 43 query.subject.nameID = NameID() 44 query.subject.nameID.format = EsgSamlNamespaces.NAMEID_FORMAT 45 query.subject.nameID.value = subject 45 46 46 47 … … 51 52 fnAttribute.friendlyName = "FirstName" 52 53 53 attributeQuery.attributes.append(fnAttribute)54 query.attributes.append(fnAttribute) 54 55 55 56 # special case handling for 'LastName' attribute … … 59 60 lnAttribute.friendlyName = "LastName" 60 61 61 attributeQuery.attributes.append(lnAttribute)62 query.attributes.append(lnAttribute) 62 63 63 64 # special case handling for 'LastName' attribute … … 68 69 emailAddressAttribute.friendlyName = "emailAddress" 69 70 70 attributeQuery.attributes.append(emailAddressAttribute)71 72 return attributeQuery73 74 def _makeRequest(self, attributeQuery=None, **kw):71 query.attributes.append(emailAddressAttribute) 72 73 return query 74 75 def _makeRequest(self, query=None, **kw): 75 76 """Convenience method to construct queries for tests""" 76 77 77 if attributeQuery is None:78 attributeQuery = self._createAttributeQuery(**kw)78 if query is None: 79 query = self._createAuthzDecisionQuery(**kw) 79 80 80 elem = A ttributeQueryElementTree.toXML(attributeQuery)81 elem = AuthzDecusionQueryElementTree.toXML(query) 81 82 soapRequest = SOAPEnvelope() 82 83 soapRequest.create() … … 106 107 107 108 def test01ValidQuery(self): 108 attributeQuery = self._createAttributeQuery()109 request = self._makeRequest( attributeQuery=attributeQuery)109 query = self._createAuthzDecisionQuery() 110 request = self._makeRequest(query=query) 110 111 111 112 header = { … … 123 124 self.assert_(samlResponse.status.statusCode.value == \ 124 125 StatusCode.SUCCESS_URI) 125 self.assert_(samlResponse.inResponseTo == attributeQuery.id)126 self.assert_(samlResponse.inResponseTo == query.id) 126 127 self.assert_(samlResponse.assertions[0].subject.nameID.value == \ 127 attributeQuery.subject.nameID.value)128 query.subject.nameID.value) 128 129 129 130 def test02AttributeReleaseDenied(self): … … 149 150 150 151 def test03InvalidAttributesRequested(self): 151 attributeQuery = self._createAttributeQuery()152 query = self._createAuthzDecisionQuery() 152 153 153 154 # Add an unsupported Attribute name … … 157 158 XSStringAttributeValue.TYPE_LOCAL_NAME 158 159 attribute.friendlyName = "myAttribute" 159 attributeQuery.attributes.append(attribute)160 161 request = self._makeRequest( attributeQuery=attributeQuery)160 query.attributes.append(attribute) 161 162 request = self._makeRequest(query=query) 162 163 163 164 header = {
Note: See TracChangeset
for help on using the changeset viewer.