Changeset 6720 for TI12-security/trunk/NDGSecurity
- Timestamp:
- 11/03/10 11:30:36 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python
- Files:
-
- 7 deleted
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/attributeauthority.py
r6719 r6720 123 123 '__propFileSection', 124 124 '__propPrefix', 125 '__attributeInterface', 125 126 '__attributeInterfaceCfg' 126 127 ) … … 140 141 141 142 self.__attributeInterfaceCfg = {} 142 143 144 def __getstate__(self): 145 '''Enable pickling with __slots__''' 146 _dict = {} 147 for attrName in AttributeAuthority.__slots__: 148 # Ugly hack to allow for derived classes setting private member 149 # variables 150 if attrName.startswith('__'): 151 attrName = "_AttributeAuthority" + attrName 152 153 _dict[attrName] = getattr(self, attrName) 154 155 return _dict 156 157 def __setstate__(self, attrDict): 158 '''Enable pickling with __slots__''' 159 for attrName, val in attrDict.items(): 160 setattr(self, attrName, val) 161 162 def _getIssuerName(self): 163 return self.__issuerName 164 165 def _setIssuerName(self, value): 166 if not isinstance(value, basestring): 167 raise TypeError('Expecting string type for "issuerName" attribute; ' 168 'got %r' % type(value)) 169 170 self.__issuerName = value 171 172 issuerName = property(_getIssuerName, _setIssuerName, 173 doc="Name of Attribute Authority organisation " 174 "issuing a response to a query") 175 143 176 def _getAssertionLifetime(self): 144 177 return self.__assertionLifetime 145 146 def _getAttributeInterface(self):147 return self.__attributeInterface148 178 149 179 def _setAssertionLifetime(self, value): … … 156 186 raise TypeError('Expecting float, int, long or string type for ' 157 187 '"assertionLifetime"; got %r' % type(value)) 188 189 def _getAttributeInterface(self): 190 return self.__attributeInterface 158 191 159 192 def _setAttributeInterface(self, value): -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/site-a.ini
r6686 r6720 48 48 49 49 # Lifetime is measured in seconds 50 attributeAuthority.attCertLifetime: 28800 51 52 # Allow an offset for clock skew between servers running 53 # security services. NB, measured in seconds - use a minus sign for time in the 54 # past 55 attributeAuthority.attCertNotBeforeOff: 0 56 57 # Clock skew for SAML Attribute Queries - allow clockSkew number of seconds 58 # tolerance for query issueInstant parameter. Set here to 3 minutes 59 attributeAuthority.clockSkew: 180.0 50 attributeAuthority.assertionLifetime: 28800 60 51 61 52 attributeAuthority.dnSeparator:/ … … 80 71 saml.soapbinding.queryInterfaceKeyName = %(attributeQueryInterfaceEnvironKeyName)s 81 72 73 # Clock skew for SAML Attribute Queries - allow clockSkew number of seconds 74 # tolerance for query issueInstant parameter. Set here to 3 minutes 75 saml.soapbinding.clockSkewTolerance: 180.0 82 76 83 77 # Logging configuration -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthority/test_attributeauthority.py
r6719 r6720 23 23 from datetime import datetime 24 24 from os import path 25 import pickle 25 26 26 27 from ndg.security.test.unit import BaseTestCase … … 46 47 PROPERTIES_FILEPATH = path.join(THIS_DIR, PROPERTIES_FILENAME) 47 48 ISSUER_NAME = '/O=My Organisation/OU=Centre/CN=Attribute Authority' 48 49 ASSERTION_LIFETIME = "86400" 50 49 51 def test01ParsePropertiesFile(self): 50 52 cls = AttributeAuthorityTestCase … … 54 56 self.assert_(aa.issuerName == cls.ISSUER_NAME) 55 57 56 def test02FromProperties(self): 57 58 # Casts from string to float 59 assertionLifetime = "86400" 60 issuerName = 'My issuer' 58 def _createAttributeAuthorityHelper(self): 59 """Helper method to creat an Attribute Authority instance for use with 60 tests 61 """ 62 63 cls = AttributeAuthorityTestCase 64 61 65 attributeInterfaceClassName = ('ndg.security.server.attributeauthority.' 62 66 'AttributeInterface') 63 67 64 aa = AttributeAuthority.fromProperties(issuerName= issuerName,65 assertionLifetime= assertionLifetime,68 aa = AttributeAuthority.fromProperties(issuerName=cls.ISSUER_NAME, 69 assertionLifetime=cls.ASSERTION_LIFETIME, 66 70 attributeInterface_className=attributeInterfaceClassName) 67 71 72 return aa 73 74 def test02FromProperties(self): 75 76 cls = AttributeAuthorityTestCase 77 aa = self._createAttributeAuthorityHelper() 78 68 79 self.assert_(aa) 69 self.assert_(aa.assertionLifetime == float(assertionLifetime)) 70 self.assert_(aa.issuerName == issuerName) 80 81 # Check lifetime property converted from string input to float 82 self.assert_(aa.assertionLifetime == float(cls.ASSERTION_LIFETIME)) 83 self.assert_(aa.issuerName == cls.ISSUER_NAME) 71 84 self.assert_(isinstance(aa.attributeInterface, AttributeInterface)) 72 85 73 86 def test03Pickle(self): 87 # Test pickling with __slots__ 88 aa = self._createAttributeAuthorityHelper() 89 jar = pickle.dumps(aa) 90 aa2 = pickle.loads(jar) 91 92 self.assert_(aa2) 93 self.assert_(aa2.assertionLifetime == aa.assertionLifetime) 94 self.assert_(aa2.issuerName == aa.issuerName) 95 self.assert_(isinstance(aa2.attributeInterface, AttributeInterface)) 96 97 74 98 class SQLAlchemyAttributeInterfaceTestCase(BaseTestCase): 75 99 THIS_DIR = THIS_DIR -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.py
r6615 r6720 20 20 from ndg.saml.common.xml import SAMLConstants 21 21 from ndg.saml.xml.etree import AttributeQueryElementTree, ResponseElementTree 22 from ndg.saml.saml2.core import (Subject, Issuer, Attribute, NameID, AttributeQuery, 23 StatusCode, XSStringAttributeValue, ) 22 from ndg.saml.saml2.core import (Subject, Issuer, Attribute, NameID, 23 AttributeQuery, StatusCode, 24 XSStringAttributeValue) 24 25 25 26 from ndg.security.common.saml_utils.binding.soap import SOAPBinding … … 37 38 AttributeAuthorityClientBaseTestCase): 38 39 """NDG Attribute Authority SAML SOAP Binding client unit tests""" 40 HERE_DIR = os.path.dirname(__file__) 39 41 CONFIG_FILENAME = 'test_samlattributeauthorityclient.cfg' 40 CONFIG_FILEPATH = os.path.join(os.environ['NDGSEC_AACLNT_UNITTEST_DIR'], 41 CONFIG_FILENAME) 42 CONFIG_FILEPATH = os.path.join(HERE_DIR, CONFIG_FILENAME) 42 43 43 44 def __init__(self, *arg, **kw):
Note: See TracChangeset
for help on using the changeset viewer.