Started building test suite

This commit is contained in:
Brad Warren 2015-07-10 11:42:10 -07:00
parent b66c60731f
commit 7081c440e7
5 changed files with 132 additions and 0 deletions

20
tests/plugins/Dockerfile Normal file
View file

@ -0,0 +1,20 @@
# https://github.com/letsencrypt/letsencrypt/pull/431#issuecomment-103659297
# it is more likely developers will already have ubuntu:trusty rather
# than e.g. debian:jessie and image size differences are negligible
FROM httpd
MAINTAINER Brad Warren <bradmw@umich.edu>
RUN mkdir /var/run/apache2 && \
ln -s /usr/local/apache2/conf/mime.types /etc/mime.types
ENV APACHE_CONFDIR=/tmp/apache2 \
APACHE_RUN_USER=daemon \
APACHE_RUN_GROUP=daemon \
APACHE_PID_FILE=/var/run/apache2/apache2.pid \
APACHE_RUN_DIR=/var/run/apache2 \
APACHE_LOCK_DIR=/var/lock \
APACHE_LOG_DIR=/usr/local/apache2/logs
COPY a2enmod.sh /usr/local/bin/
CMD [ "httpd-foreground" ]

29
tests/plugins/a2enmod.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
# An extremely simplified version of 'a2enmod' for the httpd docker image
enable () {
echo "LoadModule "$1"_module /usr/local/apache2/modules/mod_"$1".so" >> \
$APACHE_CONFDIR"/modules.load"
available_base="/mods-available/"$1".conf"
available_conf=$APACHE_CONFDIR$available_base
enabled_dir=$APACHE_CONFDIR"/mods-enabled"
enabled_conf=$enabled_dir"/"$1".conf"
if [ -e "$available_conf" -a -e "$enabled_dir" -a ! -e "$enabled_conf" ]
then
ln -s "..$available_base" $enabled_conf
fi
}
if [ $1 == "ssl" ]
then
# Enables ssl and all its dependencies
enable "setenvif"
enable "mime"
enable "socache_shmcb"
enable "ssl"
elif [ $1 == "rewrite" ]
then
enable "rewrite";
else
exit 1;
fi

49
tests/plugins/parser.py Normal file
View file

@ -0,0 +1,49 @@
"""Module for parsing command line arguments and config files."""
import argparse
DESCRIPTION = """
Tests Let's Encrypt plugins against different web servers and configurations
using Docker images. It is assumed that Docker is already installed.
"""
def parse_args():
"""Returns parsed command line arguments."""
parser = argparse.ArgumentParser(description=DESCRIPTION)
add_args(parser)
args = parser.parse_args()
if args.redirect:
args.names = True
args.install = True
elif args.install:
args.names = True
return args
def add_args(parser):
"""Adds general/program wide arguments to the group."""
group = parser.add_argument_group("general")
group.add_argument(
"-t", "--tar", default="configs.tar.gz",
help="a gzipped tarball containing server configurations")
group.add_argument(
"-p", "--plugin", default="apache",
help="the plugin to be tested")
group.add_argument(
"-n", "--names", action="store_true", help="tests installer's domain "
"name identification")
group.add_argument(
"-a", "--auth", action="store_true", help="tests authenticators")
group.add_argument(
"-i", "--install", action="store_true", help="tests installer's "
"certificate installation (implicitly includes -d)")
group.add_argument(
"-r", "--redirect", action="store_true", help="tests installer's "
"redirecting HTTP to HTTPS (implicitly includes -di)")
group.add_argument(
"--no-simple-http-tls", action="store_true", help="do not use TLS "
"when solving SimpleHTTP challenges")

13
tests/plugins/test.py Normal file
View file

@ -0,0 +1,13 @@
"""Tests Let's Encrypt plugins against different server configurations."""
import parser
import util
def main():
"""Main test script execution."""
args = parser.parse_args()
print util.setup_tmp_dir(args.tar)
if __name__ == "__main__":
main()

21
tests/plugins/util.py Normal file
View file

@ -0,0 +1,21 @@
"""Utility functions for Let's Encrypt plugin tests."""
import os
import tarfile
import tempfile
TEMP_DIRECTORY = tempfile.mkdtemp()
# Location of decompressed server root configurations
CONFIGS = os.path.join(TEMP_DIRECTORY, "configs")
SCRIPTS = os.path.join(TEMP_DIRECTORY, "scripts")
def setup_tmp_dir(tar_path):
"""Sets up a temporary directory for this run and returns its path."""
tar = tarfile.open(tar_path, "r:gz")
tar.extractall(os.path.join(tmp_dir, SERVER_ROOTS))
os.makedirs(os.path.join(tmp_dir, "mnt"))
os.makedirs(os.path.join(tmp_dir, "scripts"))
return tmp_dir