def test_04_MissingSigningPolicy(self): now = time.time() start = now - 86400 end = now + 86400 passphrase = "abcd" caCert = CreateCA(start, end, self.caName) userCert = CreateUser(start, end, caCert, self.userCertName) caCert.WriteTrustedCert(self.certDir) certPath, keyPath = userCert.Write(self.userDir, "usercert", passphrase) print "certPath: ", certPath print "keyPath: ", keyPath print "caDir: ", self.certDir outFile = os.path.join(self.userDir, "proxy.pem") try: ProxyGen.CreateGlobusProxy(passphrase, certPath, keyPath, self.certDir, outFile, 512, 12) self.fail("Should have raised GridProxyInitError exception") except ProxyGen.GridProxyInitError, e: assert str(e) == "Missing signing policy"
def test_06_ExpiredUser(self): now = time.time() user_start = now - 2 * 86400 user_end = now - 86400 ca_start = now - 86400 ca_end = now + 86400 passphrase = "abcd" caCert = CreateCA(ca_start, ca_end, self.caName) userCert = CreateUser(user_start, user_end, caCert, self.userCertName) userName = str(userCert.cert.get_subject()) caCert.WriteTrustedCert(self.certDir) caCert.WriteSigningPolicy(self.certDir) certPath, keyPath = userCert.Write(self.userDir, "usercert", passphrase) outFile = os.path.join(self.userDir, "proxy.pem") try: ProxyGen.CreateGlobusProxy(passphrase, certPath, keyPath, self.certDir, outFile, 512, 12) self.fail("Should have raised GridProxyInitError exception") except ProxyGen.GridProxyInitError, e: assert str(e) == "Expired certificate for " + userName
def test_01_ValidUser(self): now = time.time() start = now - 86400 end = now + 86400 passphrase = "abcd" caCert = CreateCA(start, end, self.caName) userCert = CreateUser(start, end, caCert, self.userCertName) caCert.WriteTrustedCert(self.certDir) caCert.WriteSigningPolicy(self.certDir) certPath, keyPath = userCert.Write(self.userDir, "usercert", passphrase) print "certPath: ", certPath print "keyPath: ", keyPath print "caDir: ", self.certDir outFile = os.path.join(self.userDir, "proxy.pem") ProxyGen.CreateGlobusProxy(passphrase, certPath, keyPath, self.certDir, outFile, 512, 12)
def CreateProxyCertificate(self, passphrase, bits=1024, hours=12): """ Create a proxy. """ # Create the proxy cert with a start validity of now-1hour, # and extend the requested validity duration by an hour so # the user still gets what he expects hoursExtended = hours+1 start = time.time()-3600 passphrasecb = lambda v,p1='',p2='': passphrase ident = self.GetDefaultIdentity() ProxyGen.CreateProxy(passphrasecb, ident.GetPath(), ident.GetKeyPath(), self.caDir, self.proxyPath, bits, hoursExtended, start)
def HaveValidProxy(self): return ProxyGen.IsValidProxy(self.proxyPath)