mirror of
https://github.com/YunoHost-Apps/redirect_ynh.git
synced 2024-09-03 20:16:10 +02:00
ci: add a dummy service to be able to test reverseproxy mode
This commit is contained in:
parent
de11beb6c5
commit
83d04b763f
6 changed files with 70 additions and 26 deletions
|
@ -1,3 +1,3 @@
|
|||
location __PATH__ {
|
||||
return 302 __TARGET__$request_uri;
|
||||
return 302 __TARGET__;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
URL_REGEX_VALID='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
|
||||
URL_REGEX_SECURE='^(http://(127\.[0-9]+\.[0-9]+\.[0-9]+|localhost)|https://.*)(:[0-9]+)?(/.*)?$'
|
||||
|
||||
|
@ -23,10 +15,26 @@ _validate_redirect_uri() {
|
|||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
_add_dummy_service() {
|
||||
cat << EOF > /etc/systemd/system/whatever.service
|
||||
[Unit]
|
||||
Description=Whatever
|
||||
After=network.target
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
[Service]
|
||||
WorkingDirectory=/redirect/
|
||||
ExecStart=python3 -m http.server -b 127.0.0.1 1234
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
mkdir -p /redirect
|
||||
echo "helloworld" > /redirect/index.html
|
||||
systemctl daemon-reload
|
||||
ynh_systemd_action --service_name=whatever --action=enable
|
||||
ynh_systemd_action --service_name=whatever --action=restart
|
||||
|
||||
true
|
||||
}
|
||||
|
|
|
@ -11,6 +11,12 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
_validate_redirect_uri
|
||||
|
||||
# When testing on the CI, we need a service to test the reverse-proxying
|
||||
if [[ ${PACKAGE_CHECK_EXEC} == "1" ]] && [[ "$redirect_type" == "reverseproxy" ]]
|
||||
then
|
||||
_add_dummy_service
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE NGINX
|
||||
#=================================================
|
||||
|
@ -19,6 +25,14 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|||
mv ../conf/{"nginx-$redirect_type.conf",nginx.conf}
|
||||
ynh_add_nginx_config
|
||||
|
||||
|
||||
if [[ ${PACKAGE_CHECK_EXEC} == "1" ]] && [[ "$redirect_type" == "reverseproxy" ]]
|
||||
then
|
||||
systemctl status whatever >&2
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
|
@ -7,6 +8,12 @@ ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
# When testing on the CI, we need a service to test the reverse-proxying
|
||||
if [[ ${PACKAGE_CHECK_EXEC} == "1" ]] && [[ "$redirect_type" == "reverseproxy" ]]
|
||||
then
|
||||
_add_dummy_service
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -20,6 +20,12 @@ if [[ -z "${target:-}" ]] && [[ -n "${redirect_path:-}" ]]; then
|
|||
ynh_app_setting_set --app=$app --key=target --value="$redirect_path"
|
||||
fi
|
||||
|
||||
# When testing on the CI, we need a service to test the reverse-proxying
|
||||
if [[ ${PACKAGE_CHECK_EXEC} == "1" ]] && [[ "$redirect_type" == "reverseproxy" ]]
|
||||
then
|
||||
_add_dummy_service
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE NGINX
|
||||
#=================================================
|
||||
|
|
31
tests.toml
31
tests.toml
|
@ -4,25 +4,34 @@ test_format = 1.0
|
|||
|
||||
[default]
|
||||
|
||||
args.redirect_type = "redirect"
|
||||
args.target = "http://127.0.0.1"
|
||||
args.redirect_type = "reverseproxy"
|
||||
args.target = "http://127.0.0.1:1234/"
|
||||
|
||||
exclude = ["install.private", "install.multi", "backup_restore", "change_url"]
|
||||
|
||||
[default.test_upgrade_from.09cf1c6b]
|
||||
name = "v1 era"
|
||||
args.domain = "domain.tld"
|
||||
args.redirect_type = "visible_302"
|
||||
args.redirect_path = "http://127.0.0.1"
|
||||
args.path = "/"
|
||||
args.redirect_type = "proxy"
|
||||
args.redirect_path = "http://127.0.0.1:1234/"
|
||||
args.is_public = true
|
||||
|
||||
|
||||
[reverseproxy]
|
||||
[redirect]
|
||||
|
||||
args.redirect_type = "reverseproxy"
|
||||
args.target = "http://127.0.0.1"
|
||||
args.redirect_type = "redirect"
|
||||
args.target = "https://127.0.0.1"
|
||||
|
||||
exclude = ["install.private", "install.multi", "backup_restore"]
|
||||
# Turns out 302 redirects cant be made private because they are interpreted before going through the sso ...
|
||||
exclude = ["install.private"]
|
||||
|
||||
[reverseproxy.test_upgrade_from.09cf1c6b]
|
||||
[redirect.test_upgrade_from.09cf1c6b]
|
||||
name = "v1 era"
|
||||
args.domain = "domain.tld"
|
||||
args.redirect_type = "proxy"
|
||||
args.redirect_path = "http://127.0.0.1"
|
||||
args.path = "/"
|
||||
args.redirect_type = "visible_302"
|
||||
args.redirect_path = "https://127.0.0.1"
|
||||
args.is_public = true
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue