diff --git a/letsencrypt-auto-source/tests/auto_test.py b/letsencrypt-auto-source/tests/auto_test.py
index 6f21c28d5..0661ff57d 100644
--- a/letsencrypt-auto-source/tests/auto_test.py
+++ b/letsencrypt-auto-source/tests/auto_test.py
@@ -160,21 +160,20 @@ def signed(content, private_key_name='signing.key'):
return out
-def install_le_auto(contents, venv_dir):
+def install_le_auto(contents, install_path):
"""Install some given source code as the letsencrypt-auto script at the
root level of a virtualenv.
:arg contents: The contents of the built letsencrypt-auto script
- :arg venv_dir: The path under which to install the script
+ :arg install_path: path where to install the script
"""
- venv_le_auto_path = join(venv_dir, 'letsencrypt-auto')
- with open(venv_le_auto_path, 'w') as le_auto:
+ with open(install_path, 'w') as le_auto:
le_auto.write(contents)
- chmod(venv_le_auto_path, S_IRUSR | S_IXUSR)
+ chmod(install_path, S_IRUSR | S_IXUSR)
-def run_le_auto(venv_dir, base_url, **kwargs):
+def run_le_auto(le_auto_path, venv_dir, base_url, **kwargs):
"""Run the prebuilt version of letsencrypt-auto, returning stdout and
stderr strings.
@@ -182,7 +181,7 @@ def run_le_auto(venv_dir, base_url, **kwargs):
"""
env = environ.copy()
- d = dict(XDG_DATA_HOME=venv_dir,
+ d = dict(VENV_PATH=venv_dir,
# URL to PyPI-style JSON that tell us the latest released version
# of LE:
LE_AUTO_JSON_URL=base_url + 'certbot/json',
@@ -201,7 +200,7 @@ iQIDAQAB
**kwargs)
env.update(d)
return out_and_err(
- join(venv_dir, 'letsencrypt-auto') + ' --version',
+ le_auto_path + ' --version',
shell=True,
env=env)
@@ -213,7 +212,7 @@ def set_le_script_version(venv_dir, version):
print its version.
"""
- with open(join(venv_dir, 'letsencrypt', 'bin', 'letsencrypt'), 'w') as script:
+ with open(join(venv_dir, 'bin', 'letsencrypt'), 'w') as script:
script.write("#!/usr/bin/env python\n"
"from sys import stderr\n"
"stderr.write('letsencrypt %s\\n')" % version)
@@ -257,7 +256,9 @@ class AutoTests(TestCase):
requirements='letsencrypt==99.9.9 --hash=sha256:1cc14d61ab424cdee446f51e50f1123f8482ec740587fe78626c933bba2873a0')
NEW_LE_AUTO_SIG = signed(NEW_LE_AUTO)
- with ephemeral_dir() as venv_dir:
+ with ephemeral_dir() as temp_dir:
+ le_auto_path = join(temp_dir, 'letsencrypt-auto')
+ venv_dir = join(temp_dir, 'venv')
# This serves a PyPI page with a higher version, a GitHub-alike
# with a corresponding le-auto script, and a matching signature.
resources = {'certbot/json': dumps({'releases': {'99.9.9': None}}),
@@ -266,6 +267,7 @@ class AutoTests(TestCase):
with serving(resources) as base_url:
run_letsencrypt_auto = partial(
run_le_auto,
+ le_auto_path,
venv_dir,
base_url,
PIP_FIND_LINKS=join(tests_dir(),
@@ -274,7 +276,7 @@ class AutoTests(TestCase):
# Test when a phase-1 upgrade is needed, there's no LE binary
# installed, and pip hashes verify:
- install_le_auto(build_le_auto(version='50.0.0'), venv_dir)
+ install_le_auto(build_le_auto(version='50.0.0'), le_auto_path)
out, err = run_letsencrypt_auto()
ok_(re.match(r'letsencrypt \d+\.\d+\.\d+',
err.strip().splitlines()[-1]))
@@ -300,7 +302,9 @@ class AutoTests(TestCase):
def test_openssl_failure(self):
"""Make sure we stop if the openssl signature check fails."""
- with ephemeral_dir() as venv_dir:
+ with ephemeral_dir() as temp_dir:
+ le_auto_path = join(temp_dir, 'letsencrypt-auto')
+ venv_dir = join(temp_dir, 'venv')
# Serve an unrelated hash signed with the good key (easier than
# making a bad key, and a mismatch is a mismatch):
resources = {'': 'certbot/',
@@ -308,9 +312,9 @@ class AutoTests(TestCase):
'v99.9.9/letsencrypt-auto': build_le_auto(version='99.9.9'),
'v99.9.9/letsencrypt-auto.sig': signed('something else')}
with serving(resources) as base_url:
- copy(LE_AUTO_PATH, venv_dir)
+ copy(LE_AUTO_PATH, le_auto_path)
try:
- out, err = run_le_auto(venv_dir, base_url)
+ out, err = run_le_auto(le_auto_path, venv_dir, base_url)
except CalledProcessError as exc:
eq_(exc.returncode, 1)
self.assertTrue("Couldn't verify signature of downloaded "
@@ -320,7 +324,9 @@ class AutoTests(TestCase):
def test_pip_failure(self):
"""Make sure pip stops us if there is a hash mismatch."""
- with ephemeral_dir() as venv_dir:
+ with ephemeral_dir() as temp_dir:
+ le_auto_path = join(temp_dir, 'letsencrypt-auto')
+ venv_dir = join(temp_dir, 'venv')
resources = {'': 'certbot/',
'certbot/json': dumps({'releases': {'99.9.9': None}})}
with serving(resources) as base_url:
@@ -329,14 +335,14 @@ class AutoTests(TestCase):
build_le_auto(
version='99.9.9',
requirements='configobj==5.0.6 --hash=sha256:badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb'),
- venv_dir)
+ le_auto_path)
try:
- out, err = run_le_auto(venv_dir, base_url)
+ out, err = run_le_auto(le_auto_path, venv_dir, base_url)
except CalledProcessError as exc:
eq_(exc.returncode, 1)
self.assertTrue("THESE PACKAGES DO NOT MATCH THE HASHES "
"FROM THE REQUIREMENTS FILE" in exc.output)
- ok_(not exists(join(venv_dir, 'letsencrypt')),
+ ok_(not exists(venv_dir),
msg="The virtualenv was left around, even though "
"installation didn't succeed. We shouldn't do "
"this, as it foils our detection of whether we "