def test_CA(self): tmp_dir = tempfile.mkdtemp(dir=data_dir.get_tmp_dir()) cakey_path = '%s/tcakey.pem' % tmp_dir cainfo_path = '%s/ca.info' % tmp_dir cacert_path = '%s/cacert.pem' % tmp_dir utils_conn.build_CA(tmp_dir) self.assertTrue(os.path.exists(cakey_path)) self.assertTrue(os.path.exists(cainfo_path)) self.assertTrue(os.path.exists(cacert_path)) expect_info = ["cn = AUTOTEST.VIRT\n", "ca\n", "cert_signing_key\n"] info_file = open(cainfo_path) lines = info_file.readlines() self.assertEqual(expect_info, lines) shutil.rmtree(tmp_dir)
def test_server_key(self): tmp_dir = tempfile.mkdtemp(dir=data_dir.get_tmp_dir()) utils_conn.build_CA(tmp_dir) serverkey_path = '%s/serverkey.pem' % tmp_dir servercert_path = '%s/servercert.pem' % tmp_dir serverinfo_path = '%s/server.info' % tmp_dir utils_conn.build_server_key(tmp_dir) self.assertTrue(os.path.exists(serverkey_path)) self.assertTrue(os.path.exists(servercert_path)) self.assertTrue(os.path.exists(serverinfo_path)) expect_info = ["organization = AUTOTEST.VIRT\n", "cn = TLSServer\n", "tls_www_server\n", "encryption_key\n", "signing_key\n"] info_file = open(serverinfo_path) lines = info_file.readlines() self.assertEqual(expect_info, lines) shutil.rmtree(tmp_dir)