| 1 | #!/bin/sh |
| 2 | |
| 3 | set -eu |
| 4 | |
| 5 | # Needed to find lighttpd binary and the chromedriver binary |
| 6 | export PATH="/sbin:/usr/sbin:/usr/bin:$PATH" |
| 7 | |
| 8 | chromedriver --version |
| 9 | |
| 10 | PORT=8888 |
| 11 | DOCROOT="$AUTOPKGTEST_TMP/docroot" |
| 12 | CONF="$AUTOPKGTEST_TMP/lighttpd.conf" |
| 13 | mkdir -p "$DOCROOT" |
| 14 | # Remove this when postinst is implemented |
| 15 | sudo cp debian/conf/lighttpd.conf /etc/dmarc-srg/lighttpd.conf |
| 16 | # Copy default config |
| 17 | sudo cp /etc/dmarc-srg/conf.sample.php /etc/dmarc-srg/conf.php |
| 18 | cat >"$CONF" <<EOF |
| 19 | server.document-root = "$DOCROOT" |
| 20 | server.port = $PORT |
| 21 | server.modules = ( "mod_access", "mod_auth", "mod_fastcgi", "mod_alias" ) |
| 22 | fastcgi.server += ( ".php" => |
| 23 | (( |
| 24 | "bin-path" => "/usr/bin/php-cgi", |
| 25 | "socket" => "$AUTOPKGTEST_TMP/php.socket", |
| 26 | "max-procs" => 1, |
| 27 | "bin-environment" => ( |
| 28 | "PHP_FCGI_CHILDREN" => "4", |
| 29 | "PHP_FCGI_MAX_REQUESTS" => "10000" |
| 30 | ), |
| 31 | "bin-copy-environment" => ( |
| 32 | "PATH", "SHELL", "USER" |
| 33 | ), |
| 34 | "broken-scriptfilename" => "enable" |
| 35 | )) |
| 36 | ) |
| 37 | include "/etc/dmarc-srg/lighttpd.conf" |
| 38 | mimetype.assign += ( ".html" => "text/html", ".css" => "text/css", ".php" => "application/php" ) |
| 39 | index-file.names = ( "index.php" ) |
| 40 | static-file.exclude-extensions = ( ".php" ) |
| 41 | |
| 42 | EOF |
| 43 | |
| 44 | # validate test configuration |
| 45 | lighttpd -tt -f "$CONF" |
| 46 | |
| 47 | lighttpd -D -f "$CONF" 2>/dev/stdout & |
| 48 | LIGHTTPD_PID=$! |
| 49 | |
| 50 | # Allow commands to fail |
| 51 | set +e |
| 52 | |
| 53 | # Wait a bit for things to stale |
| 54 | sleep 5 |
| 55 | # Do tests |
| 56 | # Send to stdout (https://bugs.python.org/issue16164) |
| 57 | python3 ./debian/tests/test_dmarc-srg_web.py 2>/dev/stdout |
| 58 | |
| 59 | EXIT_CODE=$? |
| 60 | if [ "$EXIT_CODE" -ne "0" ]; then |
| 61 | echo "Tests failed !" |
| 62 | fi |
| 63 | |
| 64 | trap 'kill "$LIGHTTPD_PID"' EXIT |
| 65 | |
| 66 | exit $EXIT_CODE |