Ignore:
Timestamp:
08/01/07 16:45:40 (13 years ago)
Author:
pjkersha
Message:

All tests working.

python/ndg.security.test/ndg/security/test/AttCert/AttCertTest.py: added new tests test6aDictSet and
test6aDictGet to test setitem and getitem dictionary methods.

python/ndg.security.common/ndg/security/common/AttCert.py:

items are read-only. This is applied to idct type items returned from AttCert?.setitem

  • fixes to setitem to ensure exceptions are raised if an attempt is made to validity time or role

names via the 'validity' or 'attributes' keywords.

  • fix to parse so that it is possible to parse a cert. where the not before and not after times are set to

. In this case the corresponding to datetimes will be reset to None also.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttCert/AttCertTest.py

    r1967 r1970  
    7878        print "test6AddRoles: " + ', '.join(self.attCert.getRoles()) 
    7979 
     80  
     81    def test6aDictSet(self): 
     82        'test6aDictSet: test __setitem__' 
     83        self.attCert['issuer'] = '/O=NDG/OU=BADC/CN=Attribute Authority' 
     84        self.attCert['issuerName'] = 'BADC' 
     85        self.attCert['holder'] = '/O=NDG/OU=BADC/CN=pjkershaw' 
     86         
     87        try: 
     88            self.attCert['validity'] = 'invalid' 
     89        except KeyError, e: 
     90            print "test6aDictSet: PASSED - %s" % e 
     91             
     92        try: 
     93            self.attCert['attributes'] = 'roleSet' 
     94        except KeyError, e: 
     95            print "test6aDictSet: PASSED - %s" % e 
     96             
     97        try: 
     98            self.attCert['attributes']['roleSet'] = ['role1', 'role2'] 
     99        except KeyError, e: 
     100            print "test6aDictSet: PASSED - %s" % e 
     101 
     102    def test6bDictGet(self): 
     103        'test6bDictGet: test __getitem__' 
     104        print "test6bDictGet ..." 
     105        print self.test2SetProvenance() 
     106        print self.test4SetValidityTime() 
     107        print self.test6AddRoles() 
     108        print self.test6aDictSet() 
     109        print self.attCert['issuer'] 
     110        print self.attCert['holder'] 
     111        print self.attCert['validity'] 
     112        print self.attCert['attributes'] 
     113        print self.attCert['attributes']['roleSet']  
     114 
    80115    def test7CreateXML(self): 
    81116        'test7CreateXML: check for correct formatted string' 
     
    87122     
    88123    def test8Parse(self): 
    89         '''test8Parse: parse an XML document'''             
     124        '''test8Parse: parse an XML document'''   
    90125        self.attCert.parse(self.attCert.createXML()) 
    91  
     126        print 'test8Parse:\n\n' + repr(self.attCert) 
    92127 
    93128    def test9Sign(self):  
     
    96131        self.test5SetDefaultValidityTime() 
    97132        self.test6AddRoles() 
    98              
     133        self.test6aDictSet()     
     134         
    99135        self.attCert.filePath = self.cfg['test9Sign']['filepath'] 
    100136        self.attCert.certFilePathList=self.cfg['test9Sign']['certfile'] 
    101137        self.attCert.signingKeyFilePath=self.cfg['test9Sign']['keyfile'] 
    102138         
    103         self.attCert.signingKeyPwd = self.cfg['test9Sign'].get('keypwd') or\ 
     139        try: 
     140            self.attCert.signingKeyPwd=self.cfg['test9Sign'].get('keypwd') or\ 
    104141            getpass.getpass(prompt="\ntest9Sign private key password: ") 
     142        except KeyboardInterrupt: 
     143            self.fail("test9Sign: Aborting test") 
     144            return 
    105145         
    106146        self.attCert.applyEnvelopedSignature() 
Note: See TracChangeset for help on using the changeset viewer.