Changeset 6720


Ignore:
Timestamp:
11/03/10 11:30:36 (10 years ago)
Author:
pjkersha
Message:
  • Attribute Authority unit tests now pass with refactored Attribute Authority which has NDG Attribute Certificate and role mapping code removed.
  • Now refactoring client unit tests.
  • Removed NDG Attribute Certificate and XMLSec unit tests - no longer needed.
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  
    123123        '__propFileSection', 
    124124        '__propPrefix', 
     125        '__attributeInterface', 
    125126        '__attributeInterfaceCfg' 
    126127    ) 
     
    140141         
    141142        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     
    143176    def _getAssertionLifetime(self): 
    144177        return self.__assertionLifetime 
    145  
    146     def _getAttributeInterface(self): 
    147         return self.__attributeInterface 
    148178 
    149179    def _setAssertionLifetime(self, value): 
     
    156186            raise TypeError('Expecting float, int, long or string type for ' 
    157187                            '"assertionLifetime"; got %r' % type(value)) 
     188 
     189    def _getAttributeInterface(self): 
     190        return self.__attributeInterface 
    158191 
    159192    def _setAttributeInterface(self, value): 
  • TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/site-a.ini

    r6686 r6720  
    4848 
    4949# 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 
     50attributeAuthority.assertionLifetime: 28800  
    6051 
    6152attributeAuthority.dnSeparator:/ 
     
    8071saml.soapbinding.queryInterfaceKeyName = %(attributeQueryInterfaceEnvironKeyName)s 
    8172 
     73# Clock skew for SAML Attribute Queries - allow clockSkew number of seconds 
     74# tolerance for query issueInstant parameter. Set here to 3 minutes 
     75saml.soapbinding.clockSkewTolerance: 180.0 
    8276 
    8377# Logging configuration 
  • TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthority/test_attributeauthority.py

    r6719 r6720  
    2323from datetime import datetime 
    2424from os import path 
     25import pickle 
    2526 
    2627from ndg.security.test.unit import BaseTestCase 
     
    4647    PROPERTIES_FILEPATH = path.join(THIS_DIR, PROPERTIES_FILENAME) 
    4748    ISSUER_NAME = '/O=My Organisation/OU=Centre/CN=Attribute Authority' 
    48      
     49    ASSERTION_LIFETIME = "86400" 
     50 
    4951    def test01ParsePropertiesFile(self): 
    5052        cls = AttributeAuthorityTestCase 
     
    5456        self.assert_(aa.issuerName == cls.ISSUER_NAME) 
    5557         
    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         
    6165        attributeInterfaceClassName = ('ndg.security.server.attributeauthority.' 
    6266                                       'AttributeInterface') 
    6367         
    64         aa = AttributeAuthority.fromProperties(issuerName=issuerName, 
    65                     assertionLifetime=assertionLifetime, 
     68        aa = AttributeAuthority.fromProperties(issuerName=cls.ISSUER_NAME, 
     69                    assertionLifetime=cls.ASSERTION_LIFETIME, 
    6670                    attributeInterface_className=attributeInterfaceClassName) 
    6771         
     72        return aa 
     73             
     74    def test02FromProperties(self): 
     75         
     76        cls = AttributeAuthorityTestCase 
     77        aa = self._createAttributeAuthorityHelper() 
     78         
    6879        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) 
    7184        self.assert_(isinstance(aa.attributeInterface, AttributeInterface)) 
    7285 
    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         
    7498class SQLAlchemyAttributeInterfaceTestCase(BaseTestCase): 
    7599    THIS_DIR = THIS_DIR 
  • TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.py

    r6615 r6720  
    2020from ndg.saml.common.xml import SAMLConstants 
    2121from ndg.saml.xml.etree import AttributeQueryElementTree, ResponseElementTree 
    22 from ndg.saml.saml2.core import (Subject, Issuer, Attribute, NameID, AttributeQuery, 
    23                              StatusCode, XSStringAttributeValue, ) 
     22from ndg.saml.saml2.core import (Subject, Issuer, Attribute, NameID,  
     23                                 AttributeQuery, StatusCode,  
     24                                 XSStringAttributeValue) 
    2425 
    2526from ndg.security.common.saml_utils.binding.soap import SOAPBinding 
     
    3738                                        AttributeAuthorityClientBaseTestCase): 
    3839    """NDG Attribute Authority SAML SOAP Binding client unit tests""" 
     40    HERE_DIR = os.path.dirname(__file__) 
    3941    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) 
    4243     
    4344    def __init__(self, *arg, **kw): 
Note: See TracChangeset for help on using the changeset viewer.