mirror of
https://github.com/cytopia/devilbox.git
synced 2025-01-29 15:44:04 +00:00
Add integration tests via GitHub Actions
This commit is contained in:
parent
ace5d7c1fc
commit
2aacfeaaed
@ -188,9 +188,10 @@ class Httpd extends BaseClass implements BaseInterface
|
||||
return false;
|
||||
}
|
||||
$dir = loadClass('Helper')->getEnv('HTTPD_TEMPLATE_DIR');
|
||||
$cfg = '/shared/httpd/'.$vhost.'/'.$dir.'/'.$name;
|
||||
|
||||
if (is_file('/shared/httpd/'.$vhost.'/'.$dir.'/'.$name)) {
|
||||
return '/shared/httpd/'.$vhost.'/'.$dir.'/'.$name;
|
||||
if (is_file($cfg)) {
|
||||
return $cfg;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
5
.github/stale.yml
vendored
5
.github/stale.yml
vendored
@ -1,7 +1,8 @@
|
||||
---
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 60
|
||||
daysUntilStale: 90
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
daysUntilClose: 30
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- "issue:protected"
|
||||
|
189
.github/workflows/ci-smoke-linux.yml
vendored
Normal file
189
.github/workflows/ci-smoke-linux.yml
vendored
Normal file
@ -0,0 +1,189 @@
|
||||
---
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Job Name
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
name: Linux
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# When to run
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
on:
|
||||
# Runs on Pull Requests
|
||||
pull_request:
|
||||
|
||||
# Runs on master Branch and Tags
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+*'
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# What to run
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
jobs:
|
||||
smoke_linux:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php:
|
||||
- "5.3"
|
||||
- "5.4"
|
||||
- "5.5"
|
||||
- "5.6"
|
||||
- "7.0"
|
||||
- "7.1"
|
||||
- "7.2"
|
||||
- "7.3"
|
||||
- "7.4"
|
||||
- "8.0"
|
||||
httpd:
|
||||
- "apache-2.2"
|
||||
- "apache-2.4"
|
||||
- "nginx-stable"
|
||||
- "nginx-mainline"
|
||||
|
||||
name: "[PHP ${{ matrix.php }}] vs [${{ matrix.httpd }}]"
|
||||
steps:
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Checkout repository
|
||||
# ------------------------------------------------------------
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Show environment
|
||||
shell: bash
|
||||
run: |
|
||||
env
|
||||
|
||||
- name: Show network
|
||||
shell: bash
|
||||
run: |
|
||||
netstat -an || true
|
||||
ss -tlun || true
|
||||
|
||||
- name: Show Docker version
|
||||
shell: bash
|
||||
run: |
|
||||
docker version
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Setup
|
||||
# ------------------------------------------------------------
|
||||
- name: Configure
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
# Set the two candidates to test against
|
||||
make configure KEY=PHP_SERVER VAL=${PHP}
|
||||
make configure KEY=HTTPD_SERVER VAL=${HTTPD}
|
||||
|
||||
# Set projects directory
|
||||
make configure KEY=HOST_PATH_HTTPD_DATADIR VAL=.tests/www
|
||||
|
||||
# Set uid/gid
|
||||
make configure KEY=NEW_UID VAL=$(id -u)
|
||||
make configure KEY=NEW_GID VAL=$(id -g)
|
||||
|
||||
# Make it more verbose
|
||||
make configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL=2
|
||||
|
||||
# 3306 is taken, so chose another one
|
||||
make configure KEY=HOST_PORT_MYSQL VAL=3307
|
||||
env:
|
||||
PHP: ${{ matrix.php }}
|
||||
HTTPD: ${{ matrix.httpd }}
|
||||
|
||||
- name: Pull images
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make pull
|
||||
|
||||
- name: Startup
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make start
|
||||
|
||||
- name: Docker logs
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make logs
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Run tests
|
||||
# ------------------------------------------------------------
|
||||
- name: Test Modules
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-modules
|
||||
|
||||
- name: Test Config
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-config
|
||||
|
||||
- name: Test Intranet
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-intranet
|
||||
|
||||
- name: Test Vendors
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-vendors
|
||||
|
||||
- name: Test Vhosts
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-vhosts
|
||||
|
||||
- name: Test Reverse Proxy
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-rproxies
|
||||
|
||||
- name: Test SSL
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-ssl
|
||||
|
||||
- name: Test Bind
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-bind
|
||||
|
||||
- name: Test Autostart
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-autostart
|
||||
|
||||
- name: "Test Framework: CakePHP"
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-framework-cakephp
|
||||
|
||||
- name: "Test Framework: Drupal"
|
||||
shell: bash
|
||||
run: |
|
||||
cd .tests/
|
||||
make test-smoke-framework-drupal
|
12
.gitignore
vendored
12
.gitignore
vendored
@ -124,13 +124,10 @@
|
||||
*.rst.todo
|
||||
|
||||
# Ignore vhost-gen files in test dir (copied on the fly)
|
||||
/.tests/vhost-tests/my-vhost/.devilbox/apache22.yml
|
||||
/.tests/vhost-tests/my-vhost/.devilbox/apache24.yml
|
||||
/.tests/vhost-tests/my-vhost/.devilbox/nginx.yml
|
||||
|
||||
/.tests/vhost-tests/my-rhost/.devilbox/apache22.yml
|
||||
/.tests/vhost-tests/my-rhost/.devilbox/apache24.yml
|
||||
/.tests/vhost-tests/my-rhost/.devilbox/nginx.yml
|
||||
/.tests/tmp/*
|
||||
/.tests/www/*
|
||||
!/.tests/www/modules
|
||||
!/.tests/www/rproxy/js
|
||||
|
||||
# Keep folders
|
||||
!.keepme
|
||||
@ -204,4 +201,3 @@ $RECYCLE.BIN/
|
||||
###### BBEdit ######
|
||||
*.bbprojectd
|
||||
*.bbproject
|
||||
|
||||
|
676
.tests/Makefile
676
.tests/Makefile
@ -1,28 +1,8 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Settings
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
ifneq (,)
|
||||
.error This Makefile requires GNU Make.
|
||||
endif
|
||||
|
||||
SHELL := /bin/bash
|
||||
|
||||
.PHONY: update-readme
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Variables
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# Paths and directory names
|
||||
CURRENT_PATH = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
DEVILBOX_PATH = $(CURRENT_PATH)..
|
||||
DEVILBOX_NAME = $(shell cd $(DEVILBOX_PATH); basename $$(pwd))
|
||||
|
||||
# Docker
|
||||
DOCKER_NETWORK = $(shell docker network ls --filter name='$(DEVILBOX_NAME)' --quiet)
|
||||
|
||||
# Devilbox test settings
|
||||
PROJECTV = my-vhost
|
||||
PROJECTR = my-rhost
|
||||
VHOST = $(PROJECTV).loc
|
||||
RHOST = $(PROJECTR).loc
|
||||
SHELL = /bin/sh
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
@ -30,607 +10,143 @@ RHOST = $(PROJECTR).loc
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
update-readme:
|
||||
cat "../README.md" \
|
||||
| perl -00 -pe "s/<!-- modules -->.*<!-- \/modules -->/<!-- modules -->\n$$(./get-modules.sh)\n<!-- \/modules -->/s" \
|
||||
| perl -00 -pe "s/<!-- modules -->.*<!-- \/modules -->/<!-- modules -->\n$$(./scripts/get-modules.sh)\n<!-- \/modules -->/s" \
|
||||
> "../README.md.tmp"
|
||||
yes | mv -f "../README.md.tmp" "../README.md"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Testing Targets
|
||||
# Startup Targets
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Initialize .env file and data dir
|
||||
### Configure .env file
|
||||
###
|
||||
init:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# INITIALIZING .env FILE"
|
||||
@echo "####################################################################################################"
|
||||
$(eval MY_UID := $(shell id -u))
|
||||
$(eval MY_GID := $(shell id -g))
|
||||
|
||||
@# Ensure .env file exists
|
||||
install -m 0644 $(DEVILBOX_PATH)/env-example $(DEVILBOX_PATH)/.env
|
||||
@# Ensure project vhost-gen files exist (vhost)
|
||||
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache22.yml-example-vhost $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/.devilbox/apache22.yml
|
||||
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache24.yml-example-vhost $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/.devilbox/apache24.yml
|
||||
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/nginx.yml-example-vhost $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/.devilbox/nginx.yml
|
||||
@# Ensure project vhost-gen files exist (rhost)
|
||||
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache22.yml-example-rproxy $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/.devilbox/apache22.yml
|
||||
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache24.yml-example-rproxy $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/.devilbox/apache24.yml
|
||||
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/nginx.yml-example-rproxy $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/.devilbox/nginx.yml
|
||||
@# Set bind port
|
||||
echo "HOST_PORT_BIND=53" >> $(DEVILBOX_PATH)/.env
|
||||
@# Set data dir
|
||||
sed -i'' 's/^HOST_PATH_HTTPD_DATADIR=/#HOST_PATH_HTTPD_DATADIR=/g' $(DEVILBOX_PATH)/.env
|
||||
echo "HOST_PATH_HTTPD_DATADIR=.tests/vhost-tests" >> $(DEVILBOX_PATH)/.env
|
||||
@# Set uid/gid
|
||||
sed -i'' 's/^NEW_UID=.*/NEW_UID=$(MY_UID)/g' $(DEVILBOX_PATH)/.env
|
||||
sed -i'' 's/^NEW_GID=.*/NEW_GID=$(MY_GID)/g' $(DEVILBOX_PATH)/.env
|
||||
@echo
|
||||
|
||||
|
||||
###
|
||||
### Configure custom versions
|
||||
###
|
||||
configure:
|
||||
ifdef SRV
|
||||
ifdef VER
|
||||
sed -i'' 's/^$(SRV)/#$(SRV)/g' $(DEVILBOX_PATH)/.env
|
||||
echo "$(SRV)=$(VER)" >> $(DEVILBOX_PATH)/.env
|
||||
configure: ../.env
|
||||
ifeq ($(KEY),)
|
||||
$(error Target requires KEY to be set.)
|
||||
endif
|
||||
ifeq ($(VAL),)
|
||||
$(error Target requires VAL to be set.)
|
||||
endif
|
||||
@$(PWD)/scripts/env-setvar.sh "$(KEY)" "$(VAL)"
|
||||
|
||||
|
||||
###
|
||||
### Start Devilbox
|
||||
### Pull currently setup images
|
||||
###
|
||||
start: stop pull
|
||||
@echo "####################################################################################################"
|
||||
@echo "# STARTING CONTAINER"
|
||||
@echo "####################################################################################################"
|
||||
cd $(DEVILBOX_PATH) && docker-compose up -d
|
||||
@$(MAKE) _wait
|
||||
@echo
|
||||
pull: ../.env
|
||||
@$(PWD)/scripts/compose-pull.sh
|
||||
|
||||
|
||||
###
|
||||
### Pulling latest container
|
||||
### Startup Devilbox
|
||||
###
|
||||
pull:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# PULLING LATEST CONTAINER"
|
||||
@echo "####################################################################################################"
|
||||
cd $(DEVILBOX_PATH) && until docker-compose pull; do sleep 1; done
|
||||
@echo
|
||||
@echo
|
||||
start: ../.env
|
||||
@$(PWD)/scripts/compose-start.sh
|
||||
|
||||
|
||||
###
|
||||
### Stop Devilbox
|
||||
### Show Docker logs
|
||||
###
|
||||
stop:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# STOPPING CONTAINER"
|
||||
@echo "####################################################################################################"
|
||||
cd $(DEVILBOX_PATH) && docker-compose stop || true
|
||||
cd $(DEVILBOX_PATH) && docker-compose kill || true
|
||||
cd $(DEVILBOX_PATH) && docker-compose rm -f || true
|
||||
@echo
|
||||
logs:
|
||||
@$(PWD)/scripts/compose-logs.sh
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Test Targets
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-modules:
|
||||
$(PWD)/tests/curl-vhosts.sh "modules"
|
||||
$(PWD)/tests/php-vhosts.sh "modules"
|
||||
|
||||
|
||||
###
|
||||
### Get Info
|
||||
###
|
||||
info:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# CONTAINER INFO"
|
||||
@echo "####################################################################################################"
|
||||
|
||||
$(eval DOCKER := $(shell docker --version))
|
||||
$(eval COMPOSE := $(shell docker-compose --version))
|
||||
|
||||
$(eval BIND := $(shell curl -sS localhost/index.php | grep -Ei 'bg-info.*Bind' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval PHP := $(shell curl -sS localhost/index.php | grep -Ei 'bg-info.*PHP' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval HTTPN := $(shell curl -sS localhost/index.php | grep -Ei 'bg-info.*(nginx|apache)' | grep -Eio 'nginx|apache'))
|
||||
$(eval HTTPV := $(shell curl -sS localhost/index.php | grep -Ei 'bg-info.*(nginx|apache)' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval MYSQLN := $(shell curl -sS localhost/index.php | grep -Ei 'bg-warn.*(mysql|maria|percona)' | grep -Eio 'mysql|maria|percona'))
|
||||
$(eval MYSQLV := $(shell curl -sS localhost/index.php | grep -Ei 'bg-warn.*(mysql|maria|percona)' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval PGSQL := $(shell curl -sS localhost/index.php | grep -Ei 'bg-warn.*Postgre' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval REDIS := $(shell curl -sS localhost/index.php | grep -Ei 'bg-dang.*Redis' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval MEMCD := $(shell curl -sS localhost/index.php | grep -Ei 'bg-dang.*Memcached' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
$(eval MONGO := $(shell curl -sS localhost/index.php | grep -Ei 'bg-dang.*Mongo' | grep -Eo '\(.+?\)' | sed -e 's/(//g' -e 's/)//g'))
|
||||
|
||||
@echo "Docker: $(DOCKER)"
|
||||
@echo "Compose: $(COMPOSE)"
|
||||
@echo "Bind: $(BIND)"
|
||||
@echo "PHP: $(PHP)"
|
||||
@echo "HTTPD: $(HTTPN) $(HTTPV)"
|
||||
@echo "MYSQL: $(MYSQLN) $(MYSQLV)"
|
||||
@echo "PGSQL: $(PGSQL)"
|
||||
@echo "Redis: $(REDIS)"
|
||||
@echo "Memcd: $(MEMCD)"
|
||||
@echo "Mongo: $(MONGO)"
|
||||
@echo
|
||||
###
|
||||
test-smoke-config:
|
||||
$(PWD)/tests/config-xdebug.sh
|
||||
|
||||
|
||||
###
|
||||
### Run tests
|
||||
###
|
||||
test: test-ssl test-vhost test-rhost test-intra test-startup
|
||||
###
|
||||
test-smoke-intranet:
|
||||
$(PWD)/tests/intranet-homepage.sh
|
||||
$(PWD)/tests/intranet-vhost.sh
|
||||
$(PWD)/tests/intranet-email.sh
|
||||
$(PWD)/tests/intranet-redis.sh
|
||||
$(PWD)/tests/intranet-memcached.sh
|
||||
|
||||
|
||||
test-ssl:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# RUNNING TESTS: SSL"
|
||||
@echo "####################################################################################################"
|
||||
@echo
|
||||
@# ---------- curl from host ----------
|
||||
@printf "[TEST] curl -sS --cacert ../ca/devilbox-ca.crt https://localhost/index.php"
|
||||
@if ! curl -sS -o /dev/null --cacert ../ca/devilbox-ca.crt https://localhost/index.php; then \
|
||||
sleep 1; \
|
||||
if ! curl -sS -o >/dev/null --cacert ../ca/devilbox-ca.crt https://localhost/index.php; then \
|
||||
sleep 1; \
|
||||
if ! curl -sS -o /dev/null --cacert ../ca/devilbox-ca.crt https://localhost/index.php; then \
|
||||
printf "\r[FAIL] curl -sS --cacert ../ca/devilbox-ca.crt https://localhost/index.php\n"; \
|
||||
\
|
||||
printf "\n[INFO] curl -I -sS --cacert ../ca/devilbox-ca.crt https://google.com\n"; \
|
||||
curl -I -sS --cacert ../ca/devilbox-ca.crt https://google.com || true; \
|
||||
\
|
||||
printf "\n[INFO] curl -I -sS https://google.com\n"; \
|
||||
curl -I -sS https://google.com || true; \
|
||||
\
|
||||
exit 1; \
|
||||
else \
|
||||
printf "\r[OK] curl -sS --cacert ../ca/devilbox-ca.crt https://localhost/index.php (3 rounds)\n"; \
|
||||
fi \
|
||||
else \
|
||||
printf "\r[OK] curl -sS --cacert ../ca/devilbox-ca.crt https://localhost/index.php (2 rounds)\n"; \
|
||||
fi \
|
||||
else \
|
||||
printf "\r[OK] curl -sS --cacert ../ca/devilbox-ca.crt https://localhost/index.php (1 round)\n"; \
|
||||
fi
|
||||
@# ---------- curl from Docker ----------
|
||||
@printf "[TEST] docker-compose exec php curl -sS https://httpd/index.php";
|
||||
@if ! sh -c "cd $(DEVILBOX_PATH) && docker-compose exec php curl -sS -o /dev/null https://httpd/index.php"; then \
|
||||
sleep 1; \
|
||||
if ! sh -c "cd $(DEVILBOX_PATH) && docker-compose exec php curl -o /dev/null -sS https://httpd/index.php"; then \
|
||||
sleep 1; \
|
||||
if ! sh -c "cd $(DEVILBOX_PATH) && docker-compose exec php curl -o >/dev/null -sS https://httpd/index.php"; then \
|
||||
printf "\r[FAIL] docker-compose exec php curl -sS https://httpd/index.php\n"; \
|
||||
\
|
||||
printf "\n[INFO] docker-compose exec php curl -I -sS --cacert /ca/devilbox-ca.crt https://httpd/index.php\n"; \
|
||||
sh -c "cd $(DEVILBOX_PATH) && docker-compose exec php curl -I -sS --cacert /ca/devilbox-ca.crt https://httpd/index.php" || true; \
|
||||
\
|
||||
printf "\n[INFO] docker-compose exec php curl -I -sS --cacert /ca/devilbox-ca.crt https://google.com\n"; \
|
||||
sh -c "cd $(DEVILBOX_PATH) && docker-compose exec php curl -I -sS --cacert /ca/devilbox-ca.crt https://google.com" || true; \
|
||||
\
|
||||
printf "\n[INFO] docker-compose exec php curl -I -sS https://google.com\n"; \
|
||||
sh -c "cd $(DEVILBOX_PATH) && docker-compose exec php curl -I -sS https://google.com" || true; \
|
||||
\
|
||||
exit 1; \
|
||||
else \
|
||||
printf "\r[OK] docker-compose exec php curl -sS https://httpd/index.php (3 rounds)\n"; \
|
||||
fi \
|
||||
else \
|
||||
printf "\r[OK] docker-compose exec php curl -sS https://httpd/index.php (2 rounds)\n"; \
|
||||
fi \
|
||||
else \
|
||||
printf "\r[OK] docker-compose exec php curl -sS https://httpd/index.php (1 round)\n"; \
|
||||
fi
|
||||
@echo
|
||||
@echo
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-vendors:
|
||||
$(PWD)/tests/vendor-adminer.sh
|
||||
$(PWD)/tests/vendor-phpmyadmin.sh
|
||||
$(PWD)/tests/vendor-phppgadmin.sh
|
||||
$(PWD)/tests/vendor-phpredmin.sh
|
||||
|
||||
|
||||
test-vhost:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# RUNNING TESTS: VHOST"
|
||||
@echo "####################################################################################################"
|
||||
@echo
|
||||
|
||||
@# Required to test against apache-2.(2|4)
|
||||
$(eval HTTPD_SERVER := $(shell grep -E '^HTTPD_SERVER' $(DEVILBOX_PATH)/.env | sed 's/.*=//g'))
|
||||
|
||||
@# Gather files to test
|
||||
$(eval PHP_FILES := $(notdir $(wildcard $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/htdocs/*.php)))
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [vhost] Test curl HTTP from Docker host"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@$(foreach file,\
|
||||
$(PHP_FILES), \
|
||||
printf "[TEST] curl -sS --header 'Host: $(VHOST)' http://localhost/$(file)"; \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
if ! curl -sS --header 'Host: $(VHOST)' http://localhost/$(file) | grep -qE '^OK$$'; then \
|
||||
printf "\r[FAIL] curl -sS --header 'Host: $(VHOST)' http://localhost/$(file)\n"; \
|
||||
curl -sS --header 'Host: $(VHOST)' http://localhost/$(file); \
|
||||
curl -sS -I --header 'Host: $(VHOST)' http://localhost/$(file); \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
else \
|
||||
printf "\r[OK] curl -sS --header 'Host: $(VHOST)' http://localhost/$(file)\n"; \
|
||||
fi; \
|
||||
)
|
||||
@echo
|
||||
|
||||
@# Error: Hostname localhost provided via SNI and hostname vhost-tests.loc provided via HTTP are different
|
||||
@# @echo "# ----------------------------------------------------------------------------------------"
|
||||
@# @echo "# [vhost] Test curl HTTPS from Docker host"
|
||||
@# @echo "# ----------------------------------------------------------------------------------------"
|
||||
@# @$(foreach file,\
|
||||
@# $(PHP_FILES), \
|
||||
@# printf "[TEST] curl -k -sS --header 'Host: $(VHOST)' https://localhost/$(file)"; \
|
||||
@# cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
@# if ! curl -k -sS --header 'Host: $(VHOST)' https://localhost/$(file) | grep -qE '^OK$$'; then \
|
||||
@# printf "\r[FAIL] curl -k -sS --header 'Host: $(VHOST)' https://localhost/$(file)\n"; \
|
||||
@# curl -k -sS --header 'Host: $(VHOST)' https://localhost/$(file); \
|
||||
@# curl -k -sS -I --header 'Host: $(VHOST)' https://localhost/$(file); \
|
||||
@# cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
@# exit 1; \
|
||||
@# else \
|
||||
@# printf "\r[OK] curl -k -sS --header 'Host: $(VHOST)' https://localhost/$(file)\n"; \
|
||||
@# fi; \
|
||||
@# )
|
||||
@# @echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [vhost] Test curl HTTP from inside Docker container"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@$(foreach file,\
|
||||
$(PHP_FILES), \
|
||||
printf "[TEST] docker-compose exec php curl -sS http://$(VHOST)/$(file)"; \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
cd $(DEVILBOX_PATH); \
|
||||
if ! docker-compose exec php curl -sS http://$(VHOST)/$(file) | grep -qE '^OK$$'; then \
|
||||
printf "\r[FAIL] docker-compose exec php curl -sS http://$(VHOST)/$(file)\n"; \
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec php curl -sS http://$(VHOST)/$(file); \
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec php curl -sS -I http://$(VHOST)/$(file); \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
else \
|
||||
printf "\r[OK] docker-compose exec php curl -sS http://$(VHOST)/$(file)\n"; \
|
||||
fi; \
|
||||
)
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [vhost] Test curl HTTPS from inside Docker container"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@$(foreach file,\
|
||||
$(PHP_FILES), \
|
||||
printf "[TEST] docker-compose exec php curl -sS https://$(VHOST)/$(file)"; \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
cd $(DEVILBOX_PATH); \
|
||||
if ! docker-compose exec php curl -sS https://$(VHOST)/$(file) | grep -qE '^OK$$'; then \
|
||||
printf "\r[FAIL] docker-compose exec php curl -sS https://$(VHOST)/$(file)\n"; \
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec php curl -sS https://$(VHOST)/$(file); \
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec php curl -sS -I https://$(VHOST)/$(file); \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
else \
|
||||
printf "\r[OK] docker-compose exec php curl -sS https://$(VHOST)/$(file)\n"; \
|
||||
fi; \
|
||||
)
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [vhost] Test php-cli from inside Docker container"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@$(foreach file,\
|
||||
$(PHP_FILES), \
|
||||
printf "[TEST] docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file)"; \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
cd $(DEVILBOX_PATH); \
|
||||
if ! docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file) | grep -q '^OK$$'; then \
|
||||
printf "\r[TEST] docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file)\n"; \
|
||||
cd $(DEVILBOX_PATH) && docker-composeexec php php /shared/httpd/$(PROJECTV)/htdocs/$(file); \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
else \
|
||||
printf "\r[OK] docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file)\n"; \
|
||||
fi; \
|
||||
)
|
||||
@echo
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-vhosts:
|
||||
$(PWD)/tests/vhost-directory_index.sh
|
||||
$(PWD)/tests/vhost-vhostgen_default_template.sh
|
||||
$(PWD)/tests/vhost-vhostgen_customize.sh
|
||||
|
||||
|
||||
test-rhost:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# RUNNING TESTS: RHOST"
|
||||
@echo "####################################################################################################"
|
||||
@echo
|
||||
|
||||
@# Gather files to test
|
||||
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/tests/*.sh)))
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [rhost] Startup"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@$(CURRENT_PATH)/vhost-tests/$(PROJECTR)/start-pm.sh
|
||||
|
||||
@$(foreach file,\
|
||||
$(SH_FILES), \
|
||||
echo; \
|
||||
echo "# ----------------------------------------------------------------------------------------"; \
|
||||
echo "# [rhost] $(file)"; \
|
||||
echo "# ----------------------------------------------------------------------------------------"; \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
if ! $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/tests/$(file); then \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
fi \
|
||||
)
|
||||
@echo
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-rproxies:
|
||||
$(PWD)/tests/rproxy-javascript.sh
|
||||
|
||||
|
||||
test-intra:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# RUNNING TESTS: INTRANET"
|
||||
@echo "####################################################################################################"
|
||||
@echo
|
||||
|
||||
@# Gather files to test
|
||||
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/intra-tests/*.sh)))
|
||||
|
||||
@$(foreach file,\
|
||||
$(SH_FILES), \
|
||||
echo "# ----------------------------------------------------------------------------------------"; \
|
||||
echo "# [intra] $(file)"; \
|
||||
echo "# ----------------------------------------------------------------------------------------"; \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
if ! $(CURRENT_PATH)/intra-tests/$(file); then \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo; \
|
||||
)
|
||||
@echo
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-ssl:
|
||||
$(PWD)/tests/ssl-intranet.sh
|
||||
$(PWD)/tests/ssl-vhost.sh
|
||||
|
||||
|
||||
test-startup:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# RUNNING TESTS: STARTUP"
|
||||
@echo "####################################################################################################"
|
||||
@echo
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-bind:
|
||||
@echo noop
|
||||
|
||||
@# Gather files to test
|
||||
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/startup-tests/*.sh)))
|
||||
|
||||
@$(foreach file,\
|
||||
$(SH_FILES), \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
|
||||
if ! $(CURRENT_PATH)/startup-tests/$(file); then \
|
||||
cd $(CURRENT_PATH) && $(MAKE) _logs; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo; \
|
||||
)
|
||||
@echo
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-autostart:
|
||||
$(PWD)/tests/autostart-examples.sh
|
||||
|
||||
|
||||
###
|
||||
###
|
||||
###
|
||||
test-smoke-framework-cakephp:
|
||||
$(PWD)/tests/framework-cakephp.sh
|
||||
|
||||
test-smoke-framework-drupal:
|
||||
$(PWD)/tests/framework-drupal.sh
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Helper Targets
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# TODO: this is super slow and should better be replaced by using local files instead
|
||||
_clean-round:
|
||||
$(eval HTTPD_SERVER := $(shell grep -E '^HTTPD_SERVER' $(DEVILBOX_PATH)/.env | sed 's/.*=//g'))
|
||||
$(eval PHP_SERVER := $(shell grep -E '^PHP_SERVER' $(DEVILBOX_PATH)/.env | sed 's/.*=//g'))
|
||||
|
||||
@cd $(DEVILBOX_PATH) && docker-compose exec php truncate -s0 /var/mail/devilbox
|
||||
|
||||
@> $(DEVILBOX_PATH)/log/php-fpm-$(PHP_SERVER)/php-fpm.access
|
||||
@> $(DEVILBOX_PATH)/log/php-fpm-$(PHP_SERVER)/php-fpm.error
|
||||
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/defaultlocalhost-access.log >/dev/null 2>&1 || true
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/defaultlocalhost-error.log >/dev/null 2>&1 || true
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/defaultlocalhost_ssl-access.log >/dev/null 2>&1 || true
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/defaultlocalhost_ssl-error.log >/dev/null 2>&1 || true
|
||||
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)-access.log >/dev/null 2>&1 || true
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)-error.log >/dev/null 2>&1 || true
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-access.log >/dev/null 2>&1 || true
|
||||
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-error.log >/dev/null 2>&1 || true
|
||||
|
||||
|
||||
_logs:
|
||||
@echo "####################################################################################################"
|
||||
@echo "# SHOWING LOGS"
|
||||
@echo "####################################################################################################"
|
||||
@echo
|
||||
|
||||
$(eval HTTPD_SERVER := $(shell grep -E '^HTTPD_SERVER' $(DEVILBOX_PATH)/.env | sed 's/.*=//g'))
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] docker-compose ps"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose ps;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [HTTPD] docker-compose logs httpd"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs httpd;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [PHP] docker-compose logs php"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs php;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [BIND] docker-compose logs bind"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs bind;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [MYSQL] docker-compose logs mysql"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs mysql;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [PGSQL] docker-compose logs pgsql"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs pgsql;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [REDIS] docker-compose logs redis"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs redis;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [MEMCD] docker-compose logs memcd"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs memcd;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [DOCKER] [MONGO] docker-compose logs mongo"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose logs mongo;
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [PHP] php-fpm.access"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec php cat /var/log/php/php-fpm.access || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [PHP] php-fpm.error"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec php cat /var/log/php/php-fpm.error || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] defaultlocalhost-access.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/defaultlocalhost-access.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] defaultlocalhost-error.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/defaultlocalhost-error.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] defaultlocalhost_ssl-access.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/defaultlocalhost_ssl-access.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] defaultlocalhost_ssl-error.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/defaultlocalhost_ssl-error.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTV)-access.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)-access.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTV)-error.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)-error.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTV)_ssl-access.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-access.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTV)_ssl-error.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-error.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTR)-access.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)-access.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTR)-error.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)-error.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTR)_ssl-access.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)_ssl-access.log || true
|
||||
@echo
|
||||
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
@echo "# [HTTPD] $(PROJECTR)_ssl-error.log"
|
||||
@echo "# ----------------------------------------------------------------------------------------"
|
||||
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)_ssl-error.log || true
|
||||
@echo
|
||||
|
||||
|
||||
_wait:
|
||||
@printf "Waiting for HTTP 200 ";
|
||||
@# [HTTPD] Test for HTTP Status 200
|
||||
@until curl -sS -o /dev/null -I -w "%{http_code}" localhost 2>/dev/null | grep -q '200'; do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
|
||||
@# [PHP] Test for HTTP content
|
||||
@printf "Waiting for Intranet to be ready ";
|
||||
@until curl -sS localhost 2>/dev/null | grep -q 'dvlbox-ok'; do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
|
||||
@# Add 20 more seconds just to be sure
|
||||
@printf "Waiting for initial setup ";
|
||||
@for i in $$(seq 1 20); do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
|
||||
@# [MongoDB] Test for MongoDB connection
|
||||
@printf "Waiting for MongoDB connection to be ready ";
|
||||
@until cd $(DEVILBOX_PATH) && docker-compose exec php mongofiles --host=mongo list >/dev/null 2>&2; do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
|
||||
@# [MYSQL] Test for MySQL connection
|
||||
@printf "Waiting for MySQL connection to be ready ";
|
||||
@until cd $(DEVILBOX_PATH) && docker-compose exec php mysql --user=root --password='' --host=mysql -e 'show databases;' 2>&1 | grep -q mysql; do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
|
||||
@# [PGSQL] Test for PGSQL connection
|
||||
@printf "Waiting for PostgreSQL connection to be ready ";
|
||||
@until cd $(DEVILBOX_PATH) && docker-compose exec php pg_isready --host=pgsql >/dev/null 2>&1; do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
|
||||
@# Add 40 more seconds just to be sure
|
||||
@printf "Waiting for additional warm-up time ";
|
||||
@for i in $$(seq 1 40); do \
|
||||
printf "."; \
|
||||
sleep 1; \
|
||||
done;
|
||||
@printf "\n";
|
||||
###
|
||||
### Ensure .env file exists
|
||||
###
|
||||
../.env:
|
||||
install -m 0644 ../env-example ../.env
|
||||
|
@ -1,4 +0,0 @@
|
||||
# Intranet tests
|
||||
|
||||
This directory includes scripts that run tests against the Devilbox intranet.
|
||||
Each file must be executable and end by `*.sh`.
|
@ -1,75 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
|
||||
NUM_OK="20"
|
||||
NUM_ERR="0"
|
||||
|
||||
|
||||
###
|
||||
### dvlbox-ok
|
||||
###
|
||||
|
||||
printf "[TEST] dvlbox-ok"
|
||||
# 1st Try
|
||||
TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )"
|
||||
if [ "${TEST_OK}" != "${NUM_OK}" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )"
|
||||
if [ "${TEST_OK}" != "${NUM_OK}" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )"
|
||||
if [ "${TEST_OK}" != "${NUM_OK}" ]; then
|
||||
printf "\r[FAIL] dvlbox-ok\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] dvlbox-ok (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] dvlbox-ok (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] dvlbox-ok (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### dvlbox-err
|
||||
###
|
||||
|
||||
printf "[TEST] dvlbox-err"
|
||||
# 1st Try
|
||||
TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )"
|
||||
if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )"
|
||||
if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )"
|
||||
if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then
|
||||
printf "\r[FAIL] dvlbox-err\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] dvlbox-err (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] dvlbox-err (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] dvlbox-err (1 round)\n"
|
||||
fi
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
|
||||
printf "[TEST] devilbox-version key in Memcached"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/db_memcd.php | tac | tac | grep -q 'devilbox-version'; then
|
||||
sleep 1
|
||||
if ! curl -sS localhost/db_memcd.php | tac | tac | grep -q 'devilbox-version'; then
|
||||
sleep 1
|
||||
if ! curl -sS localhost/db_memcd.php | tac | tac | grep -q 'devilbox-version'; then
|
||||
printf "\r[FAIL] devilbox-version key in Memcached\n"
|
||||
curl -sS localhost/db_memcd.php || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] devilbox-version key in Memcached (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] devilbox-version key in Memcached (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] devilbox-version key in Memcached (1 round)\n"
|
||||
fi
|
@ -1,128 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
DISABLED_VERSIONS=("7.4" "8.0")
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
###
|
||||
### Fetch PHP version
|
||||
###
|
||||
|
||||
|
||||
printf "[TEST] Get PHP version"
|
||||
# 1st Try
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
printf "\r[FAIL] Get PHP version\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Get PHP version (3 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (2 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (1 round): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure only to check against desired versions
|
||||
###
|
||||
### https://stackoverflow.com/a/15394738
|
||||
###
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_VERSION} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP ${PHP_VERSION}\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
###
|
||||
### Xdebug available
|
||||
###
|
||||
printf "[TEST] Xdebug available"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep -q 'xdebug\.remote_enable'; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep -q 'xdebug\.remote_enable'; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep -q 'xdebug\.remote_enable'; then
|
||||
printf "\r[FAIL] Xdebug available\n"
|
||||
curl -sS localhost/info_php.php | tac | tac | grep 'xdebug' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Xdebug available (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Xdebug available (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Xdebug available (1 round)\n"
|
||||
fi
|
||||
|
||||
###
|
||||
### Xdebug default disabled
|
||||
###
|
||||
printf "[TEST] Xdebug default disabled"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep 'xdebug\.remote_enable' | grep -Eq 'Off.+Off'; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep 'xdebug\.remote_enable' | grep -Eq 'Off.+Off'; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep 'xdebug\.remote_enable' | grep -Eq 'Off.+Off'; then
|
||||
printf "\r[FAIL] Xdebug default disabled\n"
|
||||
curl -sS localhost/info_php.php | tac | tac | grep 'xdebug' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Xdebug default disabled (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Xdebug default disabled (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Xdebug default disabled (1 round)\n"
|
||||
fi
|
||||
|
||||
###
|
||||
### Xdebug autostart disabled
|
||||
###
|
||||
printf "[TEST] Xdebug autostart disabled"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep 'xdebug\.remote_autostart' | grep -Eq 'Off.+Off'; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep 'xdebug\.remote_autostart' | grep -Eq 'Off.+Off'; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/info_php.php | tac | tac | grep 'xdebug\.remote_autostart' | grep -Eq 'Off.+Off'; then
|
||||
printf "\r[FAIL] Xdebug autostart disabled\n"
|
||||
curl -sS localhost/info_php.php | tac | tac | grep 'xdebug' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Xdebug autostart disabled (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Xdebug autostart disabled (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Xdebug autostart disabled (1 round)\n"
|
||||
fi
|
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
|
||||
printf "[TEST] devilbox-version key in Redis"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/db_redis.php | tac | tac | grep -q 'devilbox-version'; then
|
||||
sleep 1
|
||||
if ! curl -sS localhost/db_redis.php | tac | tac | grep -q 'devilbox-version'; then
|
||||
sleep 1
|
||||
if ! curl -sS localhost/db_redis.php | tac | tac | grep -q 'devilbox-version'; then
|
||||
printf "\r[FAIL] devilbox-version key in Redis\n"
|
||||
curl -sS localhost/db_redis.php || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] devilbox-version key in Redis (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] devilbox-version key in Redis (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] devilbox-version key in Redis (1 round)\n"
|
||||
fi
|
@ -1,190 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
DISABLED_VERSIONS_MONGO=("")
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
|
||||
###
|
||||
### Get current PHP version
|
||||
###
|
||||
|
||||
printf "[TEST] Get PHP version"
|
||||
# 1st Try
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
printf "\r[FAIL] Get PHP version\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Get PHP version (3 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (2 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (1 round): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
###
|
||||
### Retrieve URL for current Adminer version.
|
||||
###
|
||||
|
||||
printf "[TEST] Retrieve Adminer URL"
|
||||
# 1st Try
|
||||
if ! URL="$( curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! URL="$( curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! URL="$( curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then
|
||||
printf "\r[FAILED] Retrieve Adminer URL\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Retrieve Adminer URL (3 rounds): ${URL}\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Retrieve Adminer URL (2 rounds): ${URL}\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Retrieve Adminer URL (1 round): ${URL}\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure given Adminer version works
|
||||
###
|
||||
|
||||
printf "[TEST] Fetch ${URL}"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "Login.+Adminer"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "Login.+Adminer"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "Login.+Adminer"; then
|
||||
printf "\r[FAIL] Fetch ${URL}\n"
|
||||
curl -sS localhost${URL} || true
|
||||
curl -sSI localhost${URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Adminer MySQL login
|
||||
###
|
||||
|
||||
printf "[TEST] Adminer MySQL login"
|
||||
# 1st Try
|
||||
if ! curl -sS "localhost${URL}?server=mysql&username=root" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS "localhost${URL}?server=mysql&username=root" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS "localhost${URL}?server=mysql&username=root" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
printf "\r[FAIL] Adminer MySQL login\n"
|
||||
curl -sS "localhost${URL}?server=mysql&username=root" || true
|
||||
curl -sSI "localhost${URL}?server=mysql&username=root" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Adminer MySQL login (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Adminer MySQL login (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Adminer MySQL login (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Adminer PostgreSQL login
|
||||
###
|
||||
|
||||
printf "[TEST] Adminer PgSQL login"
|
||||
# 1st Try
|
||||
if ! curl -sS "localhost${URL}?pgsql=pgsql&username=postgres" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS "localhost${URL}?pgsql=pgsql&username=postgres" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS "localhost${URL}?pgsql=pgsql&username=postgres" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
printf "\r[FAIL] Adminer PgSQL login\n"
|
||||
curl -sS "localhost${URL}?pgsql=pgsql&username=postgres" || true
|
||||
curl -sSI "localhost${URL}?pgsql=pgsql&username=postgres" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Adminer PgSQL login (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Adminer PgSQL login (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Adminer PgSQL login (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure only to check against desired versions
|
||||
###
|
||||
|
||||
if [[ ${DISABLED_VERSIONS_MONGO[*]} =~ ${PHP_VERSION} ]]; then
|
||||
echo "Skipping Adminer Mongo login test for PHP ${PHP_VERSION}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Adminer MongoDB login
|
||||
###
|
||||
|
||||
printf "[TEST] Adminer Mongo login"
|
||||
# 1st Try
|
||||
if ! curl -sS "localhost${URL}?mongo=mongo&username=" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS "localhost${URL}?mongo=mongo&username=" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS "localhost${URL}?mongo=mongo&username=" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then
|
||||
printf "\r[FAIL] Adminer Mongo login\n"
|
||||
curl -sS "localhost${URL}?mongo=mongo&username=" || true
|
||||
curl -sSI "localhost${URL}?mongo=mongo&username=" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Adminer Mongo login (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Adminer Mongo login (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Adminer Mongo login (1 round)\n"
|
||||
fi
|
@ -1,111 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
DISABLED_VERSIONS=("5.2" "5.3" "5.4")
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
|
||||
###
|
||||
### Ensure PHPRedmin works
|
||||
###
|
||||
|
||||
URL="/vendor/phpredmin/public/index.php"
|
||||
|
||||
printf "[TEST] Fetch ${URL}"
|
||||
# 1st Try
|
||||
if [ "$(curl -sS localhost${URL} | tac | tac | grep -Ec "Strings|Hashes|Lists|Sets|Sorted Sets")" != "5" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS localhost${URL} | tac | tac | grep -Ec "Strings|Hashes|Lists|Sets|Sorted Sets")" != "5" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS localhost${URL} | tac | tac | grep -Ec "Strings|Hashes|Lists|Sets|Sorted Sets")" != "5" ]; then
|
||||
printf "\r[FAIL] Fetch ${URL}\n"
|
||||
curl -sS localhost/${URL} || true
|
||||
curl -sSI localhost/${URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Get current PHP version
|
||||
###
|
||||
|
||||
printf "[TEST] Get PHP version"
|
||||
# 1st Try
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
printf "\r[FAIL] Get PHP version\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Get PHP version (3 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (2 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (1 round): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure only to check against desired versions
|
||||
###
|
||||
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_VERSION} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP ${PHP_VERSION}\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure PHPRedmin works in subdirectory
|
||||
###
|
||||
|
||||
URL="/vendor/phpredmin/public/index.php/welcome/info/0/0"
|
||||
|
||||
printf "[TEST] Fetch ${URL}"
|
||||
# 1st Try
|
||||
if [ "$(curl -sS localhost${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)")" != "5" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS localhost${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)")" != "5" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS localhost${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)")" != "5" ]; then
|
||||
printf "\r[FAIL] Fetch ${URL}\n"
|
||||
curl -sS localhost/${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)" || true
|
||||
curl -sS localhost/${URL} || true
|
||||
curl -sSI localhost/${URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (1 round)\n"
|
||||
fi
|
@ -1,128 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
|
||||
VHOST="${1:-my-vhost}"
|
||||
|
||||
VHOST_GEN_URL="/info_vhostgen.php?name=${VHOST}"
|
||||
VHOST_URL="/vhost.d/${VHOST}.conf"
|
||||
|
||||
|
||||
###
|
||||
### vhost.d config
|
||||
###
|
||||
|
||||
printf "[TEST] vhost.d config link available for ${VHOST}"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep -q "${VHOST_URL}"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep -q "${VHOST_URL}"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep -q "${VHOST_URL}"; then
|
||||
printf "\r[FAIL] vhost.d config link available for ${VHOST}\n"
|
||||
curl -sS localhost/vhosts.php | tac | tac | grep -E "${VHOST}|vhostgen" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] vhost.d config link available for ${VHOST} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost.d config link available for ${VHOST} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost.d config link available for ${VHOST} (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### vhost-gen config
|
||||
###
|
||||
|
||||
printf "[TEST] vhost-gen config link available for ${VHOST}"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep "vhost-gen" | grep -q "${VHOST_GEN_URL}"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep "vhost-gen" | grep -q "${VHOST_GEN_URL}"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep "vhost-gen" | grep -q "${VHOST_GEN_URL}"; then
|
||||
printf "\r[FAIL] vhost-gen config link available for ${VHOST}\n"
|
||||
curl -sS localhost/vhosts.php | tac | tac | grep -E "${VHOST}|vhostgen|vhost-gen" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] vhost-gen config link available for ${VHOST} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost-gen config link available for ${VHOST} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost-gen config link available for ${VHOST} (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
###
|
||||
### vhost.d config
|
||||
###
|
||||
|
||||
printf "[TEST] vhost.d config available for ${VHOST}"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost${VHOST_URL} | tac | tac | grep -q "${VHOST}-access.log";then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${VHOST_URL} | tac | tac | grep -q "${VHOST}-access.log";then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${VHOST_URL} | tac | tac | grep -q "${VHOST}-access.log";then
|
||||
printf "\r[FAIL] vhost.d config available for ${VHOST}\n"
|
||||
curl -sS localhost${VHOST_URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] vhost.d config available for ${VHOST} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost.d config available for ${VHOST} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost.d config available for ${VHOST} (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
###
|
||||
### vhostgen config
|
||||
###
|
||||
|
||||
printf "[TEST] vhost-gen config available for ${VHOST}"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost${VHOST_GEN_URL} | tac | tac | grep -q "/shared/httpd/${VHOST}";then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${VHOST_GEN_URL} | tac | tac | grep -q "/shared/httpd/${VHOST}";then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${VHOST_GEN_URL} | tac | tac | grep -q "/shared/httpd/${VHOST}";then
|
||||
printf "\r[FAIL] vhost-gen config available for ${VHOST}\n"
|
||||
curl -sS localhost${VHOST_GEN_URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] vhost-gen config available for ${VHOST} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost-gen config available for ${VHOST} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] vhost-gen config available for ${VHOST} (1 round)\n"
|
||||
fi
|
||||
|
146
.tests/scripts/.lib.sh
Normal file
146
.tests/scripts/.lib.sh
Normal file
@ -0,0 +1,146 @@
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if ! command -v perl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'perl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Functions
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### X-platform In-file replace
|
||||
###
|
||||
replace() {
|
||||
local from="${1}"
|
||||
local to="${2}"
|
||||
local file="${3}"
|
||||
local sep="|"
|
||||
if [ "${#}" = "4" ]; then
|
||||
sep="${4}"
|
||||
fi
|
||||
|
||||
run "perl -pi -e 's${sep}${from}${sep}${to}${sep}g' ${file}"
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
### Run command
|
||||
###
|
||||
run() {
|
||||
local cmd="${1}"
|
||||
local workdir=
|
||||
local retries=1
|
||||
local verbose=1
|
||||
|
||||
# retry?
|
||||
if [ "${#}" -gt "1" ]; then
|
||||
retries="${2}"
|
||||
fi
|
||||
# change directory?
|
||||
if [ "${#}" -gt "2" ]; then
|
||||
workdir="${3}"
|
||||
fi
|
||||
|
||||
# be verbose?
|
||||
if [ "${#}" -gt "3" ]; then
|
||||
verbose="${4}"
|
||||
fi
|
||||
|
||||
local red="\033[0;31m"
|
||||
local green="\033[0;32m"
|
||||
local yellow="\033[0;33m"
|
||||
local reset="\033[0m"
|
||||
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${yellow}%s \$${reset} %s\n" "$(whoami)" "${cmd}"
|
||||
fi
|
||||
|
||||
for ((i=0; i<${retries}; i++)); do
|
||||
if [ -n "${workdir}" ]; then
|
||||
if bash -c "set -e && set -u && set -o pipefail && cd ${workdir} && ${cmd}"; then
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${green}[%s: in %s rounds]${reset}\n" "OK" "$((i+1))"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
if bash -c "set -e && set -u && set -o pipefail && ${cmd}"; then
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${green}[%s: in %s rounds]${reset}\n" "OK" "$((i+1))"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${red}[%s: in %s rounds]${reset}\n" "FAIL" "${retries}"
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
### Run fail command (succeeds on error and fails on success)
|
||||
###
|
||||
run_fail() {
|
||||
local cmd="${1}"
|
||||
local workdir=
|
||||
local retries=1
|
||||
local verbose=1
|
||||
|
||||
# retry?
|
||||
if [ "${#}" -gt "1" ]; then
|
||||
retries="${2}"
|
||||
fi
|
||||
# change directory?
|
||||
if [ "${#}" -gt "2" ]; then
|
||||
workdir="${3}"
|
||||
fi
|
||||
|
||||
# be verbose?
|
||||
if [ "${#}" -gt "3" ]; then
|
||||
verbose="${4}"
|
||||
fi
|
||||
|
||||
local red="\033[0;31m"
|
||||
local green="\033[0;32m"
|
||||
local yellow="\033[0;33m"
|
||||
local reset="\033[0m"
|
||||
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${yellow}%s \$${reset} %s\n" "$(whoami)" "${cmd}"
|
||||
fi
|
||||
|
||||
for ((i=0; i<${retries}; i++)); do
|
||||
if [ -n "${workdir}" ]; then
|
||||
if ! bash -c "set -e && set -u && set -o pipefail && cd ${workdir} && ${cmd}"; then
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${green}[%s: in %s rounds]${reset}\n" "OK" "$((i+1))"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
if ! bash -c "set -e && set -u && set -o pipefail && ${cmd}"; then
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${green}[%s: in %s rounds]${reset}\n" "OK" "$((i+1))"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [ "${verbose}" -eq "1" ]; then
|
||||
>&2 printf "${red}[%s: in %s rounds]${reset}\n" "FAIL" "${retries}"
|
||||
fi
|
||||
return 1
|
||||
}
|
27
.tests/scripts/compose-logs.sh
Executable file
27
.tests/scripts/compose-logs.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'docker-compose' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
run "docker-compose logs || true" "1" "${DVLBOX_PATH}"
|
27
.tests/scripts/compose-pull.sh
Executable file
27
.tests/scripts/compose-pull.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'docker' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
run "docker-compose pull" "60" "${DVLBOX_PATH}"
|
41
.tests/scripts/compose-reset.sh
Executable file
41
.tests/scripts/compose-reset.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'docker' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Clean Docker artifacts
|
||||
###
|
||||
|
||||
DIR_NAME="$( basename "${DVLBOX_PATH}" )"
|
||||
|
||||
# Remove networks
|
||||
if docker network ls | grep "${DIR_NAME}" >/dev/null; then
|
||||
run "docker network rm \"\$(docker network ls | grep '${DIR_NAME}' | awk '{print \$1}')\""
|
||||
fi
|
||||
|
||||
# Remove volumes
|
||||
if docker volume ls | grep "${DIR_NAME}" >/dev/null; then
|
||||
run "docker volume ls | grep '${DIR_NAME}' | awk '{print \$2}' | xargs docker volume rm"
|
||||
fi
|
154
.tests/scripts/compose-start.sh
Executable file
154
.tests/scripts/compose-start.sh
Executable file
@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'docker-compose' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
MYSQL_ROOT_PASSWORD="$( "${SCRIPT_PATH}/env-getvar.sh" "MYSQL_ROOT_PASSWORD" )"
|
||||
|
||||
|
||||
###
|
||||
### Startup
|
||||
###
|
||||
run "docker-compose up -d" "1" "${DVLBOX_PATH}"
|
||||
|
||||
|
||||
###
|
||||
### Test for HTTP 200
|
||||
###
|
||||
printf "Waiting for HTTP 200 "
|
||||
i=0
|
||||
until curl -sS -o /dev/null -I -w "%{http_code}" "http://localhost:${HOST_PORT_HTTPD}" 2>/dev/null | grep '200' >/dev/null; do
|
||||
printf "."
|
||||
|
||||
i=$(( i + 1 ))
|
||||
if [ "${i}" -eq "60" ]; then
|
||||
printf "[FAIL]\\n\\n"
|
||||
curl -o /dev/null -I -w "%{http_code}" "http://localhost:${HOST_PORT_HTTPD}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
printf "[OK]\\n"
|
||||
|
||||
|
||||
###
|
||||
### Test Intranet start page
|
||||
###
|
||||
printf "Waiting for Intranet to be ready "
|
||||
i=0
|
||||
until curl -sS --fail "http://localhost:${HOST_PORT_HTTPD}" 2>/dev/null | grep 'dvlbox-ok' >/dev/null; do
|
||||
printf "."
|
||||
|
||||
i=$(( i + 1 ))
|
||||
if [ "${i}" -eq "60" ]; then
|
||||
printf "[FAIL]\\n"
|
||||
curl "http://localhost:${HOST_PORT_HTTPD}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
printf "[OK]\\n"
|
||||
|
||||
|
||||
###
|
||||
### Wait for DB's to initialize
|
||||
###
|
||||
SEC=10
|
||||
printf "Waiting %s sec for DB's to init " "${SEC}"
|
||||
for i in $(seq 1 ${SEC}); do
|
||||
printf "."
|
||||
sleep 1
|
||||
done
|
||||
printf "[OK]\\n"
|
||||
|
||||
|
||||
###
|
||||
### Test MongoDB connection
|
||||
###
|
||||
printf "Waiting for MongoDB connection to be ready "
|
||||
i=0
|
||||
until cd "${DVLBOX_PATH}" && docker-compose exec -T php mongofiles --host=mongo list >/dev/null 2>&1; do
|
||||
printf "."
|
||||
|
||||
i=$(( i + 1 ))
|
||||
if [ "${i}" -eq "60" ]; then
|
||||
printf "[FAIL]\\n"
|
||||
cd "${DVLBOX_PATH}" && docker-compose exec -T php mongofiles --host=mongo list
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
printf "[OK]\\n"
|
||||
|
||||
|
||||
###
|
||||
### Test MySQL connection
|
||||
###
|
||||
printf "Waiting for MySQL connection to be ready ";
|
||||
i=0
|
||||
until cd "${DVLBOX_PATH}" && docker-compose exec -T php mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql -e 'show databases;' 2>&1 | grep mysql >/dev/null; do
|
||||
printf "."
|
||||
|
||||
i=$(( i + 1 ))
|
||||
if [ "${i}" -eq "60" ]; then
|
||||
printf "[FAIL]\\n"
|
||||
cd "${DVLBOX_PATH}" && docker-compose exec -T php mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql -e 'show databases;'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
printf "[OK]\\n"
|
||||
|
||||
|
||||
###
|
||||
### Test PgSQL connection
|
||||
###
|
||||
printf "Waiting for PostgreSQL connection to be ready ";
|
||||
i=0
|
||||
until cd "${DVLBOX_PATH}" && docker-compose exec -T php pg_isready --host=pgsql >/dev/null 2>&1; do
|
||||
printf "."
|
||||
|
||||
i=$(( i + 1 ))
|
||||
if [ "${i}" -eq "60" ]; then
|
||||
printf "[FAIL]\\n"
|
||||
cd "${DVLBOX_PATH}" && docker-compose exec -T php pg_isready --host=pgsql
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
printf "[OK]\\n"
|
47
.tests/scripts/compose-stop.sh
Executable file
47
.tests/scripts/compose-stop.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'docker-compose' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Clean Devilbox artifacts
|
||||
###
|
||||
|
||||
# Remove emails
|
||||
run "docker-compose exec php truncate -s0 /var/mail/devilbox || true" "1" "${DVLBOX_PATH}"
|
||||
|
||||
# Remove PHP logs
|
||||
run "docker-compose exec php sh -c \"find /var/log -name 'php-fpm*' -print0 | xargs -n1 -0 rm -f\" || true" "1" "${DVLBOX_PATH}"
|
||||
|
||||
# Remove HTTP logs
|
||||
run "docker-compose exec httpd sh -c \"find /var/log/ -name '*.log' -print0 | xargs -n1 -0 rm -f\" || true" "1" "${DVLBOX_PATH}"
|
||||
|
||||
|
||||
###
|
||||
### Stop and remove container
|
||||
###
|
||||
|
||||
run "docker-compose stop" "1" "${DVLBOX_PATH}"
|
||||
run "docker-compose kill" "1" "${DVLBOX_PATH}"
|
||||
run "docker-compose rm -f" "1" "${DVLBOX_PATH}"
|
59
.tests/scripts/env-getvar.sh
Executable file
59
.tests/scripts/env-getvar.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "${#}" -ne "1" ]; then
|
||||
>&2 echo "Error, requires one argument: <DIRECTIVE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v awk >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'awk' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# FUNCTIONS
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
env_get() {
|
||||
local env_path="${1}"
|
||||
local directive="${2}"
|
||||
|
||||
if [ ! -f "${env_path}" ]; then
|
||||
>&2 echo "Error, .env file does not exist in: ${env_path}"
|
||||
return 1
|
||||
fi
|
||||
if ! grep -Eq "^${directive}=" "${env_path}"; then
|
||||
>&2 echo "Error, directive does not exist in .env: ${directive}"
|
||||
return 1
|
||||
fi
|
||||
if [ "$( grep -Ec "^${directive}=" "${env_path}" )" -ne "1" ]; then
|
||||
>&2 echo "Error, directive exists multiple times in .env: ${directive}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
grep -E "^${directive}=.*\$" "${env_path}" \
|
||||
| awk -F'=' '{for (i=2; i<NF; i++) printf $i "="; print $NF}'
|
||||
}
|
||||
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
env_get "${DVLBOX_PATH}/.env" "${1}"
|
18
.tests/scripts/env-reset.sh
Executable file
18
.tests/scripts/env-reset.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
run "rm -f ${DVLBOX_PATH}/.env"
|
||||
run "cp ${DVLBOX_PATH}/env-example ${DVLBOX_PATH}/.env"
|
52
.tests/scripts/env-setvar.sh
Executable file
52
.tests/scripts/env-setvar.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/.lib.sh"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "${#}" -ne "2" ]; then
|
||||
>&2 echo "Error, requires two arguments: <DIRECTIVE> <VALUE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# FUNCTIONS
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
env_set() {
|
||||
local env_path="${1}"
|
||||
local directive="${2}"
|
||||
local value="${3}"
|
||||
|
||||
if [ ! -f "${env_path}" ]; then
|
||||
>&2 echo "Error, .env file does not exist in: ${env_path}"
|
||||
return 1
|
||||
fi
|
||||
if ! grep -Eq "^${directive}=" "${env_path}"; then
|
||||
>&2 echo "Error, directive does not exist in .env: ${directive}"
|
||||
return 1
|
||||
fi
|
||||
if [ "$( grep -Ec "^${directive}=" "${env_path}" )" -ne "1" ]; then
|
||||
>&2 echo "Error, directive exists multiple times in .env: ${directive}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
replace "^${directive}=.*\$" "${directive}=${value}" "${env_path}"
|
||||
}
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
env_set "${DVLBOX_PATH}/.env" "${1}" "${2}"
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
COMPOSEPATH="${SCRIPTPATH}/.."
|
||||
COMPOSEPATH="${SCRIPTPATH}/../.."
|
||||
PHP_TAG="$( grep 'devilbox/php' "${COMPOSEPATH}/docker-compose.yml" | sed 's/^.*-work-//g' )"
|
||||
|
||||
|
||||
@ -378,7 +378,7 @@ MODS="$( echo "${PHP52_MODS}, ${PHP53_MODS}, ${PHP54_MODS}, ${PHP55_MODS}, ${PHP
|
||||
###
|
||||
### Get disabled modules
|
||||
###
|
||||
DISABLED=",blackfire,ioncube,$( grep -E '^PHP_MODULES_DISABLE=' "${SCRIPTPATH}/../env-example" | sed 's/.*=//g' ),"
|
||||
DISABLED=",blackfire,ioncube,$( grep -E '^PHP_MODULES_DISABLE=' "${COMPOSEPATH}/env-example" | sed 's/.*=//g' ),"
|
||||
#echo $DISABLED
|
||||
B="✔" # Enabled base modules (cannot be disabled)
|
||||
E="🗸" # Enabled mods modules (can be disabled)
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
COMPOSEPATH="${SCRIPTPATH}/../../"
|
||||
CONTAINER="$( cd "${COMPOSEPATH}" && docker-compose ps -q php )"
|
||||
|
||||
#FILES="$()"
|
||||
cd "${COMPOSEPATH}" && docker-compose exec -T php bash -c "find /startup.1.d/*.sh-example -type f -print0 2>/dev/null" \
|
||||
| xargs -0 -n 1 echo \
|
||||
| while read f; do
|
||||
|
||||
echo "# ----------------------------------------------------------------------------------------"
|
||||
echo "# [TEST] ${f}"
|
||||
echo "# ----------------------------------------------------------------------------------------"
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
|
||||
echo "[FAIl] ${f}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "[OK] ${f}"
|
||||
echo
|
||||
echo
|
||||
done
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
COMPOSEPATH="${SCRIPTPATH}/../../"
|
||||
CONTAINER="$( cd "${COMPOSEPATH}" && docker-compose ps -q php )"
|
||||
|
||||
#FILES="$()"
|
||||
cd "${COMPOSEPATH}" && docker-compose exec -T php bash -c "find /startup.2.d/*.sh-example -type f -print0 2>/dev/null" \
|
||||
| xargs -0 -n 1 echo \
|
||||
| while read f; do
|
||||
|
||||
echo "# ----------------------------------------------------------------------------------------"
|
||||
echo "# [TEST] ${f}"
|
||||
echo "# ----------------------------------------------------------------------------------------"
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}"; then
|
||||
sleep 5
|
||||
if ! docker exec -t ${CONTAINER} bash "${f}"; then
|
||||
echo "[FAIl] ${f}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "[OK] ${f}"
|
||||
echo
|
||||
echo
|
||||
done
|
71
.tests/tests/autostart-examples.sh
Executable file
71
.tests/tests/autostart-examples.sh
Executable file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Autostart]"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
###
|
||||
### Get autostart files
|
||||
###
|
||||
FILES="$( run "docker-compose exec -T --user devilbox php bash -c 'find /startup.1.d/ -name \"*.sh-example\"'" "${RETRIES}" "${DVLBOX_PATH}" "0" )"
|
||||
|
||||
echo
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo "# [Autostart] Test PHP specific startup scripts: /startup.1.d/"
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
for file in ${FILES}; do
|
||||
run "docker-compose exec -T php bash ${file} 'ACCEPT_EULA=1'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
done
|
||||
|
||||
|
||||
###
|
||||
### Get autostart files
|
||||
###
|
||||
FILES="$( run "docker-compose exec -T --user devilbox php bash -c 'find /startup.2.d/ -name \"*.sh-example\"'" "${RETRIES}" "${DVLBOX_PATH}" "0" )"
|
||||
|
||||
echo
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo "# [Autostart] Test global startup scripts: /startup.2.d/"
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
for file in ${FILES}; do
|
||||
run "docker-compose exec -T php bash ${file}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
done
|
83
.tests/tests/config-xdebug.sh
Executable file
83
.tests/tests/config-xdebug.sh
Executable file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=("8.0")
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Config] Xdebug"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
|
||||
###
|
||||
### Xdebug available
|
||||
###
|
||||
printf "[TEST] Xdebug available"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/info_php.php' | tac | tac | grep -q 'xdebug.remote_enable'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Xdebug available\\n"
|
||||
curl "http://localhost:${HOST_PORT_HTTPD}/info_php.php" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Xdebug available\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Xdebug default disabled
|
||||
###
|
||||
printf "[TEST] Xdebug default disabled"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/info_php.php' | tac | tac | grep 'xdebug.remote_enable' | grep -Eq 'Off.+Off'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Xdebug default disabled\\n"
|
||||
curl "http://localhost:${HOST_PORT_HTTPD}/info_php.php | grep 'xdebug.remote_enable'" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Xdebug default disabled\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Xdebug autostart disabled
|
||||
###
|
||||
printf "[TEST] Xdebug autostart disabled"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/info_php.php' | tac | tac | grep 'xdebug.remote_autostart' | grep -Eq 'Off.+Off'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Xdebug autostart disabled\\n"
|
||||
curl "http://localhost:${HOST_PORT_HTTPD}/info_php.php | grep 'xdebug.remote_autostart'" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Xdebug autostart disabled\\n"
|
||||
fi
|
117
.tests/tests/curl-vhosts.sh
Executable file
117
.tests/tests/curl-vhosts.sh
Executable file
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [curl] ${1:-}"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v sort >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'sort' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${#}" -ne "1" ]; then
|
||||
>&2 echo "Error, requires one argument: <TEST_DIR>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VHOST="${1}"
|
||||
TESTS="${SCRIPT_PATH}/../www/${VHOST}/htdocs"
|
||||
if [ ! -d "${TESTS}" ]; then
|
||||
>&2 echo "Error, test dir does not exist: ${TESTS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
|
||||
###
|
||||
### Get vhost files
|
||||
###
|
||||
FILES="$( find "${TESTS}" -name '*.php' | sort )"
|
||||
|
||||
|
||||
echo
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo "# [${1}] Test from host (http)"
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
for file in ${FILES}; do
|
||||
name="$( basename "${file}" )"
|
||||
|
||||
if ! run "curl -sS --fail --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}' | tac | tac | grep -E '^OK$' >/dev/null" "${RETRIES}"; then
|
||||
run "curl --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}'"
|
||||
exit 1
|
||||
fi
|
||||
if ! run_fail "curl -sS --fail --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}' 2>&1 | tac | tac | grep -Ei 'fatal|except|err|warn|notice' >/dev/null" "${RETRIES}"; then
|
||||
run "curl --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}'"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
echo
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo "# [${1}] Test from container (http)"
|
||||
echo "#--------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
for file in ${FILES}; do
|
||||
name="$( basename "${file}" )"
|
||||
|
||||
if ! run "docker-compose exec -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}' | tac | tac | grep -E '^OK$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
run "docker-compose exec -T php curl 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}'" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
if ! run_fail "docker-compose exec -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}' 2>&1 | tac | tac | grep -Ei 'fatal|except|err|war|notice' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
run "docker-compose exec -T php curl 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}'" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
83
.tests/tests/framework-cakephp.sh
Executable file
83
.tests/tests/framework-cakephp.sh
Executable file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=("5.2" "5.3" "5.4" "5.5" "8.0")
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Framework] CakePHP 3.8.0"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
MYSQL_ROOT_PASSWORD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "MYSQL_ROOT_PASSWORD" )"
|
||||
|
||||
|
||||
# Setup CakePHP project
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'mkdir -p /shared/httpd/cakephp'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'cd /shared/httpd/cakephp; rm -rf cakephp; composer create-project --no-interaction --prefer-dist cakephp/app cakephp 3.8'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'cd /shared/httpd/cakephp; ln -sf cakephp/webroot htdocs'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php mysql -u root -h mysql --password=\"${MYSQL_ROOT_PASSWORD}\" -e \"DROP DATABASE IF EXISTS my_cake; CREATE DATABASE my_cake;\"" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
# Configure CakePHP database settings
|
||||
run "docker-compose exec --user devilbox -T php sed -i\"\" \"s/'host' =>.*/'host' => 'mysql',/g\" /shared/httpd/cakephp/cakephp/config/app.php" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php sed -i\"\" \"s/'username' =>.*/'username' => 'root',/g\" /shared/httpd/cakephp/cakephp/config/app.php" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php sed -i\"\" \"s/'password' =>.*/'password' => '${MYSQL_ROOT_PASSWORD}',/g\" /shared/httpd/cakephp/cakephp/config/app.php" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php sed -i\"\" \"s/'database' =>.*/'database' => 'my_cake',/g\" /shared/httpd/cakephp/cakephp/config/app.php" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
# Test CakePHP
|
||||
ERROR=0
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://cakephp.loc | tac | tac | grep '\"bullet success\"' | grep 'mbstring'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
ERROR=1
|
||||
fi
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://cakephp.loc | tac | tac | grep '\"bullet success\"' | grep 'openssl'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
ERROR=1
|
||||
fi
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://cakephp.loc | tac | tac | grep '\"bullet success\"' | grep 'intl'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
ERROR=1
|
||||
fi
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://cakephp.loc | tac | tac | grep '\"bullet success\"' | grep 'tmp directory'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
ERROR=1
|
||||
fi
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://cakephp.loc | tac | tac | grep '\"bullet success\"' | grep 'logs directory'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
ERROR=1
|
||||
fi
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://cakephp.loc | tac | tac | grep '\"bullet success\"' | grep 'connect to the database'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
ERROR=1
|
||||
fi
|
||||
|
||||
if [ "${ERROR}" = "1" ]; then
|
||||
run "docker-compose exec --user devilbox -T php curl http://cakephp.loc || true"
|
||||
exit 1
|
||||
fi
|
77
.tests/tests/framework-drupal.sh
Executable file
77
.tests/tests/framework-drupal.sh
Executable file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=("5.2" "5.3" "7.4" "8.0")
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Framework] Drupal 7.x-dev"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DRUSH=
|
||||
if run "docker-compose exec --user devilbox -T php bash -c 'command -v drush'" "1" "${DVLBOX_PATH}"; then
|
||||
DRUSH=drush
|
||||
elif run "docker-compose exec --user devilbox -T php bash -c 'command -v drush10'" "1" "${DVLBOX_PATH}"; then
|
||||
DRUSH=drush10
|
||||
elif run "docker-compose exec --user devilbox -T php bash -c 'command -v drush9'" "1" "${DVLBOX_PATH}"; then
|
||||
DRUSH=drush9
|
||||
elif run "docker-compose exec --user devilbox -T php bash -c 'command -v drush8'" "1" "${DVLBOX_PATH}"; then
|
||||
DRUSH=drush8
|
||||
elif run "docker-compose exec --user devilbox -T php bash -c 'command -v drush7'" "1" "${DVLBOX_PATH}"; then
|
||||
DRUSH=drush7
|
||||
fi
|
||||
if [ -z "${DRUSH}" ]; then
|
||||
>&2 echo "Error, no drush command found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
MYSQL_ROOT_PASSWORD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "MYSQL_ROOT_PASSWORD" )"
|
||||
|
||||
|
||||
# Setup Drupal project
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'mkdir -p /shared/httpd/drupal'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'cd /shared/httpd/drupal; sudo rm -rf drupal; composer create-project --no-interaction --prefer-dist drupal-composer/drupal-project drupal 7.x-dev'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'cd /shared/httpd/drupal; ln -sf drupal/web htdocs'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php mysql -u root -h mysql --password=\"${MYSQL_ROOT_PASSWORD}\" -e \"DROP DATABASE IF EXISTS my_drupal; CREATE DATABASE my_drupal;\"" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
# Configure Drupal
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'cd /shared/httpd/drupal/htdocs/; ${DRUSH} site-install standard --db-url='mysql://root:${MYSQL_ROOT_PASSWORD}@mysql/my_drupal' --site-name=Example -y'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
# Test Drupal
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail http://drupal.loc | tac | tac | grep 'Welcome to Example'" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
run "docker-compose exec --user devilbox -T php curl http://drupal.loc || true"
|
||||
exit 1
|
||||
fi
|
74
.tests/tests/intranet-email.sh
Executable file
74
.tests/tests/intranet-email.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Intranet] Email"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
|
||||
|
||||
###
|
||||
### Email variables
|
||||
###
|
||||
MY_MAIL="ci@devilbox.org"
|
||||
MY_SUBJ="testing-ci-subject"
|
||||
MY_MESS="testing-ci-message"
|
||||
|
||||
|
||||
# Empty mails first
|
||||
run "docker-compose exec --user devilbox -T php bash -c '> /var/mail/devilbox'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
# Send a new mail
|
||||
run "curl -sS --fail -XPOST 'http://localhost:${HOST_PORT_HTTPD}/mail.php?email=${MY_MAIL}&subject=${MY_SUBJ}&message=${MY_MESS}'" "${RETRIES}"
|
||||
|
||||
# Validate
|
||||
run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/mail.php' | tac | tac | grep '${MY_MAIL}' >/dev/null" "${RETRIES}"
|
||||
run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/mail.php' | tac | tac | grep '${MY_SUBJ}' >/dev/null" "${RETRIES}"
|
||||
run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/mail.php' | tac | tac | grep '${MY_MESS}' >/dev/null" "${RETRIES}"
|
81
.tests/tests/intranet-homepage.sh
Executable file
81
.tests/tests/intranet-homepage.sh
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Intranet] Homepage"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
|
||||
|
||||
###
|
||||
### dvlbox-ok
|
||||
###
|
||||
NUM_OK="20"
|
||||
printf "[TEST] dvlbox-ok"
|
||||
if ! run "test \"\$(curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/index.php' | tac | tac | grep -c 'dvlbox-ok' || true)\" = \"${NUM_OK}\"" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] dvlbox-ok\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/index.php' | tac | tac | grep -c 'dvlbox-ok' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] dvlbox-ok\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### dvlbox-err
|
||||
###
|
||||
printf "[TEST] dvlbox-err"
|
||||
if ! run "test \"\$(curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/index.php' | tac | tac | grep -c 'dvlbox-err' || true)\" = \"0\"" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] dvlbox-err\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/index.php' | tac | tac | grep -c 'dvlbox-err' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] dvlbox-err\\n"
|
||||
fi
|
63
.tests/tests/intranet-memcached.sh
Executable file
63
.tests/tests/intranet-memcached.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Intranet] Memcached"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
|
||||
printf "[TEST] devilbox-version key in Memcached"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/db_memcd.php' | tac | tac | grep -q 'devilbox-version'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] devilbox-version key in Memcached\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/db_memcd.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] devilbox-version key in Memcached\\n"
|
||||
fi
|
63
.tests/tests/intranet-redis.sh
Executable file
63
.tests/tests/intranet-redis.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Intranet] Redis"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
|
||||
printf "[TEST] devilbox-version key in Redis"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/db_redis.php' | tac | tac | grep -q 'devilbox-version'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] devilbox-version key in Redis\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/db_redis.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] devilbox-version key in Redis\\n"
|
||||
fi
|
215
.tests/tests/intranet-vhost.sh
Executable file
215
.tests/tests/intranet-vhost.sh
Executable file
@ -0,0 +1,215 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Intranet] vhost"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
HTTPD_DOCROOT_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_DOCROOT_DIR" )"
|
||||
HTTPD_TEMPLATE_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_TEMPLATE_DIR" )"
|
||||
|
||||
|
||||
###
|
||||
### The vhost name
|
||||
###
|
||||
VHOST=test-intranet-vhost
|
||||
|
||||
|
||||
###
|
||||
### Create vhost directory
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Vhost is available
|
||||
###
|
||||
printf "[TEST] vhost appears on intranet"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' | tac | tac | grep '${VHOST}' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost appears on intranet\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost appears on intranet\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost shows htdocs/ dir error
|
||||
###
|
||||
printf "[TEST] vhost shows htdocs dir error if dir is missing"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/_ajax_callback.php?vhost=${VHOST}' | tac | tac | grep 'error' | grep '${VHOST}' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost shows htdocs dir error if dir is missing\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/_ajax_callback.php?vhost=${VHOST}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost shows htdocs dir error if dir is missing\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost shows success with htdocs/ dir created
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
printf "[TEST] vhost shows no htdocs dir error if dir is present"
|
||||
if run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/_ajax_callback.php?vhost=${VHOST}' | tac | tac | grep -E 'error|${VHOST}' >/dev/null" "1" "" "0"; then
|
||||
printf "\\r[FAIL] vhost shows no htdocs dir error if dir is present\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/_ajax_callback.php?vhost=${VHOST}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost shows no htdocs dir error if dir is present\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost shows success for DNS
|
||||
###
|
||||
printf "[TEST] vhost shows DNS record success"
|
||||
if ! run "curl -sS --fail --header 'host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/devilbox-api/status.json' | tac | tac | grep 'success' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost shows DNS record success\\n"
|
||||
run "curl --header 'host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/_ajax_callback.php?vhost=${VHOST}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost shows DNS record success\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost config link is available
|
||||
###
|
||||
printf "[TEST] vhost.d config link is available"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' | tac | tac | grep 'vhost.d/${VHOST}.conf' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost.d config link is available\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost.d config link is available\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost vhost.d config is available
|
||||
###
|
||||
printf "[TEST] vhost.d config is available"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhost.d/${VHOST}.conf' | tac | tac | grep '${VHOST}-access.log' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost.d config is available\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/vhost.d/${VHOST}.conf' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost.d config is available\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### vhost-gen config link should appear
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/${HTTPD_TEMPLATE_DIR}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache22.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache22.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache24.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache24.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/nginx.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/nginx.yml" "${RETRIES}"
|
||||
|
||||
printf "[TEST] vhost-gen config link is available"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' | tac | tac | grep 'info_vhostgen.php?name=${VHOST}' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost-gen config link is available\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost-gen config link is available\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### vhost-gen config should be available
|
||||
###
|
||||
printf "[TEST] vhost-gen config is available"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/info_vhostgen.php?name=${VHOST}' | tac | tac | grep '__VHOST_NAME__' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost-gen config is available\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/info_vhostgen.php?name=${VHOST}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost-gen config is available\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### vhost-gen config changes are shown in intranet
|
||||
###
|
||||
replace "__INDEX__" "__MY_GREP_VALUE__" "${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache22.yml"
|
||||
replace "__INDEX__" "__MY_GREP_VALUE__" "${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache24.yml"
|
||||
replace "__INDEX__" "__MY_GREP_VALUE__" "${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/nginx.yml"
|
||||
|
||||
printf "[TEST] vhost-gen config changes are shown"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/info_vhostgen.php?name=${VHOST}' | tac | tac | grep '__MY_GREP_VALUE__' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost-gen config changes are shown\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/info_vhostgen.php?name=${VHOST}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost-gen config changes are shown\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost disappears after removing its dir
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
printf "[TEST] vhost disappears after removing its dir"
|
||||
if ! run "test \"\$(curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' | tac | tac | grep -c '${VHOST}')\" = \"0\"" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] vhost disappears after removing its dir\\n"
|
||||
run "curl 'http://localhost:${HOST_PORT_HTTPD}/vhosts.php' | tac | tac | grep '${VHOST}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] vhost disappears after removing its dir\\n"
|
||||
fi
|
78
.tests/tests/php-vhosts.sh
Executable file
78
.tests/tests/php-vhosts.sh
Executable file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [PHP cli] ${1:-}"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${#}" -ne "1" ]; then
|
||||
>&2 echo "Error, requires one argument: <TEST_DIR>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VHOST="${1}"
|
||||
TESTS="${SCRIPT_PATH}/../www/${VHOST}/htdocs"
|
||||
if [ ! -d "${TESTS}" ]; then
|
||||
>&2 echo "Error, test dir does not exist: ${TESTS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get vhost files
|
||||
###
|
||||
FILES="$( find "${TESTS}" -name '*.php' )"
|
||||
|
||||
for file in ${FILES}; do
|
||||
name="$( basename "${file}" )"
|
||||
if ! run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} | grep -E '^OK$' > /dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
if ! run_fail "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} 2>&1 | grep -Ei 'fatal|except|err|warn|notice' > /dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
|
||||
run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
112
.tests/tests/rproxy-javascript.sh
Executable file
112
.tests/tests/rproxy-javascript.sh
Executable file
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [rproxy] Javascript"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
HTTPD_TEMPLATE_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_TEMPLATE_DIR" )"
|
||||
|
||||
|
||||
###
|
||||
### Bundled vhost-gen rproxy files have this as their default port
|
||||
###
|
||||
VHOSTGEN_TPL_DEFAULT_PORT=8000
|
||||
|
||||
|
||||
###
|
||||
### Application specific settings
|
||||
###
|
||||
RPROXY_NAME="rproxy"
|
||||
RPROXY_PORT=8000
|
||||
OUTPUT="OK-RPROXY-JAVASCRIPT"
|
||||
|
||||
|
||||
###
|
||||
### Create vhost-gen config directory
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
|
||||
###
|
||||
### Apply default vhost-gen reverse proxy configurations
|
||||
###
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache22.yml-example-rproxy ${SCRIPT_PATH}/../www/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}/apache22.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache24.yml-example-rproxy ${SCRIPT_PATH}/../www/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}/apache24.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/nginx.yml-example-rproxy ${SCRIPT_PATH}/../www/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}/nginx.yml" "${RETRIES}"
|
||||
|
||||
|
||||
###
|
||||
### Apply custom configuration to reverse proxy files
|
||||
###
|
||||
replace ":${VHOSTGEN_TPL_DEFAULT_PORT}" ":${RPROXY_PORT}" "${SCRIPT_PATH}/../www/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}/apache22.yml"
|
||||
replace ":${VHOSTGEN_TPL_DEFAULT_PORT}" ":${RPROXY_PORT}" "${SCRIPT_PATH}/../www/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}/apache24.yml"
|
||||
replace ":${VHOSTGEN_TPL_DEFAULT_PORT}" ":${RPROXY_PORT}" "${SCRIPT_PATH}/../www/${RPROXY_NAME}/${HTTPD_TEMPLATE_DIR}/nginx.yml"
|
||||
|
||||
|
||||
###
|
||||
### Ensure webserver reloads configuration
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mv /shared/httpd/${RPROXY_NAME} /shared/httpd/${RPROXY_NAME}.tmp" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mv /shared/httpd/${RPROXY_NAME}.tmp /shared/httpd/${RPROXY_NAME}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Start rproxy application
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'cd /shared/httpd/${RPROXY_NAME}/js && pm2 start index.js'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
|
||||
###
|
||||
### Test rhost
|
||||
###
|
||||
printf "[TEST] rproxy javascript"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${RPROXY_NAME}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}' | tac | tac | grep -E '^${OUTPUT}$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] rproxy javascript\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl -v 'http://${RPROXY_NAME}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}' || true' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] rproxy javascript\\n"
|
||||
fi
|
109
.tests/tests/ssl-intranet.sh
Executable file
109
.tests/tests/ssl-intranet.sh
Executable file
@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [SSL] Intranet"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
HOST_PORT_HTTPD_SSL="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD_SSL" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
HTTPD_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_SERVER" )"
|
||||
|
||||
|
||||
###
|
||||
### Intranet / from host
|
||||
###
|
||||
printf "[TEST] https Intranet / from host"
|
||||
if ! run "curl -sS --fail --cacert ${DVLBOX_PATH}/ca/devilbox-ca.crt 'https://localhost:${HOST_PORT_HTTPD_SSL}' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] https Intranet / from host\\n"
|
||||
run "curl -v --cacert ${DVLBOX_PATH}/ca/devilbox-ca.crt 'https://localhost:${HOST_PORT_HTTPD_SSL}' || true" "1"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] https Intranet / from host\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Intranet / from container
|
||||
###
|
||||
printf "[TEST] https Intranet / from container"
|
||||
if ! run "docker-compose exec -T php curl -sS --fail 'https://httpd' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] https Intranet / from container\\n"
|
||||
run "docker-compose exec -T php curl -v 'https://httpd' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] https Intranet / from container\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Intranet /credits.php from host
|
||||
###
|
||||
printf "[TEST] https Intranet /credits.php from host"
|
||||
if ! run "curl -sS --fail --cacert ${DVLBOX_PATH}/ca/devilbox-ca.crt 'https://localhost:${HOST_PORT_HTTPD_SSL}/credits.php' | tac | tac | grep -E 'https:\\/\\/github\\.com\\/cytopia' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] https Intranet /credits.php from host\\n"
|
||||
run "curl -v --cacert ${DVLBOX_PATH}/ca/devilbox-ca.crt 'https://localhost:${HOST_PORT_HTTPD_SSL}/credits.php' || true" "1"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] https Intranet /credits.php from host\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Intranet /credits.php from container
|
||||
###
|
||||
printf "[TEST] https Intranet /credits.php from container"
|
||||
if ! run "docker-compose exec -T php curl -sS --fail 'https://httpd/credits.php' | tac | tac | grep -E 'https:\\/\\/github\\.com\\/cytopia' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] https Intranet /credits.php from container\\n"
|
||||
run "docker-compose exec -T php curl -v 'https://httpd/credits.php' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] https Intranet /credits.php from container\\n"
|
||||
fi
|
98
.tests/tests/ssl-vhost.sh
Executable file
98
.tests/tests/ssl-vhost.sh
Executable file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [SSL] vhost"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HTTPD_DOCROOT_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_DOCROOT_DIR" )"
|
||||
HOST_PORT_HTTPD_SSL="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD_SSL" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
|
||||
|
||||
###
|
||||
### The vhost name
|
||||
###
|
||||
VHOST=test-ssl-vhost
|
||||
|
||||
|
||||
###
|
||||
### Create vhost directory
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/htdocs" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"<?php echo \\\"indexphp\\\";\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.php'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Vhost / from host
|
||||
###
|
||||
printf "[TEST] https vhost / from host"
|
||||
if ! run "curl -sS --fail --resolve ${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD_SSL}:127.0.0.1 --cacert ${DVLBOX_PATH}/ca/devilbox-ca.crt 'https://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD_SSL}' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] https vhost / from host\\n"
|
||||
run "curl -v --resolve ${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD_SSL}:127.0.0.1 --cacert ${DVLBOX_PATH}/ca/devilbox-ca.crt 'https://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD_SSL}' || true" "1"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] https vhost / from host\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Vhost / from container
|
||||
###
|
||||
printf "[TEST] https vhost / from container"
|
||||
if ! run "docker-compose exec -T php curl -sS --fail 'https://${VHOST}.${TLD_SUFFIX}' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] https vhost / from container\\n"
|
||||
run "docker-compose exec -T php curl -sv 'https://${VHOST}.${TLD_SUFFIX}' || true" "1" "${DVLBOX_PATH}" "0"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] https vhost / from container\\n"
|
||||
fi
|
156
.tests/tests/vendor-adminer.sh
Executable file
156
.tests/tests/vendor-adminer.sh
Executable file
@ -0,0 +1,156 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS_MONGO=("")
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Vendor] Adminer"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
|
||||
|
||||
###
|
||||
### Get current PHP version
|
||||
###
|
||||
printf "[TEST] Retrieve PHP version"
|
||||
if ! PHP_VERSION="$( run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/index.php' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Eo 'PHP.*?\\([.0-9]+' \
|
||||
| grep -Eo '\\([.0-9]+' \
|
||||
| grep -Eo '[0-9]+\\.[0-9]+'" \
|
||||
"${RETRIES}" "" "0" )"; then
|
||||
printf "\\r[FAILED] Retrieve PHP version\\n"
|
||||
run "curl -v 'http://localhost:${HOST_PORT_HTTPD}/index.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Retrieve PHP version: %s\\n" "${PHP_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Retrieve URL for current Adminer version.
|
||||
###
|
||||
printf "[TEST] Retrieve Adminer URL"
|
||||
if ! URL="$( run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/index.php' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Eo '/vendor/adminer-[.0-9]+-en\\.php'" \
|
||||
"${RETRIES}" "" "0" )"; then
|
||||
printf "\\r[FAILED] Retrieve Adminer URL\\n"
|
||||
run "curl -v 'http://localhost:${HOST_PORT_HTTPD}/index.php' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Retrieve Adminer URL: %s\\n" "${URL}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure given Adminer version works
|
||||
###
|
||||
printf "[TEST] Fetch %s" "${URL}"
|
||||
if ! run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Ei 'Login.+Adminer' >/dev/null" \
|
||||
"${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAILED] Fetch %s\\n" "${URL}"
|
||||
run "curl -v 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Fetch %s\\n" "${URL}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Adminer MySQL login
|
||||
###
|
||||
# TODO: password
|
||||
printf "[TEST] Adminer MySQL login"
|
||||
if ! run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}?server=mysql&username=root' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Ei 'Database.+Collation.+Tables' >/dev/null" \
|
||||
"${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Adminer MySQL login\\n"
|
||||
run "curl -v 'http://localhost:${HOST_PORT_HTTPD}${URL}?server=mysql&username=root' || true"
|
||||
run "curl -vI 'http://localhost:${HOST_PORT_HTTPD}${URL}?server=mysql&username=root' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Adminer MySQL login\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Adminer PostgreSQL login
|
||||
###
|
||||
printf "[TEST] Adminer PgSQL login"
|
||||
if ! run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}?pgsql=pgsql&username=postgres' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Ei 'Database.+Collation.+Tables' >/dev/null" \
|
||||
"${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Adminer PgSQL login\\n"
|
||||
run "curl -v 'http://localhost:${HOST_PORT_HTTPD}${URL}?pgsql=pgsql&username=postgres' || true"
|
||||
run "curl -vI 'http://localhost:${HOST_PORT_HTTPD}${URL}?pgsql=pgsql&username=postgres' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Adminer PgSQL login\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure only to check against desired versions
|
||||
###
|
||||
if [[ ${DISABLED_VERSIONS_MONGO[*]} =~ ${PHP_VERSION} ]]; then
|
||||
echo "Skipping Adminer Mongo login test for PHP ${PHP_VERSION}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Test Adminer MongoDB login
|
||||
###
|
||||
printf "[TEST] Adminer Mongo login"
|
||||
if ! run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}?mongo=mongo&username=' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Ei 'Database.+Collation.+Tables' >/dev/null" \
|
||||
"${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Adminer Mongo login\\n"
|
||||
run "curl -v 'http://localhost:${HOST_PORT_HTTPD}${URL}?mongo=mongo&username=' || true"
|
||||
run "curl -vI 'http://localhost:${HOST_PORT_HTTPD}${URL}?mongo=mongo&username=' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Adminer Mongo login\\n"
|
||||
fi
|
@ -1,17 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=("")
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Vendor] phpMyAdmin"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get current PHP version
|
||||
@ -19,15 +33,15 @@ DISABLED_VERSIONS=("")
|
||||
|
||||
printf "[TEST] Get PHP version"
|
||||
# 1st Try
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
printf "\r[FAIL] Get PHP version\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
curl localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Get PHP version (3 rounds): %s\n" "${PHP_VERSION}"
|
||||
@ -57,15 +71,15 @@ fi
|
||||
|
||||
printf "[TEST] Retrieve phpMyAdmin URL"
|
||||
# 1st Try
|
||||
if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" )"; then
|
||||
if ! URL="$( curl -sS --fail localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" )"; then
|
||||
if ! URL="$( curl -sS --fail localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" )"; then
|
||||
if ! URL="$( curl -sS --fail localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" )"; then
|
||||
printf "\r[FAILED] Retrieve phpMyAdmin URL\n"
|
||||
curl -sS localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" || true
|
||||
curl localhost/index.php | grep -Eo "/vendor/phpmyadmin-[.0-9]+/index\.php" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Retrieve phpMyAdmin URL (3 rounds): ${URL}\n"
|
||||
@ -277,16 +291,16 @@ fi
|
||||
|
||||
printf "[TEST] Evaluate successful phpMyAdmin login"
|
||||
# 1st Try
|
||||
if [ "$( curl -sS -c cookie.txt -b cookie.txt localhost${URL} | tac | tac | grep -Ec "(Databases<.+SQL<.+Status<.+Users<.+Export<)|(\"User accounts\")" )" != "1" ]; then
|
||||
if [ "$( curl -sS --fail -c cookie.txt -b cookie.txt localhost${URL} | tac | tac | grep -Ec "(Databases<.+SQL<.+Status<.+Users<.+Export<)|(\"User accounts\")" )" != "1" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$( curl -sS -c cookie.txt -b cookie.txt localhost${URL} | tac | tac | grep -Ec "(Databases<.+SQL<.+Status<.+Users<.+Export<|(\"User accounts\")" )" != "1" ]; then
|
||||
if [ "$( curl -sS --fail -c cookie.txt -b cookie.txt localhost${URL} | tac | tac | grep -Ec "(Databases<.+SQL<.+Status<.+Users<.+Export<|(\"User accounts\")" )" != "1" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$( curl -sS -c cookie.txt -b cookie.txt localhost${URL} | tac | tac | grep -Ec "(Databases<.+SQL<.+Status<.+Users<.+Export<|(\"User accounts\")" )" != "1" ]; then
|
||||
if [ "$( curl -sS --fail -c cookie.txt -b cookie.txt localhost${URL} | tac | tac | grep -Ec "(Databases<.+SQL<.+Status<.+Users<.+Export<|(\"User accounts\")" )" != "1" ]; then
|
||||
printf "\r[FAIL] Evaluate successful phpMyAdmin login\n"
|
||||
curl -sS -c cookie.txt -b cookie.txt localhost/${URL} || true
|
||||
curl -sSI -c cookie.txt -b cookie.txt localhost/${URL} || true
|
||||
curl -c cookie.txt -b cookie.txt localhost/${URL} || true
|
||||
curl -I -c cookie.txt -b cookie.txt localhost/${URL} || true
|
||||
rm -f cookie.txt || true
|
||||
exit 1
|
||||
else
|
@ -1,17 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=("8.0")
|
||||
|
||||
#
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
#
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Vendor] phpPgAdmin"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get current PHP version
|
||||
@ -19,15 +33,15 @@ DISABLED_VERSIONS=("8.0")
|
||||
|
||||
printf "[TEST] Get PHP version"
|
||||
# 1st Try
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
printf "\r[FAIL] Get PHP version\n"
|
||||
curl -sS localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
curl localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Get PHP version (3 rounds): %s\n" "${PHP_VERSION}"
|
||||
@ -57,15 +71,15 @@ fi
|
||||
|
||||
printf "[TEST] Retrieve phpPgAdmin URL"
|
||||
# 1st Try
|
||||
if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" )"; then
|
||||
if ! URL="$( curl -sS --fail localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" )"; then
|
||||
if ! URL="$( curl -sS --fail localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" )"; then
|
||||
if ! URL="$( curl -sS --fail localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" )"; then
|
||||
printf "\r[FAILED] Retrieve phpMyAdmin URL\n"
|
||||
curl -sS localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" || true
|
||||
curl localhost/index.php | grep -Eo "/vendor/phppgadmin-[.0-9]+/" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Retrieve phpPgAdmin URL (3 rounds): ${URL}\n"
|
||||
@ -84,16 +98,16 @@ fi
|
||||
|
||||
printf "[TEST] Fetch ${URL}intro.php"
|
||||
# 1st Try
|
||||
if ! curl -sS localhost${URL}intro.php | tac | tac | grep -Eiq "welcome to phpPgAdmin"; then
|
||||
if ! curl -sS --fail localhost${URL}intro.php | tac | tac | grep -Eiq "welcome to phpPgAdmin"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${URL}intro.php | tac | tac | grep -Eiq "welcome to phpPgAdmin"; then
|
||||
if ! curl -sS --fail localhost${URL}intro.php | tac | tac | grep -Eiq "welcome to phpPgAdmin"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! curl -sS localhost${URL}intro.php | tac | tac | grep -Eiq "welcome to phpPgAdmin"; then
|
||||
if ! curl -sS --fail localhost${URL}intro.php | tac | tac | grep -Eiq "welcome to phpPgAdmin"; then
|
||||
printf "\r[FAIL] Fetch ${URL}intro.php\n"
|
||||
curl -sS localhost/${URL}intro.php || true
|
||||
curl -sSI localhost/${URL}intro.php || true
|
||||
curl localhost/${URL}intro.php || true
|
||||
curl -I localhost/${URL}intro.php || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL}intro.php (3 rounds)\n"
|
||||
@ -112,16 +126,16 @@ fi
|
||||
|
||||
printf "[TEST] Evaluate successful phpPgAdmin login"
|
||||
# 1st Try
|
||||
if [ "$(curl -sS "localhost${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
if [ "$(curl -sS --fail "localhost${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS "localhost${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
if [ "$(curl -sS --fail "localhost${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS "localhost${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
if [ "$(curl -sS --fail "localhost${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
printf "\r[FAIL] Evaluate successful phpPgAdmin login\n"
|
||||
curl -sS "localhost/${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" || true
|
||||
curl -sSI "localhost/${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" || true
|
||||
curl "localhost/${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" || true
|
||||
curl -I "localhost/${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Evaluate successful phpPgAdmin login (3 rounds)\n"
|
125
.tests/tests/vendor-phpredmin.sh
Executable file
125
.tests/tests/vendor-phpredmin.sh
Executable file
@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=("5.2" "5.3" "5.4")
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [Vendor] phpReadmin"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Ensure PHPRedmin works
|
||||
###
|
||||
|
||||
URL="/vendor/phpredmin/public/index.php"
|
||||
|
||||
printf "[TEST] Fetch ${URL}"
|
||||
# 1st Try
|
||||
if [ "$(curl -sS --fail localhost${URL} | tac | tac | grep -Ec "Strings|Hashes|Lists|Sets|Sorted Sets")" != "5" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS --fail localhost${URL} | tac | tac | grep -Ec "Strings|Hashes|Lists|Sets|Sorted Sets")" != "5" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS --fail localhost${URL} | tac | tac | grep -Ec "Strings|Hashes|Lists|Sets|Sorted Sets")" != "5" ]; then
|
||||
printf "\r[FAIL] Fetch ${URL}\n"
|
||||
curl localhost/${URL} || true
|
||||
curl -I localhost/${URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Get current PHP version
|
||||
###
|
||||
|
||||
printf "[TEST] Get PHP version"
|
||||
# 1st Try
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if ! PHP_VERSION="$( curl -sS --fail localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' | grep -Eo '\([.0-9]+' | grep -Eo '[0-9]+\.[0-9]+' )"; then
|
||||
printf "\r[FAIL] Get PHP version\n"
|
||||
curl localhost/index.php | tac | tac | grep -Eo 'PHP.*?\([.0-9]+' || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Get PHP version (3 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (2 rounds): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Get PHP version (1 round): %s\n" "${PHP_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure only to check against desired versions
|
||||
###
|
||||
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_VERSION} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP ${PHP_VERSION}\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Ensure PHPRedmin works in subdirectory
|
||||
###
|
||||
|
||||
URL="/vendor/phpredmin/public/index.php/welcome/info/0/0"
|
||||
|
||||
printf "[TEST] Fetch ${URL}"
|
||||
# 1st Try
|
||||
if [ "$(curl -sS --fail localhost${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)")" != "5" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS --fail localhost${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)")" != "5" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS --fail localhost${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)")" != "5" ]; then
|
||||
printf "\r[FAIL] Fetch ${URL}\n"
|
||||
curl localhost/${URL} | tac | tac | grep -Ec "(Version:)|(Mode:)|(Role:)|(OS:)|(Uptime:)" || true
|
||||
curl localhost/${URL} || true
|
||||
curl -I localhost/${URL} || true
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] Fetch ${URL} (1 round)\n"
|
||||
fi
|
155
.tests/tests/vhost-directory_index.sh
Executable file
155
.tests/tests/vhost-directory_index.sh
Executable file
@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [vhost] DirectoryIndex"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HTTPD_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_SERVER" )"
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
HTTPD_DOCROOT_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_DOCROOT_DIR" )"
|
||||
|
||||
|
||||
###
|
||||
### The vhost name
|
||||
###
|
||||
VHOST=test-vhost-dir_index
|
||||
|
||||
|
||||
###
|
||||
### Create vhost directory
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/htdocs" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
|
||||
###
|
||||
### index.htm should be served by default
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"indexhtm\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.htm'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
printf "[TEST] index.htm should be served by default"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}' | tac | tac | grep -E '^indexhtm$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.htm should be served by default\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.htm should be served by default\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### index.html should be served by default
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"indexhtml\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.html'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
printf "[TEST] index.html should be served by default"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}' | tac | tac | grep -E '^indexhtml$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.html should be served by default\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.html should be served by default\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### index.php should be served by default
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"<?php echo \\\"indexphp\\\";\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.php'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
printf "[TEST] index.php should be served by default"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}' | tac | tac | grep -E '^indexphp$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.php should be served by default\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.php should be served by default\\n"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
###
|
||||
### index.htm is available via direct path
|
||||
###
|
||||
printf "[TEST] index.htm is available via direct path"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}/index.htm' | tac | tac | grep -E '^indexhtm$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.htm is available via direct path\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}/index.htm' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.htm is available via direct path\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### index.html is available via direct path
|
||||
###
|
||||
printf "[TEST] index.html is available via direct path"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}/index.html' | tac | tac | grep -E '^indexhtml$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.html is available via direct path\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}/index.html' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.html is available via direct path\\n"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### index.php is available via direct path
|
||||
###
|
||||
printf "[TEST] index.php is available via direct path"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}/index.php' | tac | tac | grep -E '^indexphp$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.php is available via direct path\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}/index.php' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.php is available via direct path\\n"
|
||||
fi
|
125
.tests/tests/vhost-vhostgen_customize.sh
Executable file
125
.tests/tests/vhost-vhostgen_customize.sh
Executable file
@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [vhost] Customize"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v diff >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'diff' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HTTPD_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_SERVER" )"
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
HTTPD_DOCROOT_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_DOCROOT_DIR" )"
|
||||
HTTPD_TEMPLATE_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_TEMPLATE_DIR" )"
|
||||
|
||||
|
||||
###
|
||||
### The vhost name
|
||||
###
|
||||
VHOST=test-vhost-vhostgen_customize
|
||||
|
||||
|
||||
###
|
||||
### Create vhost directory
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/htdocs" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Add index.htm, index.html and index.php
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"indexhtm\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.htm'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"indexhtml\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.html'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "docker-compose exec --user devilbox -T php bash -c 'echo \"<?php echo \\\"indexphp\\\";\" > /shared/httpd/${VHOST}/${HTTPD_DOCROOT_DIR}/index.php'" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
|
||||
|
||||
###
|
||||
### Copy default configuration
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/${HTTPD_TEMPLATE_DIR}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache22.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache22.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache24.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache24.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/nginx.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/nginx.yml" "${RETRIES}"
|
||||
|
||||
|
||||
###
|
||||
### Customize DirectoryIndex to use 'index.html' only
|
||||
###
|
||||
replace "__INDEX__" "index.html" "${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache22.yml"
|
||||
replace "__INDEX__" "index.html" "${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache24.yml"
|
||||
replace "__INDEX__" "index.html" "${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/nginx.yml"
|
||||
|
||||
|
||||
###
|
||||
### Ensure webserver reloads configuration
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mv /shared/httpd/${VHOST} /shared/httpd/${VHOST}.tmp" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mv /shared/httpd/${VHOST}.tmp /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Ensure index.html will be served by default (as configured)
|
||||
###
|
||||
printf "[TEST] index.html should be served"
|
||||
if ! run "docker-compose exec --user devilbox -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}' | tac | tac | grep -E '^indexhtml$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}" "0"; then
|
||||
printf "\\r[FAIL] index.html should be served\\n"
|
||||
run "docker-compose exec --user devilbox -T php curl 'http://${VHOST}.${TLD_SUFFIX}' || true" "1" "${DVLBOX_PATH}"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] index.html should be served\\n"
|
||||
fi
|
126
.tests/tests/vhost-vhostgen_default_template.sh
Executable file
126
.tests/tests/vhost-vhostgen_default_template.sh
Executable file
@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
|
||||
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
|
||||
# shellcheck disable=SC1090
|
||||
. "${SCRIPT_PATH}/../scripts/.lib.sh"
|
||||
|
||||
RETRIES=10
|
||||
DISABLED_VERSIONS=()
|
||||
|
||||
|
||||
echo
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo "# [vhost] Default Template"
|
||||
echo "# --------------------------------------------------------------------------------------------------"
|
||||
echo
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Pre-check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )"
|
||||
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then
|
||||
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'curl' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v tac >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'tac' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v diff >/dev/null 2>&1; then
|
||||
>&2 echo "Error 'diff' binary not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Get required env values
|
||||
###
|
||||
HTTPD_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_SERVER" )"
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
|
||||
HTTPD_DOCROOT_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_DOCROOT_DIR" )"
|
||||
HTTPD_TEMPLATE_DIR="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HTTPD_TEMPLATE_DIR" )"
|
||||
|
||||
|
||||
###
|
||||
### The vhost name
|
||||
###
|
||||
VHOST=test-vhost-vhostgen_def_tpl
|
||||
|
||||
|
||||
###
|
||||
### Create vhost directory
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php rm -rf /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/htdocs" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Fetch current httpd.conf
|
||||
###
|
||||
TEMPLATE1="$( run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhost.d/${VHOST}.conf'" "${RETRIES}" )"
|
||||
|
||||
|
||||
###
|
||||
### Copy default configuration
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mkdir -p /shared/httpd/${VHOST}/${HTTPD_TEMPLATE_DIR}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache22.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache22.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/apache24.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/apache24.yml" "${RETRIES}"
|
||||
run "cp ${DVLBOX_PATH}/cfg/vhost-gen/nginx.yml-example-vhost ${SCRIPT_PATH}/../www/${VHOST}/${HTTPD_TEMPLATE_DIR}/nginx.yml" "${RETRIES}"
|
||||
|
||||
|
||||
###
|
||||
### Ensure webserver reloads configuration
|
||||
###
|
||||
run "docker-compose exec --user devilbox -T php mv /shared/httpd/${VHOST} /shared/httpd/${VHOST}.tmp" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
run "docker-compose exec --user devilbox -T php mv /shared/httpd/${VHOST}.tmp /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
|
||||
run "sleep 4"
|
||||
|
||||
|
||||
###
|
||||
### Fetch new httpd.conf
|
||||
###
|
||||
TEMPLATE2="$( run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/vhost.d/${VHOST}.conf'" "${RETRIES}" )"
|
||||
|
||||
|
||||
###
|
||||
### Diff templates
|
||||
###
|
||||
TMP_DIR="${SCRIPT_PATH}/../tmp"
|
||||
run "mkdir -p '${TMP_DIR}'"
|
||||
echo "${TEMPLATE1}" > "${TMP_DIR}/original.txt"
|
||||
echo "${TEMPLATE2}" > "${TMP_DIR}/template.txt"
|
||||
|
||||
ERROR=0
|
||||
if ! run "diff -y '${TMP_DIR}/original.txt' '${TMP_DIR}/template.txt'"; then
|
||||
ERROR=1
|
||||
fi
|
||||
if ! run "diff '${TMP_DIR}/original.txt' '${TMP_DIR}/template.txt'"; then
|
||||
ERROR=1
|
||||
fi
|
||||
exit "${ERROR}"
|
@ -1 +0,0 @@
|
||||
js
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
COMPOSEPATH="${SCRIPTPATH}/../../../"
|
||||
cd "${COMPOSEPATH}"
|
||||
|
||||
NODE_PATH="/shared/httpd/my-rhost/js"
|
||||
NODE_FILE="index.js"
|
||||
|
||||
if ! docker-compose exec php test -d "${NODE_PATH}"; then
|
||||
>&2 echo "[Warning], skipping startup, directory does not exist in container: ${NODE_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker-compose exec php test -f "${NODE_PATH}/${NODE_FILE}"; then
|
||||
>&2 echo "[Warning], skipping startup, file does not exist in container: ${NODE_PATH}/${NODE_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Check if at least one pm2 process is already running
|
||||
if docker-compose exec --user devilbox php bash -c "cd /shared/httpd/my-rhost/js; pm2 show 0 >/dev/null"; then
|
||||
>&2 echo "[Warning], pm2 process already running"
|
||||
else
|
||||
echo "su -c \"cd ${NODE_PATH}; pm2 start ${NODE_FILE}\" -l devilbox"
|
||||
docker-compose exec --user devilbox php bash -c "cd /shared/httpd/my-rhost/js; pm2 start ${NODE_FILE}"
|
||||
fi
|
@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
COMPOSEPATH="${SCRIPTPATH}/../../../../"
|
||||
cd "${COMPOSEPATH}"
|
||||
|
||||
|
||||
printf "[TEST] http://my-rhost.loc"
|
||||
# 1st round
|
||||
if ! docker-compose exec --user devilbox php curl http://my-rhost.loc | grep "Hello World"; then
|
||||
sleep 1;
|
||||
# 2nd round
|
||||
if ! docker-compose exec --user devilbox php curl http://my-rhost.loc | grep "Hello World"; then
|
||||
sleep 1;
|
||||
# 3rd round
|
||||
if ! docker-compose exec --user devilbox php curl http://my-rhost.loc | grep "Hello World"; then
|
||||
printf "\r[FAIL] http://my-rhost.loc\n"
|
||||
cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php curl http://my-rhost.loc
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] http://my-rhost.loc (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] http://my-rhost.loc (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] http://my-rhost.loc (1 round)\n"
|
||||
fi
|
||||
|
||||
|
||||
printf "[TEST] https://my-rhost.loc"
|
||||
# 1st round
|
||||
if ! docker-compose exec --user devilbox php curl https://my-rhost.loc | grep "Hello World"; then
|
||||
sleep 1;
|
||||
# 2nd round
|
||||
if ! docker-compose exec --user devilbox php curl https://my-rhost.loc | grep "Hello World"; then
|
||||
sleep 1;
|
||||
# 3rd round
|
||||
if ! docker-compose exec --user devilbox php curl https://my-rhost.loc | grep "Hello World"; then
|
||||
printf "\r[FAIL] https://my-rhost.loc\n"
|
||||
cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php curl https://my-rhost.loc
|
||||
exit 1
|
||||
else
|
||||
printf "\r[OK] https://my-rhost.loc (3 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] https://my-rhost.loc (2 rounds)\n"
|
||||
fi
|
||||
else
|
||||
printf "\r[OK] https://my-rhost.loc (1 round)\n"
|
||||
fi
|
@ -1,7 +0,0 @@
|
||||
# Virtual host tests
|
||||
|
||||
Tests in this directory are run by a virtual host as well as executed on the cli inside the
|
||||
PHP container.
|
||||
|
||||
Every single PHP file must echo out `OK` and only `OK` if it succeeded.
|
||||
The tests are looking for the following regex string in the complete output: `/^OK$/`.
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This page should print 'OK' if everything works,
|
||||
* 'FAIL' or nothing if an error occured.
|
||||
*/
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
|
||||
|
||||
$MY_MAIL = 'test@example.org';
|
||||
$MY_SUBJ = 'mysubject';
|
||||
$MY_MESS = 'mymessage';
|
||||
$MY_URL = 'http://localhost/mail.php';
|
||||
|
||||
// Sent Email via POST request
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $MY_URL.'?email='.$MY_MAIL.'&subject='.$MY_SUBJ.'&message='.$MY_MESS);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
|
||||
curl_exec($ch);
|
||||
curl_close ($ch);
|
||||
sleep(5);
|
||||
|
||||
// Retrieve contents
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $MY_URL);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if (strpos($output, $MY_MAIL) === false) {
|
||||
echo 'FAIL - no mail';
|
||||
//print_r($output);
|
||||
exit(1);
|
||||
}
|
||||
if (strpos($output, $MY_SUBJ) === false) {
|
||||
echo 'FAIL - no subject';
|
||||
//print_r($output);
|
||||
exit(1);
|
||||
}
|
||||
if (strpos($output, $MY_MESS) === false) {
|
||||
echo 'FAIL - no message';
|
||||
//print_r($output);
|
||||
exit(1);
|
||||
}
|
||||
echo 'OK';
|
26
.tests/www/modules/htdocs/bcmath.php
Normal file
26
.tests/www/modules/htdocs/bcmath.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* This page should print 'OK' if everything works,
|
||||
* 'FAIL' or nothing if an error occured.
|
||||
*/
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
|
||||
$a = '1.234';
|
||||
$b = '5';
|
||||
|
||||
$num1 = bcadd($a, $b); // 6
|
||||
$num2 = bcadd($a, $b, 4); // 6.2340
|
||||
|
||||
if ($num1 != 6) {
|
||||
echo 'FAIL: ' . $num1;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($num2 != 6.2340) {
|
||||
echo 'FAIL: ' . $num2;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo 'OK';
|
67
.tests/www/modules/htdocs/gd-jpeg.php
Normal file
67
.tests/www/modules/htdocs/gd-jpeg.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* This page should print 'OK' if everything works,
|
||||
* 'FAIL' or nothing if an error occured.
|
||||
*/
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
|
||||
// Create a blank image and add some text
|
||||
if ( ($im = imagecreatetruecolor(640, 480)) === FALSE ) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// First we create our stamp image manually from GD
|
||||
if ( ($stamp = imagecreatetruecolor(100, 70)) === FALSE ) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!imagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF)) {
|
||||
echo 'FAIL: imagefilledrectangle()';
|
||||
exit(1);
|
||||
}
|
||||
if (!imagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF)) {
|
||||
echo 'FAIL: imagefilledrectangle()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!imagestring($stamp, 5, 20, 20, 'libGD', 0x0000FF)) {
|
||||
echo 'FAIL: imagestring()';
|
||||
exit(1);
|
||||
}
|
||||
if (!imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0x0000FF)) {
|
||||
echo 'FAIL: imagestring()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
// Set the margins for the stamp and get the height/width of the stamp image
|
||||
$marge_right = 10;
|
||||
$marge_bottom = 10;
|
||||
$sx = imagesx($stamp);
|
||||
$sy = imagesy($stamp);
|
||||
|
||||
// Merge the stamp onto our photo with an opacity of 50%
|
||||
if (!imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50)) {
|
||||
echo 'FAIL: imagecopymerge()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Save the image to file and free memory
|
||||
if (!imagejpeg($im, 'image.jpg')) {
|
||||
echo 'FAIL: imagejpeg()';
|
||||
exit(1);
|
||||
}
|
||||
if (!imagedestroy($im)) {
|
||||
echo 'FAIL: imagedestroy()';
|
||||
unlink('image.jpg');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Remove image after test
|
||||
unlink('image.jpg');
|
||||
|
||||
echo 'OK';
|
67
.tests/www/modules/htdocs/gd-png.php
Normal file
67
.tests/www/modules/htdocs/gd-png.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* This page should print 'OK' if everything works,
|
||||
* 'FAIL' or nothing if an error occured.
|
||||
*/
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
|
||||
// Create a blank image and add some text
|
||||
if ( ($im = imagecreatetruecolor(640, 480)) === FALSE ) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// First we create our stamp image manually from GD
|
||||
if ( ($stamp = imagecreatetruecolor(100, 70)) === FALSE ) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!imagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF)) {
|
||||
echo 'FAIL: imagefilledrectangle()';
|
||||
exit(1);
|
||||
}
|
||||
if (!imagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF)) {
|
||||
echo 'FAIL: imagefilledrectangle()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!imagestring($stamp, 5, 20, 20, 'libGD', 0x0000FF)) {
|
||||
echo 'FAIL: imagestring()';
|
||||
exit(1);
|
||||
}
|
||||
if (!imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0x0000FF)) {
|
||||
echo 'FAIL: imagestring()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
// Set the margins for the stamp and get the height/width of the stamp image
|
||||
$marge_right = 10;
|
||||
$marge_bottom = 10;
|
||||
$sx = imagesx($stamp);
|
||||
$sy = imagesy($stamp);
|
||||
|
||||
// Merge the stamp onto our photo with an opacity of 50%
|
||||
if (!imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50)) {
|
||||
echo 'FAIL: imagecopymerge()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Save the image to file and free memory
|
||||
if (!imagepng($im, 'image.png')) {
|
||||
echo 'FAIL: imagepng()';
|
||||
exit(1);
|
||||
}
|
||||
if (!imagedestroy($im)) {
|
||||
echo 'FAIL: imagedestroy()';
|
||||
unlink('image.png');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Remove image after test
|
||||
unlink('image.png');
|
||||
|
||||
echo 'OK';
|
42
.tests/www/modules/htdocs/gd-webp.php
Normal file
42
.tests/www/modules/htdocs/gd-webp.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* This page should print 'OK' if everything works,
|
||||
* 'FAIL' or nothing if an error occured.
|
||||
*/
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
|
||||
// Create a blank image and add some text
|
||||
if ( ($im = imagecreatetruecolor(120, 20)) === FALSE ) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( ($text_color = imagecolorallocate($im, 233, 14, 91)) === FALSE ) {
|
||||
echo 'FAIL: imagecolorallocate()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!imagestring($im, 1, 5, 5, 'WebP with PHP', $text_color)) {
|
||||
echo 'FAIL: imagestring()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Save the image
|
||||
if (!imagewebp($im, 'image.webp')) {
|
||||
echo 'FAIL: imagewebp()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Free up memory
|
||||
if (!imagedestroy($im)) {
|
||||
echo 'FAIL: imagedestroy()';
|
||||
unlink('image.webp');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Remove image after test
|
||||
unlink('image.webp');
|
||||
|
||||
echo 'OK';
|
40
.tests/www/modules/htdocs/imagick.php
Normal file
40
.tests/www/modules/htdocs/imagick.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* This page should print 'OK' if everything works,
|
||||
* 'FAIL' or nothing if an error occured.
|
||||
*/
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
|
||||
/* Set width and height in proportion of genuine PHP logo */
|
||||
$width = 400;
|
||||
$height = 210;
|
||||
|
||||
/* Create an Imagick object with transparent canvas */
|
||||
$img = new Imagick();
|
||||
|
||||
if ($img->newImage($width, $height, new ImagickPixel('transparent')) !== TRUE) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* New ImagickDraw instance for ellipse draw */
|
||||
$draw = new ImagickDraw();
|
||||
/* Set purple fill color for ellipse */
|
||||
$draw->setFillColor('#777bb4');
|
||||
/* Set ellipse dimensions */
|
||||
$draw->ellipse($width / 2, $height / 2, $width / 2, $height / 2, 0, 360);
|
||||
/* Draw ellipse onto the canvas */
|
||||
$img->drawImage($draw);
|
||||
|
||||
/* Reset fill color from purple to black for text (note: we are reusing ImagickDraw object) */
|
||||
$draw->setFillColor('black');
|
||||
|
||||
if ($img->setImageFormat('png') !== TRUE) {
|
||||
echo 'FAIL: imagecreatetruecolor()';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
echo 'OK';
|
@ -19,10 +19,10 @@ $redis = new \Redis();
|
||||
if (!$redis->connect($MY_HOST, $MY_PORT, 0.5, NULL)) {
|
||||
echo 'FAIL';
|
||||
exit(1);
|
||||
} else {
|
||||
$redis->set($MY_KEY, $MY_VAL);
|
||||
}
|
||||
|
||||
$redis->set($MY_KEY, $MY_VAL);
|
||||
|
||||
foreach ($redis->info('all') as $key => $val) {
|
||||
if (preg_match('/db[0-9]+/', $key)) {
|
||||
$database = str_replace('db', '', $key);
|
||||
@ -30,7 +30,7 @@ foreach ($redis->info('all') as $key => $val) {
|
||||
if ($redis->get($MY_KEY) == $MY_VAL) {
|
||||
echo 'OK';
|
||||
$redis->close();
|
||||
exit(1);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
// Load the http module to create an http server.
|
||||
var http = require('http');
|
||||
|
||||
// Configure our HTTP server to respond with Hello World to all requests.
|
||||
// Configure our HTTP server to respond with 'OK-RPROXY-JAVASCRIPT' to all requests.
|
||||
var server = http.createServer(function (request, response) {
|
||||
response.writeHead(200, {"Content-Type": "text/plain"});
|
||||
response.end("Hello World\n");
|
||||
response.end("OK-RPROXY-JAVASCRIPT\n");
|
||||
});
|
||||
|
||||
// Listen on port 8000, IP defaults to 127.0.0.1
|
Loading…
x
Reference in New Issue
Block a user