Fix node-daemon-setup test with older pyOpenSSL
authorMichael Hanselmann <hansmi@google.com>
Thu, 6 Dec 2012 15:43:53 +0000 (16:43 +0100)
committerGuido Trotter <ultrotter@google.com>
Thu, 6 Dec 2012 16:19:52 +0000 (17:19 +0100)
Older versions use “-----BEGIN RSA PRIVATE KEY-----” instead of
“-----BEGIN PRIVATE KEY-----”.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

test/ganeti.tools.node_daemon_setup_unittest.py

index dc05fe0..da06d7e 100755 (executable)
@@ -101,8 +101,12 @@ class TestVerifyCertificate(testutils.GanetiTestCase):
     cert_pem = utils.ReadFile(cert_filename)
     result = \
       node_daemon_setup._VerifyCertificate(cert_pem, _check_fn=self._Check)
-    self.assertTrue("-----BEGIN PRIVATE KEY-----" in result)
-    self.assertTrue("-----BEGIN CERTIFICATE-----" in result)
+
+    cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, result)
+    self.assertTrue(cert)
+
+    key = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, result)
+    self.assertTrue(key)
 
   def testMismatchingKey(self):
     cert1_path = self._TestDataFilename("cert1.pem")