Skip to content

Commit

Permalink
Add drupal11 preset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csandanov committed Aug 7, 2024
1 parent bba11af commit d0fea73
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ test:
cd ./tests/php && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/matomo && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/wordpress && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/drupal/11 && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/drupal/10 && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/drupal/9 && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/drupal/7 && IMAGE=$(REPO):$(TAG) ./run.sh
Expand Down
22 changes: 22 additions & 0 deletions tests/drupal/11/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
nginx:
image: $IMAGE
environment:
DEBUG: 1
NGINX_BACKEND_HOST: drupal
NGINX_VHOST_PRESET: drupal11
NGINX_SERVER_EXTRA_CONF_FILEPATH: /var/www/html/server.conf
NGINX_ALLOW_XML_ENDPOINTS: 1
NGINX_LOG_FORMAT_OVERRIDE: '$$http_x_forwarded_for - $$remote_user [$$time_local] "$$request" $$status $$body_bytes_sent "$$http_referer" "$$http_user_agent"'
depends_on:
- drupal
volumes:
- codebase:/var/www/html
- ./server.conf:/var/www/html/server.conf
drupal:
image: drupal:11-fpm-alpine
volumes:
- codebase:/var/www/html

volumes:
codebase:
69 changes: 69 additions & 0 deletions tests/drupal/11/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash

set -e

if [[ -n "${DEBUG}" ]]; then
set -x
fi

nginx_exec() {
docker compose exec -T nginx "${@}"
}

clean_exit() {
docker compose down -v
}
trap clean_exit EXIT

docker compose up -d

nginx_exec make check-ready -f /usr/local/bin/actions.mk

# TODO: check endpoints of installed Drupal

echo "Checking Drupal endpoints"
echo -n "Checking / page... "
nginx_exec curl -s -S -I "localhost" | grep '302 Found'
echo -n "authorize.php... "
nginx_exec curl -s -S -I "localhost/core/authorize.php" | grep '500 Service unavailable'
echo -n "install.php... "
nginx_exec curl -s -S -I "localhost/core/install.php" | grep '200 OK'
echo -n "statistics.php... "
nginx_exec curl -s -S -I "localhost/core/modules/statistics/statistics.php" | grep '500 Service unavailable'
echo -n "cron... "
nginx_exec curl -s -S -I "localhost/cron" | grep '302 Found'
echo -n "index.php... "
nginx_exec curl -s -S -I "localhost/index.php" | grep '302 Found'
echo -n "update.php... "
nginx_exec curl -s -S -I "localhost/update.php" | grep '302 Found'
echo -n ".htaccess... "
nginx_exec curl -s -S -I "localhost/.htaccess" | grep '403 Forbidden'
echo -n "favicon.ico... "
nginx_exec curl -s -S -I "localhost/favicon.ico" | grep '200 OK'
echo -n "robots.txt... "
nginx_exec curl -s -S -I "localhost/robots.txt" | grep '200 OK'
echo -n "humans.txt... "
nginx_exec curl -s -S -I "localhost/humans.txt" | grep '302 Found'
echo -n "ads.txt... "
nginx_exec curl -s -S -I "localhost/ads.txt" | grep '302 Found'
echo -n "drupal.js... "
nginx_exec curl -s -S -I "localhost/core/misc/drupal.js" | grep '200 OK'
echo -n "druplicon.png... "
nginx_exec curl -s -S -I "localhost/core/misc/druplicon.png" | grep '200 OK'
echo -n "Checking composer.json"
nginx_exec curl -s -S -I "localhost/composer.json" | grep '404 Not Found'
echo -n "Checking package.json"
nginx_exec curl -s -S -I "localhost/core/package.json" | grep '404 Not Found'
echo -n "Checking web.config"
nginx_exec curl -s -S -I "localhost/web.config" | grep '404 Not Found'

echo -n "Checking non existing php endpoint... "
nginx_exec curl -s -S -I "localhost/non-existing.php" | grep '404 Not Found'
echo -n "Checking user-defined internal temporal redirect... "
nginx_exec curl -s -S -I "localhost/redirect-internal-temporal" | grep '302 Moved Temporarily'
echo -n "Checking user-defined internal permanent redirect... "
nginx_exec curl -s -S -I "localhost/redirect-internal-permanent" | grep '301 Moved Permanently'
echo -n "Checking user-defined external redirect... "
nginx_exec curl -s -S -I "localhost/redirect-external" | grep '302 Moved Temporarily'
echo -n "Checking CSP header... "
nginx_exec curl -s -S -I "localhost" | grep "frame-ancestors 'self'"
3 changes: 3 additions & 0 deletions tests/drupal/11/server.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rewrite ^/redirect-internal-permanent$ /index.php permanent;
rewrite ^/redirect-internal-temporal$ /index.php redirect;
rewrite ^/redirect-external$ http://example.com/ redirect;

0 comments on commit d0fea73

Please sign in to comment.