From e0544e6a352525124f499d33619f1224add4e473 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 9 Feb 2024 19:37:31 +0100 Subject: [PATCH 1/4] EWPP-3969: Add Drupal 10.2.x and PHP 8.2 to matrix. --- .drone.yml | 18 +++++++------- behat.yml.dist | 24 +++++++++++++++++++ composer.json | 7 +++--- docker-compose.yml | 13 +++------- .../oe_authentication_eulogin_mock.info.yml | 2 +- .../oe_authentication_user_fields.info.yml | 2 +- oe_authentication.info.yml | 2 +- 7 files changed, 43 insertions(+), 25 deletions(-) diff --git a/.drone.yml b/.drone.yml index cffc6ec..d8f5846 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,13 +24,11 @@ services: environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes selenium: - image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-3.141.59-oxygen - shm_size: 2g + image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-4.1.3-20220405 environment: - DISPLAY=:99 - - SE_OPTS=-debug - - SCREEN_WIDTH=1280 - - SCREEN_HEIGHT=800 + - SCREEN_WIDTH=1440 + - SCREEN_HEIGHT=900 - NODE_MAX_INSTANCES=5 - NODE_MAX_SESSION=5 @@ -77,9 +75,11 @@ pipeline: matrix: include: - - CORE_VERSION: 9.4.0 - PHP_VERSION: 8.0 - - CORE_VERSION: 9.4.0 + - CORE_VERSION: 10.1.0 PHP_VERSION: 8.1 - - CORE_VERSION: 10.0 + - CORE_VERSION: 10.1.0 + PHP_VERSION: 8.2 + - CORE_VERSION: 10.2.0 PHP_VERSION: 8.1 + - CORE_VERSION: 10.2.0 + PHP_VERSION: 8.2 diff --git a/behat.yml.dist b/behat.yml.dist index 89d1484..81fd147 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -30,6 +30,30 @@ default: base_url: "${drupal.base_url}" selenium2: wd_host: '${selenium.host}:${selenium.port}/wd/hub' + capabilities: + browser: chrome + nativeEvents: true + marionette: true + browserName: chrome + version: '*' + extra_capabilities: + chromeOptions: + w3c: false + args: + - '--no-sandbox' + - '--start-maximized' + - '--disable-gpu' + - '--window-size=1440,900' + - '--disable-dev-shm-usage' + - '--disable-setuid-sandbox' + - '--disable-web-security' + - '--DNS-prefetch-disable' + - '--disable-translate' + - '--ignore-certificate-errors' + - '--test-type' + - '--disable-extensions' + - '--incognito' + - '--disable-infobars' Drupal\DrupalExtension: api_driver: "drupal" drupal: diff --git a/composer.json b/composer.json index cc149df..fe5c4f4 100644 --- a/composer.json +++ b/composer.json @@ -6,17 +6,18 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.0", + "php": ">=8.1", "drupal/cas": "^2.2", - "drupal/core": "^9.4 || ^10" + "drupal/core": "^10" }, "require-dev": { "composer/installers": "^1.11", "drupal/cas_mock_server": "^2.0.1", - "drupal/core-composer-scaffold": "^9.4 || ^10", + "drupal/core-composer-scaffold": "^10", "drupal/drupal-extension": "^5.0", "drush/drush": "^11.1 || ^12", "mikey179/vfsstream": "^1.6.10", + "nikic/php-parser": "^4", "openeuropa/behat-transformation-context": "^0.2", "openeuropa/code-review": "^2.0.0-alpha6", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", diff --git a/docker-compose.yml b/docker-compose.yml index ab9f3e9..042c251 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,23 +24,16 @@ services: MYSQL_ALLOW_EMPTY_PASSWORD: "yes" # ports: # - 3306:3306 - # If you would like to see what is going on you can run the following on your host: - # docker run --rm -p 4444:4444 -p 5900:5900 --network="host" selenium/standalone-chrome-debug:latest - # Newer version of this image might run into this issue: - # @link https://github.com/elgalu/docker-selenium/issues/20 + # Visit localhost:7900 to access the browser. selenium: - image: selenium/standalone-chrome-debug:3.141.59-oxygen - expose: - - '4444' + image: selenium/standalone-chrome:4.1.3-20220405 environment: - DISPLAY=:99 - - SE_OPTS=-debug - SCREEN_WIDTH=1280 - SCREEN_HEIGHT=800 - VNC_NO_PASSWORD=1 ports: - - '4444:4444' - - '5900:5900' + - '7900:7900' shm_size: 2g #### Mac users: uncomment the "volumes" key to enable the NFS file sharing. diff --git a/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.info.yml b/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.info.yml index 847f394..5c2b633 100644 --- a/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.info.yml +++ b/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.info.yml @@ -2,7 +2,7 @@ name: OE Authentication EU Login mock description: EU Login mock server implementation. package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - cas:cas - cas_mock_server:cas_mock_server diff --git a/modules/oe_authentication_user_fields/oe_authentication_user_fields.info.yml b/modules/oe_authentication_user_fields/oe_authentication_user_fields.info.yml index a27bfcf..7a221a3 100644 --- a/modules/oe_authentication_user_fields/oe_authentication_user_fields.info.yml +++ b/modules/oe_authentication_user_fields/oe_authentication_user_fields.info.yml @@ -2,6 +2,6 @@ name: OE Authentication User Fields description: Provides some user basic fields and map them with EU Login attributes. package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_authentication:oe_authentication diff --git a/oe_authentication.info.yml b/oe_authentication.info.yml index cf18634..69c0ce8 100644 --- a/oe_authentication.info.yml +++ b/oe_authentication.info.yml @@ -2,6 +2,6 @@ name: OE Authentication description: Authentication against the OpenEuropa Authentication service. package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - cas:cas From 4ad2562996fa5f3498c708569d8ce3fd811e2ddd Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 9 Feb 2024 21:05:26 +0100 Subject: [PATCH 2/4] EWPP-3969: Drop support for Drush 11. --- composer.json | 7 +--- .../drush.services.yml | 6 ---- .../Commands/sql/UserSanitizeCommand.php | 33 +++++++++++++------ .../Functional/UserSanitizeCommandTest.php | 4 +-- 4 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 modules/oe_authentication_user_fields/drush.services.yml rename modules/oe_authentication_user_fields/src/{ => Drush}/Commands/sql/UserSanitizeCommand.php (70%) diff --git a/composer.json b/composer.json index fe5c4f4..1f912eb 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "drupal/cas_mock_server": "^2.0.1", "drupal/core-composer-scaffold": "^10", "drupal/drupal-extension": "^5.0", - "drush/drush": "^11.1 || ^12", + "drush/drush": "^12", "mikey179/vfsstream": "^1.6.10", "nikic/php-parser": "^4", "openeuropa/behat-transformation-context": "^0.2", @@ -62,11 +62,6 @@ "locations": { "web-root": "./build" } - }, - "drush": { - "services": { - "drush.services.yml": "^11" - } } }, "config": { diff --git a/modules/oe_authentication_user_fields/drush.services.yml b/modules/oe_authentication_user_fields/drush.services.yml deleted file mode 100644 index 61dabb3..0000000 --- a/modules/oe_authentication_user_fields/drush.services.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - oe_authentication_user_fields.sanitize_commands: - class: Drupal\oe_authentication_user_fields\Commands\sql\UserSanitizeCommand - arguments: [ '@entity_type.manager', '@database' ] - tags: - - { name: drush.command } diff --git a/modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php b/modules/oe_authentication_user_fields/src/Drush/Commands/sql/UserSanitizeCommand.php similarity index 70% rename from modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php rename to modules/oe_authentication_user_fields/src/Drush/Commands/sql/UserSanitizeCommand.php index 190412b..6ba1b27 100755 --- a/modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php +++ b/modules/oe_authentication_user_fields/src/Drush/Commands/sql/UserSanitizeCommand.php @@ -2,19 +2,23 @@ declare(strict_types = 1); -namespace Drupal\oe_authentication_user_fields\Commands\sql; +namespace Drupal\oe_authentication_user_fields\Drush\Commands\sql; use Consolidation\AnnotatedCommand\CommandData; +use Consolidation\AnnotatedCommand\Hooks\HookManager; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drush\Attributes as CLI; use Drush\Commands\DrushCommands; +use Drush\Drupal\Commands\sql\SanitizeCommands; use Drush\Drupal\Commands\sql\SanitizePluginInterface; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Sanitizes the user fields related data. */ -class UserSanitizeCommand extends DrushCommands implements SanitizePluginInterface { +final class UserSanitizeCommand extends DrushCommands implements SanitizePluginInterface { /** * The entity type manager. @@ -45,12 +49,24 @@ public function __construct(EntityTypeManagerInterface $entityTypeManager, Conne } /** - * Sanitize the user data from the DB. + * Returns a new instance. * - * @hook post-command sql-sanitize + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The Drupal container. * - * @inheritdoc + * @return static */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity_type.manager'), + $container->get('database') + ); + } + + /** + * {@inheritdoc} + */ + #[CLI\Hook(type: HookManager::POST_COMMAND_HOOK, target: SanitizeCommands::SANITIZE)] public function sanitize($result, CommandData $commandData) { $this->connection->update('users_field_data') ->expression('field_oe_firstname', 'CONCAT(:fn_dummy_string, uid)', [ @@ -74,12 +90,9 @@ public function sanitize($result, CommandData $commandData) { } /** - * Sets the output message. - * - * @hook on-event sql-sanitize-confirms - * - * @inheritdoc + * {@inheritdoc} */ + #[CLI\Hook(type: HookManager::ON_EVENT, target: SanitizeCommands::CONFIRMS)] public function messages(&$messages, InputInterface $input) { $messages[] = dt('Sanitise user fields.'); } diff --git a/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php b/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php index 0daa101..72b212f 100755 --- a/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php +++ b/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php @@ -46,13 +46,11 @@ public function testEuLoginUsersDataSanitization() { $this->drush('sql:sanitize'); $expected = 'The following operations will be performed:' . PHP_EOL; - // An extra newline is added when the command is executed with Drupal 9.x. - // @todo Remove when support for Drupal 9.x is dropped. - $expected .= version_compare(\Drupal::VERSION, '10.0.0', '<') ? PHP_EOL : ''; $expected .= '* Truncate sessions table.' . PHP_EOL; $expected .= '* Sanitize text fields associated with users.' . PHP_EOL; $expected .= '* Sanitize user passwords.' . PHP_EOL; $expected .= '* Sanitize user emails.' . PHP_EOL; + $expected .= '* Preserve user emails and passwords for the specified roles.' . PHP_EOL; $expected .= '* Sanitise user fields.'; $this->assertOutputEquals($expected); From 3b8fc257be9d688c6bc7f9ae8efe08ed2ded0d1f Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 9 Feb 2024 22:03:40 +0100 Subject: [PATCH 3/4] EWPP-3969: Add entry to readme section. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1f912eb..f7b6914 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,8 @@ }, "_readme": [ "Explicit minimum version requirement of symfony/phpunit-bridge to replace drupal/core-dev testing classes and traits.", - "Explicit requirement of mikey179/vfsstream to remove when drupal/core-dev is reinstated." + "Explicit requirement of mikey179/vfsstream to remove when drupal/core-dev is reinstated.", + "Explicit requirement of nikic/php-parser ^4 as later versions are not compatible with grumphp @see https://github.com/phpro/grumphp/issues/1119" ], "drupal-scaffold": { "locations": { From a748bdba6231822b7c0554916f6b2fd9153f368d Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Tue, 13 Feb 2024 16:14:13 +0100 Subject: [PATCH 4/4] EWPP-3969: Fix coding standards. --- .../oe_authentication_eulogin_mock.install | 2 +- .../src/EventSubscriber/CasMockServerSubscriber.php | 2 +- .../src/EventSubscriber/CasPreRedirectSubscriber.php | 2 +- modules/oe_authentication_eulogin_mock/src/Form/LogoutForm.php | 2 +- .../oe_authentication_eulogin_mock/src/Form/RegisterForm.php | 2 +- .../src/Routing/RouteSubscriber.php | 2 +- .../tests/src/Kernel/MockResponseTest.php | 2 +- .../oe_authentication_user_fields.module | 2 +- .../src/Drush/Commands/sql/UserSanitizeCommand.php | 2 +- .../src/EuLoginAttributesHelper.php | 2 +- .../EventSubscriber/EuLoginAttributesToUserFieldsSubscriber.php | 2 +- .../tests/src/Functional/UserSanitizeCommandTest.php | 2 +- oe_authentication.install | 2 +- oe_authentication.module | 2 +- oe_authentication.post_update.php | 2 +- src/CasProcessor.php | 2 +- src/Controller/ProxyCallbackController.php | 2 +- src/Controller/RegisterController.php | 2 +- src/Event/EuLoginEventSubscriber.php | 2 +- src/Event/MessengerEuLoginEventSubscriber.php | 2 +- src/Form/AuthenticationSettingsForm.php | 2 +- src/Plugin/Block/LoginBlock.php | 2 +- src/Routing/RouteSubscriber.php | 2 +- tests/Behat/AuthenticationContext.php | 2 +- tests/Behat/CleanupContext.php | 2 +- tests/Kernel/EuLoginEventSubscriberTest.php | 2 +- tests/Kernel/LoginBlockTest.php | 2 +- tests/Kernel/ProxyCallbackTest.php | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.install b/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.install index 08af74f..de500f7 100644 --- a/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.install +++ b/modules/oe_authentication_eulogin_mock/oe_authentication_eulogin_mock.install @@ -5,7 +5,7 @@ * OpenEuropa Authentication EU Login mock install file. */ -declare(strict_types = 1); +declare(strict_types=1); /** * Implements hook_install(). diff --git a/modules/oe_authentication_eulogin_mock/src/EventSubscriber/CasMockServerSubscriber.php b/modules/oe_authentication_eulogin_mock/src/EventSubscriber/CasMockServerSubscriber.php index 428fe6f..7bf4896 100644 --- a/modules/oe_authentication_eulogin_mock/src/EventSubscriber/CasMockServerSubscriber.php +++ b/modules/oe_authentication_eulogin_mock/src/EventSubscriber/CasMockServerSubscriber.php @@ -1,6 +1,6 @@