Changeset 3029
- Timestamp:
- 21/11/07 13:53:45 (13 years ago)
- Location:
- TI12-security/trunk/python/ndg.security.test/ndg/security/test/X509
- Files:
-
- 1 added
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.test/ndg/security/test/X509/X509Test.py
r2953 r3029 32 32 for section in configParser.sections(): 33 33 self.cfg[section] = dict(configParser.items(section)) 34 34 35 35 36 … … 37 38 'test1X509CertRead: read in a cert from file' 38 39 print self.test1X509CertRead.__doc__ 39 self. X509Cert=X509CertRead(self.cfg['test1X509CertRead']['certfile'])40 assert(self. X509Cert)40 self.x509Cert=X509CertRead(self.cfg['test1X509CertRead']['certfile']) 41 assert(self.x509Cert) 41 42 42 43 def test2X509CertAsPEM(self): … … 44 45 self.test1X509CertRead() 45 46 print self.test2X509CertAsPEM.__doc__ 46 self.pemString = self. X509Cert.asPEM()47 self.pemString = self.x509Cert.asPEM() 47 48 print self.pemString 48 49 … … 59 60 self.test1X509CertRead() 60 61 print self.test4GetDN.__doc__ 61 self.dn = self. X509Cert.dn62 self.dn = self.x509Cert.dn 62 63 print self.dn 63 64 … … 81 82 assert(not(self.dn != self.dn)) 82 83 84 def test7x509Stack(self): 85 '''test7x509Stack: test X509Stack functionality''' 86 print self.test7x509Stack.__doc__ 87 self.test1X509CertRead() 88 stack = X509Stack() 89 assert(len(stack)==0) 90 assert(stack.push(self.x509Cert)) 91 assert(len(stack)==1) 92 print "stack[0] = %s" % stack[0] 93 for i in stack: 94 print "stack iterator i = %s" % i 95 print "stack.pop() = %s" % stack.pop() 96 assert(len(stack)==0) 97 98 def test8x509StackVerifyCertChain(self): 99 '''test8x509StackVerifyCertChain: testVerifyCertChain method''' 100 print self.test8x509StackVerifyCertChain.__doc__ 101 self.test1X509CertRead() 102 proxyCert=X509CertRead(\ 103 self.cfg['test8x509StackVerifyCertChain']['proxycertfile']) 104 105 stack1 = X509Stack() 106 stack1.push(self.x509Cert) 83 107 108 caCert=X509CertRead(\ 109 self.cfg['test8x509StackVerifyCertChain']['cacertfile']) 110 caStack = X509Stack() 111 caStack.push(caCert) 112 113 print "Verification of external cert with external CA stack..." 114 stack1.verifyCertChain(x509Cert2Verify=proxyCert, 115 caX509Stack=caStack) 116 117 print "Verification of stack content using CA stack..." 118 stack1.push(proxyCert) 119 stack1.verifyCertChain(caX509Stack=caStack) 120 121 print "Verification of stack alone..." 122 stack1.push(caCert) 123 stack1.verifyCertChain() 124 125 print "Reject self-signed cert. ..." 126 stack2 = X509Stack() 127 try: 128 stack2.verifyCertChain() 129 raise Exception, "Empty stack error expected" 130 except X509StackError: 131 pass 132 133 stack2.push(caCert) 134 try: 135 stack2.verifyCertChain() 136 raise Exception, "Reject of self-signed cert. expected" 137 except SelfSignedCert: 138 pass 139 140 print "Accept self-signed cert. ..." 141 stack2.verifyCertChain(rejectSelfSignedCert=False) 142 143 assert(stack2.pop()) 144 print "Test no cert. issuer found ..." 145 stack2.push(proxyCert) 146 try: 147 stack2.verifyCertChain() 148 raise Exception, "No cert. issuer error expected" 149 except CertIssuerNotFound: 150 pass 151 152 print "Test no cert. issuer found again with incomplete chain ..." 153 stack2.push(self.x509Cert) 154 try: 155 stack2.verifyCertChain() 156 raise Exception, "No cert. issuer error expected" 157 except CertIssuerNotFound: 158 pass 159 160 84 161 class X509TestSuite(unittest.TestSuite): 85 162 def __init__(self): … … 91 168 "test4GetDN", 92 169 "test5DN", 93 "test6DNCmp" 170 "test6DNCmp", 171 "test7x509Stack", 172 "test8x509StackVerifyCertChain" 94 173 )) 95 174 unittest.TestSuite.__init__(self, map) -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/X509/x509Test.cfg
r2952 r3029 10 10 11 11 [test1X509CertRead] 12 #certfile: cert.pem 13 certfile: proxy-cert.pem 12 certfile: user-cert.pem 14 13 14 [test8x509StackVerifyCertChain] 15 certfile: user-cert.pem 16 proxycertfile: proxy-cert.pem 17 cacertfile: cacert.pem 18
Note: See TracChangeset
for help on using the changeset viewer.