From 38a172626ccba44faef722b724dad0e63af5a118 Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Thu, 4 Mar 2021 10:56:38 +0100 Subject: [PATCH 1/2] Change SF4 default env based on dev group_names By default, when the build is not in development mode, the production debug=false option is used. When in dev mode, debug mode is engaged, and a conditional smoketest env can be set if the testcookie was present. Should be fine for production releases as they will not be polluted with the additional config. To pull this change run: './deploy-site-app.sh' Should be rather compatible with the Stepup RV changes found here: https://github.com/OpenConext/Stepup-Deploy/blob/572d09b8dc068710af3f39dcaccbca627293a9f7/roles/app/templates/php72-nginx-vhost-symfony4.conf.j2#L45-L51 --- .../php72-nginx-vhost-symfony4.conf.j2 | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/roles/app/templates/php72-nginx-vhost-symfony4.conf.j2 b/roles/app/templates/php72-nginx-vhost-symfony4.conf.j2 index cbcec3a3..bd10dfbf 100644 --- a/roles/app/templates/php72-nginx-vhost-symfony4.conf.j2 +++ b/roles/app/templates/php72-nginx-vhost-symfony4.conf.j2 @@ -42,8 +42,24 @@ server { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS on; - fastcgi_param SYMFONY_ENV prod; - fastcgi_param APP_ENV prod; + + {% if 'dev' not in group_names %} + # Non dev environments have the symfony env set to prod in a hardcoded manner + set $app_env "prod"; + set $app_debug false; + {% elif 'dev' in group_names %} + # If the testcookie is present, we will kick the symfony environment into smoketest mode. Otherwise dev mode it is. + set $app_env "dev"; + set $app_debug true; + if ($cookie_testcookie) { + set $app_env "smoketest"; + set $app_debug true; + } + {% endif %} + + fastcgi_param SYMFONY_ENV $app_env; + fastcgi_param APP_ENV $app_env; + fastcgi_param APP_DEBUG $app_debug; } {# Finally, disallow opening php files outside of index.php #} From 603c1b034afab024d43f87d90fdecc488a6f7bc0 Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Thu, 4 Mar 2021 11:01:31 +0100 Subject: [PATCH 2/2] Make FeatureContext SF4 proof app/console was used throughout this Context. This resulted in failing behat tests. --- tests/behat/features/bootstrap/FeatureContext.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index da9faefb..1c5eb50c 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -51,16 +51,16 @@ public static function setupDatabase(BeforeFeatureScope $scope) { // Generate test databases echo "Preparing test schemas\n"; - shell_exec("/src/Stepup-Middleware/app/console doctrine:schema:drop --env=smoketest --force"); - shell_exec("/src/Stepup-Gateway/app/console doctrine:schema:drop --env=test --force"); - shell_exec("/src/Stepup-Middleware/app/console doctrine:schema:create --env=smoketest"); - shell_exec("/src/Stepup-Gateway/app/console doctrine:schema:create --env=test"); + shell_exec("php72 /src/Stepup-Middleware/bin/console doctrine:schema:drop --env=smoketest --force"); + shell_exec("php72 /src/Stepup-Gateway/bin/console doctrine:schema:drop --env=test --force"); + shell_exec("php72 /src/Stepup-Middleware/bin/console doctrine:schema:create --env=smoketest"); + shell_exec("php72 /src/Stepup-Gateway/bin/console doctrine:schema:create --env=test"); echo "Replaying event stream\n"; // Import the events.sql into middleware shell_exec("mysql -uroot -ppassword middleware_test < ./fixtures/events.sql"); // Perform an event replay - shell_exec("/src/Stepup-Middleware/app/console middleware:event:replay --env=smoketest_event_replay --no-interaction -q"); + shell_exec("php72 /src/Stepup-Middleware/bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -q"); echo "Update the keys\n"; // Update the `saml_entities` projection in `gateway_test`