From a60ca80070f7e5d5b2f605d5830cbc03fff852e8 Mon Sep 17 00:00:00 2001 From: nagyad Date: Mon, 7 Jan 2019 14:04:53 +0100 Subject: [PATCH 01/10] OPENEUROPA-1501: Implement configuration UI for Authentication. --- oe_authentication.links.menu.yml | 5 ++ oe_authentication.permissions.yml | 3 + oe_authentication.routing.yml | 7 ++ src/Form/AuthenticationSettingsForm.php | 80 +++++++++++++++++++ .../features/configure_authentication.feature | 30 +++++++ 5 files changed, 125 insertions(+) create mode 100644 oe_authentication.links.menu.yml create mode 100644 oe_authentication.permissions.yml create mode 100644 oe_authentication.routing.yml create mode 100644 src/Form/AuthenticationSettingsForm.php create mode 100644 tests/features/configure_authentication.feature diff --git a/oe_authentication.links.menu.yml b/oe_authentication.links.menu.yml new file mode 100644 index 0000000..9d4d373 --- /dev/null +++ b/oe_authentication.links.menu.yml @@ -0,0 +1,5 @@ +oe_authentication.settings: + title: Authentication settings + description: 'Configure Authentication settings.' + route_name: oe_authentication.settings + parent: system.admin_config_system diff --git a/oe_authentication.permissions.yml b/oe_authentication.permissions.yml new file mode 100644 index 0000000..4512e5c --- /dev/null +++ b/oe_authentication.permissions.yml @@ -0,0 +1,3 @@ +administer authentication configuration: + title: 'Administer Authentication configuration' + restrict access: false diff --git a/oe_authentication.routing.yml b/oe_authentication.routing.yml new file mode 100644 index 0000000..af56c4a --- /dev/null +++ b/oe_authentication.routing.yml @@ -0,0 +1,7 @@ +oe_authentication.settings: + path: '/admin/config/system/oe_authentication' + defaults: + _form: 'Drupal\oe_authentication\Form\AuthenticationSettingsForm' + _title: 'Authentication settings' + requirements: + _permission: 'administer authentication configuration' diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php new file mode 100644 index 0000000..b3a192d --- /dev/null +++ b/src/Form/AuthenticationSettingsForm.php @@ -0,0 +1,80 @@ + 'textfield', + '#title' => $this->t('Application authentication protocol'), + '#default_value' => $this->config(static::CONFIGNAME)->get('protocol'), + ]; + $form['register_path'] = [ + '#type' => 'textfield', + '#title' => $this->t('Application register path'), + '#default_value' => $this->config(static::CONFIGNAME)->get('register_path'), + ]; + $form['validation_path'] = [ + '#type' => 'textfield', + '#title' => $this->t('Application validation path'), + '#default_value' => $this->config(static::CONFIGNAME)->get('validation_path'), + ]; + $form['assurance_level'] = [ + '#type' => 'textfield', + '#title' => $this->t('Application assurance levels'), + '#default_value' => $this->config(static::CONFIGNAME)->get('assurance_level'), + ]; + $form['ticket_types'] = [ + '#type' => 'textfield', + '#title' => $this->t('Application available ticket types'), + '#default_value' => $this->config(static::CONFIGNAME)->get('ticket_types'), + ]; + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $this->config(static::CONFIGNAME) + ->set('protocol', $form_state->getValues()['protocol']) + ->set('register_path', $form_state->getValues()['register_path']) + ->set('validation_path', $form_state->getValues()['validation_path']) + ->set('assurance_level', $form_state->getValues()['assurance_level']) + ->set('ticket_types', $form_state->getValues()['ticket_types']) + ->save(); + parent::submitForm($form, $form_state); + } + +} diff --git a/tests/features/configure_authentication.feature b/tests/features/configure_authentication.feature new file mode 100644 index 0000000..786f644 --- /dev/null +++ b/tests/features/configure_authentication.feature @@ -0,0 +1,30 @@ +@api +Feature: Authentication + As the site manager + I need to be able to configure the settings + + Background: + Given the site is configured to use Drupal login + And I am logged in as a user with the "administer authentication configuration" permission + + Scenario: Configure Authentication settings + Given I am on "admin/config/system/oe_authentication" + Then I should see "Authentication settings" + # Check for the default config is there. + And the "Application authentication protocol" field should contain "eulogin" + And the "Application register path" field should contain "eim/external/register.cgi" + And the "Application validation path" field should contain "TicketValidationService" + And the "Application assurance levels" field should contain "TOP" + And the "Application available ticket types" field should contain "SERVICE,PROXY" + # Change the configuration values. + When I fill in "Application authentication protocol" with "something" + And I fill in "Application register path" with "test/something" + And I fill in "Application validation path" with "validation/path" + And I fill in "Application assurance levels" with "assurance" + And I fill in "Application available ticket types" with "ticket.test" + And I press "Save configuration" + And the "Application authentication protocol" field should contain "something" + And the "Application register path" field should contain "test/something" + And the "Application validation path" field should contain "validation/path" + And the "Application assurance levels" field should contain "assurance" + And the "Application available ticket types" field should contain "ticket.test" From 1e0c76c186b9b2a9954676a487851cdf57f8201e Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 08:16:00 +0100 Subject: [PATCH 02/10] OPENEUROPA-1501: Create behat tag for Drupal logins. --- tests/Behat/AuthenticationContext.php | 11 ++++++++++- tests/features/configure_authentication.feature | 4 ++-- tests/features/drupal-login.feature | 5 ++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index e485415..90dda3b 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -20,12 +20,21 @@ class AuthenticationContext extends ConfigContext { /** * Configures the CAS module to use Drupal login. * - * @Given the site is configured to use Drupal login + * @BeforeScenario @DrupalLogin */ public function setConfigDrupalLogin(): void { $this->setConfig('cas.settings', 'forced_login.enabled', FALSE); } + /** + * Configures the CAS module to use CAS login. + * + * @AfterScenario @DrupalLogin + */ + public function setConfigCasLogin(): void { + $this->setConfig('cas.settings', 'forced_login.enabled', TRUE); + } + /** * Configures the CAS module to initialize this client as a proxy. * diff --git a/tests/features/configure_authentication.feature b/tests/features/configure_authentication.feature index 786f644..15cffc5 100644 --- a/tests/features/configure_authentication.feature +++ b/tests/features/configure_authentication.feature @@ -4,9 +4,9 @@ Feature: Authentication I need to be able to configure the settings Background: - Given the site is configured to use Drupal login - And I am logged in as a user with the "administer authentication configuration" permission + Given I am logged in as a user with the "administer authentication configuration" permission + @DrupalLogin Scenario: Configure Authentication settings Given I am on "admin/config/system/oe_authentication" Then I should see "Authentication settings" diff --git a/tests/features/drupal-login.feature b/tests/features/drupal-login.feature index abdec06..52b62b5 100644 --- a/tests/features/drupal-login.feature +++ b/tests/features/drupal-login.feature @@ -3,10 +3,9 @@ Feature: Login through Drupal If configured properly I can access the CMS backend through Drupal + @DrupalLogin Scenario: If configured properly I can access the CMS backend through Drupal - Given the site is configured to use Drupal login - - When I am logged in as a user with the "authenticated" role + Given I am logged in as a user with the "authenticated" role Then I should see the link "Log out" When I click "Log out" From 8b5d610e5575d9375808a1943d448bb220bddc69 Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 11:08:17 +0100 Subject: [PATCH 03/10] OPENEUROPA-1501: Backup default authentication config during behat. --- src/Form/AuthenticationSettingsForm.php | 14 +++++++------- tests/Behat/AuthenticationContext.php | 14 ++++++++++++++ tests/features/configure_authentication.feature | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php index b3a192d..58d24ec 100644 --- a/src/Form/AuthenticationSettingsForm.php +++ b/src/Form/AuthenticationSettingsForm.php @@ -24,13 +24,6 @@ public function getFormId() { return 'oe_authentication_settings'; } - /** - * {@inheritdoc} - */ - protected function getEditableConfigNames() { - return ['oe_authentication.settings']; - } - /** * {@inheritdoc} */ @@ -77,4 +70,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return ['oe_authentication.settings']; + } + } diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 90dda3b..56274e5 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -69,4 +69,18 @@ public function blockUser(string $username): void { } } + /** + * Backup configs that need to be reverted in AfterScenario by ConfigContext. + * + * @BeforeScenario @BackupCasConfigs + */ + public function backupCasConfigs(): void { + $name = 'oe_authentication.settings'; + + $configs = $this->getDriver()->getCore()->configGet($name); + foreach ($configs as $key => $backup) { + $this->config[$name][$key] = $backup; + } + } + } diff --git a/tests/features/configure_authentication.feature b/tests/features/configure_authentication.feature index 15cffc5..306bb06 100644 --- a/tests/features/configure_authentication.feature +++ b/tests/features/configure_authentication.feature @@ -6,7 +6,7 @@ Feature: Authentication Background: Given I am logged in as a user with the "administer authentication configuration" permission - @DrupalLogin + @DrupalLogin @BackupCasConfigs Scenario: Configure Authentication settings Given I am on "admin/config/system/oe_authentication" Then I should see "Authentication settings" From 422d29286bea1789588def7d99d06b3b33fc7102 Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 11:44:47 +0100 Subject: [PATCH 04/10] OPENEUROPA-1501: Set task runner to beta4. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6522e72..f69f5c9 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "nikic/php-parser": "~3.0", "openeuropa/code-review": "~1.0.0-alpha4", "openeuropa/drupal-core-require-dev": "^8.6", - "openeuropa/task-runner": "~1.0-beta3", + "openeuropa/task-runner": "~1.0-beta4", "symfony/browser-kit": "~3.0||~4.0", "phpunit/phpunit": "~6.0" }, From 5f2042175c326dee9a26bfa64d1e46ae43d41b9b Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 14:41:03 +0100 Subject: [PATCH 05/10] OPENEUROPA-1501: Disable Big Pipe and fix typo.. --- behat.yml.dist | 3 +++ runner.yml.dist | 1 + tests/Behat/AuthenticationContext.php | 2 +- tests/features/configure_authentication.feature | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index c4d070e..171ffae 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -6,6 +6,7 @@ default: contexts: - Drupal\DrupalExtension\Context\MinkContext - Drupal\DrupalExtension\Context\DrupalContext + - Drupal\DrupalExtension\Context\MessageContext - Drupal\Tests\oe_authentication\Behat\AuthenticationContext extensions: Behat\MinkExtension: @@ -20,5 +21,7 @@ default: api_driver: "drupal" drupal: drupal_root: "${drupal.root}" + selectors: + message_selector: ".messages" formatters: progress: ~ diff --git a/runner.yml.dist b/runner.yml.dist index 714c15a..734c3b3 100644 --- a/runner.yml.dist +++ b/runner.yml.dist @@ -16,6 +16,7 @@ drupal: - "./vendor/bin/drush en config_devel -y" # Enable the modules. - "./vendor/bin/drush en oe_authentication -y" + - "./vendor/bin/drush pmu big_pipe -y" - "./vendor/bin/drush cr" settings: settings: diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 56274e5..5633fba 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -72,7 +72,7 @@ public function blockUser(string $username): void { /** * Backup configs that need to be reverted in AfterScenario by ConfigContext. * - * @BeforeScenario @BackupCasConfigs + * @BeforeScenario @BackupAuthConfigs */ public function backupCasConfigs(): void { $name = 'oe_authentication.settings'; diff --git a/tests/features/configure_authentication.feature b/tests/features/configure_authentication.feature index 306bb06..5622230 100644 --- a/tests/features/configure_authentication.feature +++ b/tests/features/configure_authentication.feature @@ -6,7 +6,7 @@ Feature: Authentication Background: Given I am logged in as a user with the "administer authentication configuration" permission - @DrupalLogin @BackupCasConfigs + @DrupalLogin @BackupAuthConfigs Scenario: Configure Authentication settings Given I am on "admin/config/system/oe_authentication" Then I should see "Authentication settings" @@ -23,6 +23,7 @@ Feature: Authentication And I fill in "Application assurance levels" with "assurance" And I fill in "Application available ticket types" with "ticket.test" And I press "Save configuration" + Then I should see the message "The configuration options have been saved." And the "Application authentication protocol" field should contain "something" And the "Application register path" field should contain "test/something" And the "Application validation path" field should contain "validation/path" From 75ee3ac1f842350cbf3c5e7280c99a1e2a9f4840 Mon Sep 17 00:00:00 2001 From: nagyad Date: Tue, 8 Jan 2019 14:55:55 +0100 Subject: [PATCH 06/10] OPENEUROPA-1501: Add dom-crawler to composer. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f69f5c9..c8e69f8 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "openeuropa/drupal-core-require-dev": "^8.6", "openeuropa/task-runner": "~1.0-beta4", "symfony/browser-kit": "~3.0||~4.0", - "phpunit/phpunit": "~6.0" + "phpunit/phpunit": "~6.0", + "symfony/dom-crawler": "~3.4" }, "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", From c6a3618ff1cec08d1713e00ed5498e313e3d96dd Mon Sep 17 00:00:00 2001 From: nagyad Date: Wed, 9 Jan 2019 09:08:59 +0100 Subject: [PATCH 07/10] OPENEUROPA-1501: Set CAS version to 1.3 release and remove not necessary config setter from AfterScenario. --- composer.json | 2 +- tests/Behat/AuthenticationContext.php | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/composer.json b/composer.json index c8e69f8..c04ca84 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "drupal/cas": "dev-1.x", + "drupal/cas": "~1.3", "openeuropa/drupal-core-require": "^8.6", "php": "^7.1" }, diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 5633fba..5326953 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -26,15 +26,6 @@ public function setConfigDrupalLogin(): void { $this->setConfig('cas.settings', 'forced_login.enabled', FALSE); } - /** - * Configures the CAS module to use CAS login. - * - * @AfterScenario @DrupalLogin - */ - public function setConfigCasLogin(): void { - $this->setConfig('cas.settings', 'forced_login.enabled', TRUE); - } - /** * Configures the CAS module to initialize this client as a proxy. * From 47e0a4df174e087f4cef25c0061bc2bb35ecd322 Mon Sep 17 00:00:00 2001 From: nagyad Date: Wed, 9 Jan 2019 15:37:12 +0100 Subject: [PATCH 08/10] OPENEUROPA-1501: Set CAS version to dev. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c04ca84..c8e69f8 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "drupal/cas": "~1.3", + "drupal/cas": "dev-1.x", "openeuropa/drupal-core-require": "^8.6", "php": "^7.1" }, From 930e50ffb8bc042b9300e09153eef0f31a974718 Mon Sep 17 00:00:00 2001 From: nagyad Date: Thu, 10 Jan 2019 13:50:51 +0100 Subject: [PATCH 09/10] OPENEUROPA-1501: Extend the proper class for behat context and fix test. --- behat.yml.dist | 1 + src/Form/AuthenticationSettingsForm.php | 10 ++--- tests/Behat/AuthenticationContext.php | 53 +++++++++++++++++++------ tests/features/ecas-login.feature | 11 +++-- 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 171ffae..8be9f0b 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -5,6 +5,7 @@ default: - %paths.base%/tests/features contexts: - Drupal\DrupalExtension\Context\MinkContext + - Drupal\DrupalExtension\Context\ConfigContext - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\MessageContext - Drupal\Tests\oe_authentication\Behat\AuthenticationContext diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php index 58d24ec..6b3ee4b 100644 --- a/src/Form/AuthenticationSettingsForm.php +++ b/src/Form/AuthenticationSettingsForm.php @@ -61,11 +61,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config(static::CONFIGNAME) - ->set('protocol', $form_state->getValues()['protocol']) - ->set('register_path', $form_state->getValues()['register_path']) - ->set('validation_path', $form_state->getValues()['validation_path']) - ->set('assurance_level', $form_state->getValues()['assurance_level']) - ->set('ticket_types', $form_state->getValues()['ticket_types']) + ->set('protocol', $form_state->getValue('protocol')) + ->set('register_path', $form_state->getValue('register_path')) + ->set('validation_path', $form_state->getValue('validation_path')) + ->set('assurance_level', $form_state->getValue('assurance_level')) + ->set('ticket_types', $form_state->getValue('ticket_types')) ->save(); parent::submitForm($form, $form_state); } diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 5326953..03e39a0 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -4,18 +4,34 @@ namespace Drupal\Tests\oe_authentication\Behat; -use Drupal\DrupalExtension\Context\ConfigContext; +use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use Drupal\DrupalExtension\Context\RawDrupalContext; /** * Defines step definitions specifically for testing the CAS options. - * - * We are extending ConfigContext to override the setConfig() method until - * issue https://github.com/jhedstrom/drupalextension/issues/498 is fixed. - * - * @todo Extend DrupalRawContext and gather the config context when the above - * issue is fixed. */ -class AuthenticationContext extends ConfigContext { +class AuthenticationContext extends RawDrupalContext { + + + /** + * The config context. + * + * @var \Drupal\DrupalExtension\Context\ConfigContext + */ + protected $configContext; + + /** + * Gathers some other contexts. + * + * @param \Behat\Behat\Hook\Scope\BeforeScenarioScope $scope + * The before scenario scope. + * + * @BeforeScenario + */ + public function gatherContexts(BeforeScenarioScope $scope) { + $environment = $scope->getEnvironment(); + $this->configContext = $environment->getContext('Drupal\DrupalExtension\Context\ConfigContext'); + } /** * Configures the CAS module to use Drupal login. @@ -23,7 +39,20 @@ class AuthenticationContext extends ConfigContext { * @BeforeScenario @DrupalLogin */ public function setConfigDrupalLogin(): void { - $this->setConfig('cas.settings', 'forced_login.enabled', FALSE); + $this->configContext->setConfig('cas.settings', 'forced_login.enabled', FALSE); + } + + /** + * Configures the CAS module to use CAS login. + * + * Revert the CAS login setting. The ConfigContext does revert + * this value, however it is cached and therefore it isn't available for + * other scenarios following this tag. + * + * @AfterScenario @DrupalLogin + */ + public function setConfigCasLogin(): void { + $this->configContext->setConfig('cas.settings', 'forced_login.enabled', TRUE); } /** @@ -32,7 +61,7 @@ public function setConfigDrupalLogin(): void { * @Given the site is configured to initialize this client as a proxy */ public function setConfigProxyInitialize(): void { - $this->setConfig('cas.settings', 'proxy.initialize', TRUE); + $this->configContext->setConfig('cas.settings', 'proxy.initialize', TRUE); } /** @@ -69,8 +98,8 @@ public function backupCasConfigs(): void { $name = 'oe_authentication.settings'; $configs = $this->getDriver()->getCore()->configGet($name); - foreach ($configs as $key => $backup) { - $this->config[$name][$key] = $backup; + foreach ($configs as $key => $value) { + $this->configContext->setConfig($name, $key, $value); } } diff --git a/tests/features/ecas-login.feature b/tests/features/ecas-login.feature index 69ba5e7..1468ccc 100644 --- a/tests/features/ecas-login.feature +++ b/tests/features/ecas-login.feature @@ -1,4 +1,4 @@ -@javascript +@api @javascript Feature: Login through OE Authentication In order to be able to access the CMS backend As user of the system @@ -36,14 +36,17 @@ Feature: Login through OE Authentication And I should see the link "Log in" Scenario: A blocked user should not be able to log in - Given the user "chucknorris" is blocked + Given users: + | name | + | lsalander | + And the user "lsalander" is blocked When I am on the homepage Then I should see the link "Log in" And I should not see the link "Log out" # When I try to log in again I will be denied access. When I click "Log in" - And I fill in "Username or e-mail address" with "texasranger@chuck_norris.com.eu" - And I fill in "Password" with "Qwerty098" + And I fill in "Username or e-mail address" with "Lisbeth.SALANDER@ext.ec.europa.eu" + And I fill in "Password" with "dragon_tattoo" And I press the "Login!" button Then I should see "There was a problem logging in, please contact a site administrator." From 7d7ed6bb8ffd4d463023d0f85f53d3977299629c Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 11 Jan 2019 09:49:49 +0100 Subject: [PATCH 10/10] OPENEUROPA-1501: Rename constant and add string for path in behat. --- behat.yml.dist | 5 ++++- composer.json | 1 + src/Form/AuthenticationSettingsForm.php | 14 +++++++------- tests/features/configure_authentication.feature | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 8be9f0b..a07eaa8 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -4,11 +4,14 @@ default: paths: - %paths.base%/tests/features contexts: - - Drupal\DrupalExtension\Context\MinkContext - Drupal\DrupalExtension\Context\ConfigContext - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\MessageContext + - Drupal\DrupalExtension\Context\MinkContext - Drupal\Tests\oe_authentication\Behat\AuthenticationContext + - OpenEuropa\Behat\TransformationContext: + pages: + Authentication configuration: 'admin/config/system/oe_authentication' extensions: Behat\MinkExtension: goutte: ~ diff --git a/composer.json b/composer.json index c8e69f8..95a16e9 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "drupal/drupal-extension": "~4.0", "drush/drush": "~9.0@stable", "nikic/php-parser": "~3.0", + "openeuropa/behat-transformation-context" : "~0.1", "openeuropa/code-review": "~1.0.0-alpha4", "openeuropa/drupal-core-require-dev": "^8.6", "openeuropa/task-runner": "~1.0-beta4", diff --git a/src/Form/AuthenticationSettingsForm.php b/src/Form/AuthenticationSettingsForm.php index 6b3ee4b..1e70289 100644 --- a/src/Form/AuthenticationSettingsForm.php +++ b/src/Form/AuthenticationSettingsForm.php @@ -15,7 +15,7 @@ class AuthenticationSettingsForm extends ConfigFormBase { /** * Name of the config being edited. */ - const CONFIGNAME = 'oe_authentication.settings'; + const CONFIG_NAME = 'oe_authentication.settings'; /** * {@inheritdoc} @@ -31,27 +31,27 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['protocol'] = [ '#type' => 'textfield', '#title' => $this->t('Application authentication protocol'), - '#default_value' => $this->config(static::CONFIGNAME)->get('protocol'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('protocol'), ]; $form['register_path'] = [ '#type' => 'textfield', '#title' => $this->t('Application register path'), - '#default_value' => $this->config(static::CONFIGNAME)->get('register_path'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('register_path'), ]; $form['validation_path'] = [ '#type' => 'textfield', '#title' => $this->t('Application validation path'), - '#default_value' => $this->config(static::CONFIGNAME)->get('validation_path'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('validation_path'), ]; $form['assurance_level'] = [ '#type' => 'textfield', '#title' => $this->t('Application assurance levels'), - '#default_value' => $this->config(static::CONFIGNAME)->get('assurance_level'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('assurance_level'), ]; $form['ticket_types'] = [ '#type' => 'textfield', '#title' => $this->t('Application available ticket types'), - '#default_value' => $this->config(static::CONFIGNAME)->get('ticket_types'), + '#default_value' => $this->config(static::CONFIG_NAME)->get('ticket_types'), ]; return parent::buildForm($form, $form_state); } @@ -60,7 +60,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $this->config(static::CONFIGNAME) + $this->config(static::CONFIG_NAME) ->set('protocol', $form_state->getValue('protocol')) ->set('register_path', $form_state->getValue('register_path')) ->set('validation_path', $form_state->getValue('validation_path')) diff --git a/tests/features/configure_authentication.feature b/tests/features/configure_authentication.feature index 5622230..b1bc885 100644 --- a/tests/features/configure_authentication.feature +++ b/tests/features/configure_authentication.feature @@ -8,7 +8,7 @@ Feature: Authentication @DrupalLogin @BackupAuthConfigs Scenario: Configure Authentication settings - Given I am on "admin/config/system/oe_authentication" + Given I am on "the Authentication configuration page" Then I should see "Authentication settings" # Check for the default config is there. And the "Application authentication protocol" field should contain "eulogin"