You are here

public function WebhookHashTest::testWebhook in Mailchimp 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/WebhookHashTest.php \Drupal\Tests\mailchimp\Functional\WebhookHashTest::testWebhook()

Tests configuring a text editor for an existing text format.

File

tests/src/Functional/WebhookHashTest.php, line 29

Class

WebhookHashTest
Tests Mailchimp webhook protection.

Namespace

Drupal\Tests\mailchimp\Functional

Code

public function testWebhook() {

  // If there are no settings, any request should work.
  $this
    ->drupalGet('mailchimp/webhook/foo');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // If a hash is set, an invalid hash should fail.
  $this
    ->config('mailchimp.settings')
    ->set('webhook_hash', 'bar')
    ->save();
  $this
    ->drupalGet('mailchimp/webhook/foo');
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // If a hash is set and it matches, the request should work.
  $this
    ->drupalGet('mailchimp/webhook/bar');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}