From e7e8eead920618ce630e892d01366a9b62045f9a Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Mon, 3 Aug 2020 23:41:14 -0700 Subject: [PATCH] [#415] Fix tests. --- src/Plugin/KeyInput/ApigeeAuthKeyInput.php | 3 ++- .../Form/AuthenticationFormJsTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Plugin/KeyInput/ApigeeAuthKeyInput.php b/src/Plugin/KeyInput/ApigeeAuthKeyInput.php index 94cd362d..6d429feb 100644 --- a/src/Plugin/KeyInput/ApigeeAuthKeyInput.php +++ b/src/Plugin/KeyInput/ApigeeAuthKeyInput.php @@ -106,7 +106,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['password'] = [ '#type' => 'password', '#title' => $this->t('Password'), - '#description' => $this->t("Organization user's password that is used for authenticating with the endpoint."), + '#description' => $this->t("Organization user's password that is used for authenticating with the endpoint.") . + (empty($values['password']) ? '' : ' ' . $this->t('Leave empty unless you want to change the stored password.')), '#attributes' => [ 'autocomplete' => 'off', ], diff --git a/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php b/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php index 6a6f459f..d5657f5c 100644 --- a/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php +++ b/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php @@ -116,6 +116,9 @@ public function testAuthenticationForm() { $this->drupalLogin($this->rootUser); $this->drupalGet(Url::fromRoute('apigee_edge.settings')); + // We need to fill in the password field to test connection. + $this->getSession()->getPage()->fillField('Password', $this->password); + $this->assertSession()->pageTextContains('Send request using the given API credentials.'); $this->assertSendRequestMessage('.messages--status', 'Connection successful.'); $web_assert->elementNotExists('css', 'details[data-drupal-selector="edit-debug"]'); @@ -131,6 +134,9 @@ public function testAuthenticationForm() { $this->visitAuthenticationForm(); $web_assert->fieldValueEquals('Organization', $this->organization); $web_assert->fieldValueEquals('Username', $this->username); + + // Password field should be empty. + $web_assert->fieldValueEquals('Password', ''); } /** @@ -321,10 +327,13 @@ protected function validateForm(callable $visitFormAsAdmin): void { $this->cssSelect('select[name="key_input_settings[auth_type]"]')[0]->setValue('basic'); // Test the connection with basic auth. + $page->fillField('Password', $this->password); $this->assertSendRequestMessage('.messages--status', 'Connection successful.'); $web_assert->elementNotExists('css', 'details[data-drupal-selector="edit-debug"]'); + $page->fillField('Password', $this->password); // Press the Save/Save configuration button. $page->pressButton('op'); + $this->assertSession()->pageTextContains('Connection successful.'); // Because Key add/edit form redirects the user to the Key entity listing // page on success therefore we have to re-visit the form again.