Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2017-03-16 12:52:58 +0300
committerYen Chi Hsuan <yan12125@gmail.com>2017-04-14 21:32:18 +0300
commit29d25f0915dad93cd7f49eba89557a88c730eb23 (patch)
treee832de36d3ac41788fae409ba5c0cf731099cdcc /tests
parentf54280d9b98a59c33dabb2499f687b63a93043f4 (diff)
Enable boulder tests on Python 3
Diffstat (limited to 'tests')
-rwxr-xr-xtests/boulder-integration.sh4
-rwxr-xr-xtests/manual-http-auth.sh4
-rw-r--r--tests/run_http_server.py11
3 files changed, 16 insertions, 3 deletions
diff --git a/tests/boulder-integration.sh b/tests/boulder-integration.sh
index 6612b2e67..08c482676 100755
--- a/tests/boulder-integration.sh
+++ b/tests/boulder-integration.sh
@@ -82,7 +82,7 @@ CheckHooks() {
# We start a server listening on the port for the
# unrequested challenge to prevent regressions in #3601.
-python -m SimpleHTTPServer $http_01_port &
+python ./tests/run_http_server.py $http_01_port &
python_server_pid=$!
common --domains le1.wtf --preferred-challenges tls-sni-01 auth \
@@ -90,7 +90,7 @@ common --domains le1.wtf --preferred-challenges tls-sni-01 auth \
--post-hook 'echo wtf.post >> "$HOOK_TEST"'\
--renew-hook 'echo renew >> "$HOOK_TEST"'
kill $python_server_pid
-python -m SimpleHTTPServer $tls_sni_01_port &
+python ./tests/run_http_server.py $tls_sni_01_port &
python_server_pid=$!
common --domains le2.wtf --preferred-challenges http-01 run \
--pre-hook 'echo wtf.pre >> "$HOOK_TEST"' \
diff --git a/tests/manual-http-auth.sh b/tests/manual-http-auth.sh
index c4730392b..48c33f04b 100755
--- a/tests/manual-http-auth.sh
+++ b/tests/manual-http-auth.sh
@@ -1,10 +1,12 @@
#!/bin/sh
uri_path=".well-known/acme-challenge/$CERTBOT_TOKEN"
+# This script should be run from the top level. e.g. ./tests/manual-http-auth.sh
+source_dir="$(pwd)"
cd $(mktemp -d)
mkdir -p $(dirname $uri_path)
echo $CERTBOT_VALIDATION > $uri_path
-python -m SimpleHTTPServer $http_01_port >/dev/null 2>&1 &
+python "$source_dir/tests/run_http_server.py" $http_01_port >/dev/null 2>&1 &
server_pid=$!
while ! curl "http://localhost:$http_01_port/$uri_path" >/dev/null 2>&1; do
sleep 1s
diff --git a/tests/run_http_server.py b/tests/run_http_server.py
new file mode 100644
index 000000000..fd1163816
--- /dev/null
+++ b/tests/run_http_server.py
@@ -0,0 +1,11 @@
+import runpy
+import sys
+
+# Run Python's built-in HTTP server
+# Usage: python ./tests/run_http_server.py port_num
+# NOTE: This script should be compatible with 2.6, 2.7, 3.3+
+
+# sys.argv (port number) is passed as-is to the HTTP server module
+runpy.run_module(
+ 'http.server' if sys.version_info[0] == 3 else 'SimpleHTTPServer',
+ run_name='__main__')