Procházet zdrojové kódy

Merge pull request #13649 from J0WI/posfixadmin-test

Fix postfixadmin
Tianon Gravi před 3 roky
rodič
revize
d4e3252f75

+ 3 - 3
library/postfixadmin

@@ -5,14 +5,14 @@ GitRepo: https://github.com/postfixadmin/docker.git
 Tags: 3.3.11-apache, 3.3-apache, 3-apache, apache, 3.3.11, 3.3, 3, latest
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
 Directory: apache
-GitCommit: 9015fbc506fd3d813cf0fa404bc51dd2bfcfeaef
+GitCommit: d6a00844d6ddc441062dc4caf7e77de2b24bf8cc
 
 Tags: 3.3.11-fpm, 3.3-fpm, 3-fpm, fpm
 Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
 Directory: fpm
-GitCommit: 9015fbc506fd3d813cf0fa404bc51dd2bfcfeaef
+GitCommit: d6a00844d6ddc441062dc4caf7e77de2b24bf8cc
 
 Tags: 3.3.11-fpm-alpine, 3.3-fpm-alpine, 3-fpm-alpine, fpm-alpine
 Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
 Directory: fpm-alpine
-GitCommit: 9015fbc506fd3d813cf0fa404bc51dd2bfcfeaef
+GitCommit: d6a00844d6ddc441062dc4caf7e77de2b24bf8cc

+ 6 - 0
test/config.sh

@@ -190,6 +190,12 @@ imageTests+=(
 		plone-zeoclient
 		plone-zeosite
 	'
+	[postfixadmin:apache]='
+		postfixadmin-apache-run
+	'
+	[postfixadmin:fpm]='
+		postfixadmin-fpm-run
+	'
 	[postgres]='
 		postgres-basics
 		postgres-initdb

+ 36 - 0
test/tests/postfixadmin-apache-run/run.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+# Use a client image with curl for testing
+clientImage='buildpack-deps:buster-curl'
+# ensure the clientImage is ready and available
+if ! docker image inspect "$clientImage" &> /dev/null; then
+	docker pull "$clientImage" > /dev/null
+fi
+
+serverImage="$1"
+
+# Create an instance of the container-under-test
+cid="$(docker run -d "$serverImage")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+_request() {
+	local method="$1"
+	shift
+
+	local url="${1#/}"
+	shift
+
+	docker run --rm \
+		--link "$cid":apache \
+		"$clientImage" \
+		curl -fsL -X"$method" "$@" "http://apache/$url"
+}
+
+# Make sure that Apache is listening and ready
+. "$dir/../../retry.sh" --tries 10 '_request GET / --output /dev/null'
+
+# Check that we can request / and that it contains the word "login" somewhere
+_request GET '/' | grep -i login > /dev/null

+ 46 - 0
test/tests/postfixadmin-fpm-run/run.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Build a client image with cgi-fcgi for testing
+clientImage='librarytest/posfixadmin-fpm-run:fcgi-client'
+docker build -t "$clientImage" - > /dev/null <<'EOF'
+FROM debian:buster-slim
+
+RUN set -x && apt-get update && apt-get install -y --no-install-recommends libfcgi-bin && rm -rf /var/lib/apt/lists/*
+
+ENTRYPOINT ["cgi-fcgi"]
+EOF
+
+# Create an instance of the container-under-test
+cid="$(docker run -d "$image")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+fcgi-request() {
+	local method="$1"
+
+	local url="$2"
+	local queryString=
+	if [[ "$url" == *\?* ]]; then
+		queryString="${url#*\?}"
+		url="${url%%\?*}"
+	fi
+
+	docker run --rm -i --link "$cid":fpm \
+		-e REQUEST_METHOD="$method" \
+		-e SCRIPT_NAME="$url" \
+		-e SCRIPT_FILENAME=/var/www/html/public/"${url#/}" \
+		-e QUERY_STRING="$queryString" \
+		-e HTTP_HOST='localhost' \
+		"$clientImage" \
+		-bind -connect fpm:9000
+}
+
+# Make sure that PHP-FPM is listening and ready
+. "$dir/../../retry.sh" --tries 10 'fcgi-request GET /index.php' > /dev/null 2>&1
+
+# index.php redirects to login.php, check that it contains the word "login" somewhere
+fcgi-request GET '/login.php' | grep -i login > /dev/null