Revision 00ef625c test/py/ganeti.utils.x509_unittest.py
b/test/py/ganeti.utils.x509_unittest.py | ||
---|---|---|
82 | 82 |
|
83 | 83 |
def _LoadCert(self, name): |
84 | 84 |
return OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, |
85 |
self._ReadTestData(name))
|
|
85 |
testutils.ReadTestData(name))
|
|
86 | 86 |
|
87 | 87 |
def test(self): |
88 | 88 |
validity = utils.GetX509CertValidity(self._LoadCert("cert1.pem")) |
... | ... | |
157 | 157 |
shutil.rmtree(self.tmpdir) |
158 | 158 |
|
159 | 159 |
def testVerifyCertificate(self): |
160 |
cert_pem = utils.ReadFile(self._TestDataFilename("cert1.pem"))
|
|
160 |
cert_pem = testutils.ReadTestData("cert1.pem")
|
|
161 | 161 |
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, |
162 | 162 |
cert_pem) |
163 | 163 |
|
... | ... | |
297 | 297 |
shutil.rmtree(self.tmpdir) |
298 | 298 |
|
299 | 299 |
def testMismatchingKey(self): |
300 |
other_cert = self._TestDataFilename("cert1.pem")
|
|
301 |
node_cert = self._TestDataFilename("cert2.pem")
|
|
300 |
other_cert = testutils.TestDataFilename("cert1.pem")
|
|
301 |
node_cert = testutils.TestDataFilename("cert2.pem")
|
|
302 | 302 |
|
303 | 303 |
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, |
304 | 304 |
utils.ReadFile(other_cert)) |
... | ... | |
312 | 312 |
self.fail("Exception was not raised") |
313 | 313 |
|
314 | 314 |
def testMatchingKey(self): |
315 |
cert_filename = self._TestDataFilename("cert2.pem")
|
|
315 |
cert_filename = testutils.TestDataFilename("cert2.pem")
|
|
316 | 316 |
|
317 | 317 |
# Extract certificate |
318 | 318 |
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, |
... | ... | |
323 | 323 |
utils.CheckNodeCertificate(cert, _noded_cert_file=cert_filename) |
324 | 324 |
|
325 | 325 |
def testMissingFile(self): |
326 |
cert_path = self._TestDataFilename("cert1.pem")
|
|
326 |
cert_path = testutils.TestDataFilename("cert1.pem")
|
|
327 | 327 |
nodecert = utils.PathJoin(self.tmpdir, "does-not-exist") |
328 | 328 |
|
329 | 329 |
utils.CheckNodeCertificate(NotImplemented, _noded_cert_file=nodecert) |
... | ... | |
338 | 338 |
NotImplemented, _noded_cert_file=tmpfile) |
339 | 339 |
|
340 | 340 |
def testNoPrivateKey(self): |
341 |
cert = self._TestDataFilename("cert1.pem")
|
|
341 |
cert = testutils.TestDataFilename("cert1.pem")
|
|
342 | 342 |
self.assertRaises(errors.X509CertError, utils.CheckNodeCertificate, |
343 | 343 |
NotImplemented, _noded_cert_file=cert) |
344 | 344 |
|
345 | 345 |
def testMismatchInNodeCert(self): |
346 |
cert1_path = self._TestDataFilename("cert1.pem")
|
|
347 |
cert2_path = self._TestDataFilename("cert2.pem")
|
|
346 |
cert1_path = testutils.TestDataFilename("cert1.pem")
|
|
347 |
cert2_path = testutils.TestDataFilename("cert2.pem")
|
|
348 | 348 |
tmpfile = utils.PathJoin(self.tmpdir, "cert") |
349 | 349 |
|
350 | 350 |
# Extract certificate |
Also available in: Unified diff