Skip to content

Commit

Permalink
[apigee#415] Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
arlina-espinoza committed Aug 4, 2020
1 parent 769cae6 commit e7e8eea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Plugin/KeyInput/ApigeeAuthKeyInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]');
Expand All @@ -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', '');
}

/**
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e7e8eea

Please sign in to comment.