1
0
mirror of https://github.com/zokradonh/kopano-docker synced 2025-06-07 16:06:14 +00:00

experiment with overriding exec to test bash script functions (#254)

* experiment with overriding exec to test bash script functions

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* refine tests

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* test installation of packages

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* make sure package list is not updated when there are not additional packages

* basic commander tests for webapp

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* add webapp commander to makefile

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* basic tests for webapp

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* check webapp config.php

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* add tests for z-push

Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
Felix Bartels 2019-10-08 23:00:36 +02:00 committed by GitHub
parent dca6e0c87b
commit 80a3b2a563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 142 additions and 7 deletions

View File

@ -386,6 +386,8 @@ test-commander: ## Test scripts with commander
commander test tests/commander.yaml
COMMANDER_OPTS="--concurrent 1" COMMANDER_FILES_PATH=core/commander/server dccommander run kopano_server
COMMANDER_OPTS="--concurrent 1" COMMANDER_FILES_PATH=core/commander/spooler dccommander run kopano_spooler
COMMANDER_OPTS="--concurrent 1" COMMANDER_FILES_PATH=webapp dccommander run kopano_webapp
COMMANDER_OPTS="--concurrent 1" COMMANDER_FILES_PATH=zpush dccommander run kopano_zpush
test-security: ## Scan containers with Trivy for known security risks (not part of CI workflow for now).
cat $(TAG_FILE) | xargs -I % sh -c 'trivy --exit-code 0 --severity HIGH --quiet --auto-refresh %'

View File

@ -1,22 +1,55 @@
tests:
test run of config update script for core:
command: /usr/bin/python3 /kopano/server.py
start-service script:
command: bash -c "shopt -s expand_aliases; alias exec='echo'; . /kopano/start-service.sh"
exit-code: 0
config update kopano-server:
command: /usr/bin/python3 /kopano/server.py && cat /etc/kopano/server.cfg /etc/kopano/ldap.cfg
stdout:
not-contains:
- "Reading package lists..."
start-service script (installing new package):
command: bash -c "shopt -s expand_aliases; alias exec='echo'; . /kopano/start-service.sh"
exit-code: 0
stdout:
contains:
- "Setting up nano"
config:
env:
ADDITIONAL_KOPANO_PACKAGES: "nano"
start-service script (installing existing package):
command: bash -c "shopt -s expand_aliases; alias exec='echo'; . /kopano/start-service.sh"
exit-code: 0
stdout:
contains:
- "INFO: kopano-server is already installed"
config:
env:
ADDITIONAL_KOPANO_PACKAGES: "kopano-server"
generate configuration for kopano-server:
command: /usr/bin/python3 /kopano/server.py && cat /etc/kopano/server.cfg
exit-code: 0
stdout:
contains:
- server_listen_tls = *:237
- server_ssl_key_file = /kopano/ssl/kopano_server.pem
not-contains:
- #server_listen_tls = *:237
generate ldap configuration openLDAP (default):
command: /usr/bin/python3 /kopano/server.py && cat /etc/kopano/ldap.cfg
exit-code: 0
stdout:
contains:
- "!include /usr/share/kopano/ldap.openldap.cfg"
- "#!include /usr/share/kopano/ldap.active-directory.cfg"
config update ldap ads:
not-contains:
- "#!include /usr/share/kopano/ldap.openldap.cfg"
generate ldap configuration for ADS:
command: /usr/bin/python3 /kopano/server.py && cat /etc/kopano/ldap.cfg
exit-code: 0
stdout:
contains:
- "#!include /usr/share/kopano/ldap.openldap.cfg"
- "!include /usr/share/kopano/ldap.active-directory.cfg"
not-contains:
- "#!include /usr/share/kopano/ldap.active-directory.cfg"
config:
env:
KCCOMMENT_LDAP_1: "!include /usr/share/kopano/ldap.openldap.cfg"
@ -48,7 +81,6 @@ config:
KCCONF_SERVER_SSLKEYS_PATH: ${KCCONF_SERVER_SSLKEYS_PATH}
KCCONF_SERVER_SYSTEM_EMAIL_ADDRESS: ${KCCONF_SERVER_SYSTEM_EMAIL_ADDRESS}
KCUNCOMMENT_LDAP_1: ${KCUNCOMMENT_LDAP_1}
KOPANO_LOCALE: ${KOPANO_LOCALE}
KOPANO_USERSCRIPT_LOCALE: ${KOPANO_USERSCRIPT_LOCALE}
LANG: ${LANG}
SERVICE_TO_START: ${SERVICE_TO_START}
PATH: ${PATH}

View File

@ -17,6 +17,8 @@ ADDITIONAL_KOPANO_PACKAGES=$(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"')
# shellcheck disable=SC2016 disable=SC2086
if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then
apt --assume-yes --no-upgrade install "$installpkg"
else
echo "INFO: $installpkg is already installed"
fi
done

52
webapp/commander.yaml Normal file
View File

@ -0,0 +1,52 @@
tests:
start-service script:
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh"
exit-code: 0
stdout:
not-contains:
- "Reading package lists..."
start-service script (installing new package):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh"
exit-code: 0
stdout:
contains:
- "Setting up nano"
config:
env:
ADDITIONAL_KOPANO_PACKAGES: "nano"
start-service script (installing existing package):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh"
exit-code: 0
stdout:
contains:
- "INFO: kopano-webapp is already installed"
config:
env:
ADDITIONAL_KOPANO_PACKAGES: "kopano-webapp"
start-service script (webapp configuration):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/kopano/webapp/config.php
exit-code: 0
stdout:
contains:
- "define('OIDC_CLIENT_ID', 'webapp');"
config:
env:
KCCONF_WEBAPP_OIDC_CLIENT_ID: "webapp"
start-service script (installing & configuring webapp mdm plugin):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/kopano/webapp/config-mdm.php
exit-code: 0
stdout:
contains:
- "define('PLUGIN_MDM_USER_DEFAULT_ENABLE_MDM', true);"
config:
env:
ADDITIONAL_KOPANO_WEBAPP_PLUGINS: "kopano-webapp-plugin-mdm"
KCCONF_WEBAPPPLUGIN_MDM_PLUGIN_MDM_USER_DEFAULT_ENABLE_MDM: "true"
config:
env:
DEBUG: ${DEBUG}
KCCONF_WEBAPP_OIDC_ISS: ${KCCONF_WEBAPP_OIDC_ISS}
KCCONF_WEBAPP_OIDC_CLIENT_ID: ${KCCONF_WEBAPP_OIDC_CLIENT_ID}
LANG: ${LANG}
PATH: ${PATH}
TZ: ${TZ}

View File

@ -20,6 +20,8 @@ ADDITIONAL_KOPANO_PACKAGES=$(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"')
# shellcheck disable=SC2016 disable=SC2086
if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then
apt --assume-yes --no-upgrade install "$installpkg"
else
echo "INFO: $installpkg is already installed"
fi
done

43
zpush/commander.yaml Normal file
View File

@ -0,0 +1,43 @@
tests:
start-service script:
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh"
exit-code: 0
stdout:
not-contains:
- "Reading package lists..."
start-service script (installing new package):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh"
exit-code: 0
stdout:
contains:
- "Setting up nano"
config:
env:
ADDITIONAL_KOPANO_PACKAGES: "nano"
start-service script (installing existing package):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh"
exit-code: 0
stdout:
contains:
- "INFO: z-push-kopano is already installed"
config:
env:
ADDITIONAL_KOPANO_PACKAGES: "z-push-kopano"
start-service script (z-push configuration):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/z-push/z-push.conf.php
exit-code: 0
stdout:
contains:
- "define('USE_CUSTOM_REMOTE_IP_HEADER', 'HTTP_X_FORWARDED_FOR');"
start-service script (configuring gabsync):
command: bash -c "shopt -s expand_aliases; alias exec='echo exec'; alias php-fpm7.0='echo php-fpm7.0'; . /kopano/start.sh" && cat /etc/z-push/gabsync.conf.php
exit-code: 0
stdout:
contains:
- "define('USERNAME', 'SYSTEM');"
config:
env:
DEBUG: ${DEBUG}
LANG: ${LANG}
PATH: ${PATH}
TZ: ${TZ}

View File

@ -44,6 +44,8 @@ ADDITIONAL_KOPANO_PACKAGES=$(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"')
# shellcheck disable=SC2016 disable=SC2086
if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then
apt --assume-yes --no-upgrade install "$installpkg"
else
echo "INFO: $installpkg is already installed"
fi
done