source: TI12-security/trunk/python/Tests/attCertTest.py @ 751

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/attCertTest.py@1257
Revision 751, 2.1 KB checked in by pjkersha, 14 years ago (diff)

Tests/init.py: enables test files to be loaded as part of a package

Tests/SessionMgrIOtest.py: converted into format for pyunit

Tests/attCertTest.py: added test for signing

www/cgi-bin/security.py: added pub/pri key args for encryption.

bin/ndgSessionClient.py: update to help text for --req-role option.

NDG/AttAuthority.py: fixed bug in valid ext AttCert? check except block.

NDG/AttCert.py: modified isValidTime() to allow exception to be raised in order to give info
about why the cert time is not valid.

NDG/XMLMsg.py: updateXML() - leave tags set to None.

NDG/XMLSecDoc.py: fixed bug in asString() - make sure a filePath has been set if libxml2Doc
is not initialised.

NDG/SessionMgrIO.py:

regular expressions to parse AttCerts?. The default using ElementTree adds in unwanted 'ns0'
namespaces to the digital signature elements. Also fixes to updateXML methods.

NDG/SessionClient.py:

  • default mapFromTrustedHosts to None for reqAuthorisation() method. This tells wallet at

SessionMgr? to leave this flag setting as it is without modifying it.

NDG/CredWallet.py:

  • reqAuthorisation() - check "if not mapFromTrustedHosts and not rtnExtAttCertList" was in

the wrong place. Moved it to BEFORE call to getAATrustedHostInfo().

  • Property svn:executable set to *
Line 
1#!/bin/env python
2
3import unittest
4from NDG.AttCert import *
5
6
7class attCertTestCase(unittest.TestCase):
8   
9    def setUp(self):
10        self.attCert = AttCert()
11        self.attCert['provenance'] = 'original'
12        self.attCert.setValidityTime(lifeTime=60*60*8.)
13        self.attCert.addRoles(['government', 'acsoe', 'atsr'])
14       
15    def tearDown(self):
16        pass
17
18
19           
20    def testAttCert2Sign(self):
21       
22        try:
23            certFilePathList = [ "./Junk-cert.pem",
24                                 "/usr/local/NDG/conf/certs/cacert.pem"]
25                                 
26            signingPriKeyFilePath = "./Junk-key.pem"
27            priKeyPwd = open("./tmp2").read().strip()
28           
29            import pdb
30            pdb.set_trace()
31                       
32            # Digitally sign certificate using Attribute Authority's
33            # certificate and private key
34            self.attCert.sign(certFilePathList=certFilePathList,
35                              signingKeyFilePath=signingPriKeyFilePath,
36                              signingKeyPwd=priKeyPwd)
37           
38            # Check the certificate is valid
39            self.attCert.isValid(raiseExcep=True)
40            print "Signature is valid\n"
41           
42            print "AttCert.asString()...\n"
43            print self.attCert.asString()
44       
45        except Exception, e:
46            raise self.fail(str(e))
47           
48           
49    def testAttCert4NonZero(self):
50       
51        try:
52            if not self.attCert:
53                self.fail("AttCert instance yields 0")
54           
55        except Exception, e:
56            self.fail(str(e))
57       
58
59class attCertTestSuite(unittest.TestSuite):
60    def __init__(self):
61        map = map(attCertTestCase,
62                  (
63                    "test1AttCertAddRoles",
64                    "test2AttCertSign",
65                    "test3AttCertAsString",
66                    "test4AttCertNonZero",
67                  ))
68        unittest.TestSuite.__init__(self, map)
69 
70                                       
71if __name__ == "__main__":
72    unittest.main()
Note: See TracBrowser for help on using the repository browser.