Ignore:
Timestamp:
10/10/08 10:24:21 (12 years ago)
Author:
pjkersha
Message:

Major surgery on ConfigFileParsers? to enable support for nesting of component sections e.g.

[mySection]
sessionManager.credentialWallet.caCertFilePathList=ca/ndg-test-ca.crt

... yields a properties dictionary with:
mySection?sessionManager?credentialWallet?caCertFilePathList?='ca/ndg-test-ca.crt'

XML properties parsing is untested - will add warning for now but may deprecate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/configfileparsers/test_configfileparsers.py

    r4318 r4319  
    6868                       sections=('test2INIPropertyFile',), 
    6969                       prefix='attributeAuthority') 
    70         print "prop ..." 
    71         print prop['test2INIPropertyFile'] 
    72         print prop['test2INIPropertyFile']['attributeAuthority']['name'] 
    73         print prop['test2INIPropertyFile']['attributeAuthority']['useSSL'] 
    74         print prop['test2INIPropertyFile']['attributeAuthority']['attCertLifetime'] 
    75         assert(isinstance(prop['test2INIPropertyFile']['attributeAuthority']['attCertLifetime'], int)) 
    76         assert(isinstance(prop['test2INIPropertyFile']['attributeAuthority']['useSSL'], bool)) 
     70        print "properties ..." 
     71        print prop 
     72        print "prop['test2INIPropertyFile']['attributeAuthority']['name']=%s"%\ 
     73            prop['test2INIPropertyFile']['attributeAuthority']['name'] 
     74             
     75        print("prop['test2INIPropertyFile']['attributeAuthority']['useSSL']" 
     76              "=%s" % prop['test2INIPropertyFile']['attributeAuthority'] 
     77              ['useSSL']) 
     78        print("prop['test2INIPropertyFile']['attributeAuthority']" 
     79              "['attCertLifetime']=%s" % prop['test2INIPropertyFile'] 
     80              ['attributeAuthority']['attCertLifetime']) 
     81         
     82        assert(isinstance(prop['test2INIPropertyFile']['attributeAuthority'] 
     83                          ['attCertLifetime'], float)) 
     84         
     85        assert(isinstance(prop['test2INIPropertyFile']['attributeAuthority'] 
     86                          ['useSSL'], bool)) 
    7787             
    7888    def test3ReadAndValidateProperties(self): 
     
    8696            'sslCACertFilePathList': [], 
    8797            'credentialWallet': { 
     98                'attributeAuthorityURI': 'A DEFAULT VALUE', 
    8899                'caCertFilePathList': [], 
    89100                'mapFromTrustedHosts': False, 
     
    95106                               sections=('test3ReadAndValidateProperties',), 
    96107                               prefix='sessionManager') 
     108        print "properties ..." 
     109        print prop 
     110        assert(prop.keys()==['test3ReadAndValidateProperties']) 
     111         
     112        assert(prop['test3ReadAndValidateProperties']['sessionManager'] 
     113               ['sslCertFile']) 
     114        assert('credentialWallet' in prop['test3ReadAndValidateProperties'] 
     115               ['sessionManager']) 
     116         
     117        # attributeAuthorityURI is not present in the config so it should be  
     118        # set to its default value 
     119        assert(prop['test3ReadAndValidateProperties']['sessionManager'] 
     120            ['credentialWallet']['attributeAuthorityURI']=='A DEFAULT VALUE') 
    97121         
    98122if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.