You are here

public function ContentHubSettingsFormTest::testContentHubSettingsPageWithInvalidData in Acquia Content Hub 8.2

Tests different cases of invalid data provided through the form.

Throws

\Behat\Mink\Exception\ResponseTextException

File

tests/src/Functional/ContentHubSettingsFormTest.php, line 207

Class

ContentHubSettingsFormTest
Tests the Content Hub settings form.

Namespace

Drupal\Tests\acquia_contenthub\Functional

Code

public function testContentHubSettingsPageWithInvalidData() {
  $session = $this
    ->assertSession();
  $settings = [
    'hostname' => 'https://invalid-url.com',
    'api_key' => 'invalid',
    'secret_key' => 'invalid',
    'client_name' => 'test',
    'webhook' => MockDataProvider::VALID_WEBHOOK_URL,
  ];
  $this
    ->drupalPostForm(self::CH_SETTINGS_FORM_PATH, $settings, 'Register Site');
  $session
    ->pageTextContains(sprintf('Could not get authorization from Content Hub to register client %s. Are your credentials inserted correctly?', $settings['client_name']));
  $session
    ->pageTextContains('There is a problem connecting to Acquia Content Hub. Please ensure that your hostname and credentials are correct.');
  $settings['hostname'] = MockDataProvider::VALID_HOSTNAME;
  $this
    ->drupalPostForm(self::CH_SETTINGS_FORM_PATH, $settings, 'Register Site');
  $session
    ->pageTextContains(sprintf('[4001] Not Found: Customer Key %s could not be found.', $settings['api_key']));
  $settings['api_key'] = MockDataProvider::VALID_API_KEY;
  $this
    ->drupalPostForm(self::CH_SETTINGS_FORM_PATH, $settings, 'Register Site');
  $session
    ->pageTextContains('[4001] Signature for the message does not match expected signature for API key.');
}