From 7b967f473dc0a35afb63e1c73727291a257204f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 27 Dec 2019 15:49:33 +0100 Subject: [PATCH] Add more test for permission helper - Add more test of helper 'ynh_permission_update' - Add test of permission protection feature --- permissions_app_ynh/scripts/install | 6 ++++-- permissions_app_ynh/scripts/upgrade | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 permissions_app_ynh/scripts/upgrade diff --git a/permissions_app_ynh/scripts/install b/permissions_app_ynh/scripts/install index af5c537..bca4f96 100644 --- a/permissions_app_ynh/scripts/install +++ b/permissions_app_ynh/scripts/install @@ -17,13 +17,15 @@ path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH) admin_user=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +ynh_app_setting_set --app $app --key admin_user --value $admin_user + # Check domain/path availability ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path." ynh_webpath_register $app $domain $path_url -ynh_permission_create --permission "admin" --url "/admin" --allowed "$admin_user" +ynh_permission_create --permission "admin" --url "/admin" --allowed "$admin_user" --protected true -ynh_permission_create --permission "dev" --url "/dev" +ynh_permission_create --permission "dev" --url "/dev" --protected false #================================================= # SETUP SSOWAT diff --git a/permissions_app_ynh/scripts/upgrade b/permissions_app_ynh/scripts/upgrade new file mode 100644 index 0000000..adc0c0c --- /dev/null +++ b/permissions_app_ynh/scripts/upgrade @@ -0,0 +1,22 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Stop script if errors +ynh_abort_if_errors + +# Retrieve arguments +app=$YNH_APP_INSTANCE_NAME +admin_user=$(ynh_app_setting_get --app $app --key admin_user) + +#================================================= +# UPDATE PERMISSIONS +#================================================= + +ynh_permission_update --permission admin --remove $admin_user --protected false +ynh_permission_update --permission dev --add $admin_user --protected true