From ea45fc6504af1c25e3faeab72f457839da51a5ea Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Sun, 4 Oct 2015 18:32:49 +0000 Subject: [PATCH] TestSimpleServer: don't rely on symlinks --- acme/acme/standalone_test.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/acme/acme/standalone_test.py b/acme/acme/standalone_test.py index 9ff99f5ff..a6f7502b6 100644 --- a/acme/acme/standalone_test.py +++ b/acme/acme/standalone_test.py @@ -1,6 +1,8 @@ """Tests for acme.standalone.""" import os +import shutil import threading +import tempfile import time import unittest @@ -115,21 +117,28 @@ class ACMESimpleHTTPTLSServerTestEndToEnd(unittest.TestCase): class TestSimpleServer(unittest.TestCase): """Tests for acme.standalone.simple_server.""" - TEST_CWD = os.path.join(os.path.dirname(__file__), '..', 'examples', 'standalone') - def setUp(self): + # mirror ../examples/standalone + self.test_cwd = tempfile.mkdtemp() + localhost_dir = os.path.join(self.test_cwd, 'localhost') + os.makedirs(localhost_dir) + shutil.copy(test_util.vector_path('cert.pem'), localhost_dir) + shutil.copy(test_util.vector_path('rsa512_key.pem'), + os.path.join(localhost_dir, 'key.pem')) + from acme.standalone import simple_server self.thread = threading.Thread(target=simple_server, kwargs={ 'cli_args': ('xxx', '--port', '1234'), 'forever': False, }) self.old_cwd = os.getcwd() - os.chdir(self.TEST_CWD) + os.chdir(self.test_cwd) self.thread.start() def tearDown(self): os.chdir(self.old_cwd) self.thread.join() + shutil.rmtree(self.test_cwd) def test_it(self): max_attempts = 5