Ejemplo n.º 1
0
    def test_generate_certificate_uses_tmpdir(self):
        subp_directory = {}

        def capture_directory(*args, **kwargs):
            subp_directory['path'] = os.getcwd()

        self.subp.side_effect = capture_directory
        manager = azure_helper.OpenSSLManager()
        self.assertEqual(manager.tmpdir, subp_directory['path'])
Ejemplo n.º 2
0
    def test_pubkey_extract(self):
        cert = load_file(self._data_file('pubkey_extract_cert'))
        good_key = load_file(self._data_file('pubkey_extract_ssh_key'))
        sslmgr = azure_helper.OpenSSLManager()
        key = sslmgr._get_ssh_key_from_cert(cert)
        self.assertEqual(good_key, key)

        good_fingerprint = '073E19D14D1C799224C6A0FD8DDAB6A8BF27D473'
        fingerprint = sslmgr._get_fingerprint_from_cert(cert)
        self.assertEqual(good_fingerprint, fingerprint)
Ejemplo n.º 3
0
 def test_parse_certificates(self, mock_decrypt_certs):
     """Azure control plane puts private keys as well as certificates
        into the Certificates XML object. Make sure only the public keys
        from certs are extracted and that fingerprints are converted to
        the form specified in the ovf-env.xml file.
     """
     cert_contents = load_file(self._data_file('parse_certificates_pem'))
     fingerprints = load_file(
         self._data_file('parse_certificates_fingerprints')).splitlines()
     mock_decrypt_certs.return_value = cert_contents
     sslmgr = azure_helper.OpenSSLManager()
     keys_by_fp = sslmgr.parse_certificates('')
     for fp in keys_by_fp.keys():
         self.assertIn(fp, fingerprints)
     for fp in fingerprints:
         self.assertIn(fp, keys_by_fp)
 def test_clean_up(self, del_dir):
     manager = azure_helper.OpenSSLManager()
     manager.clean_up()
     self.assertEqual([mock.call(manager.tmpdir)], del_dir.call_args_list)
 def test_openssl_manager_creates_a_tmpdir(self, mkdtemp):
     manager = azure_helper.OpenSSLManager()
     self.assertEqual(mkdtemp.return_value, manager.tmpdir)