You are here

public function ManageFieldsTest::testExternalDestinations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Tests/ManageFieldsTest.php \Drupal\field_ui\Tests\ManageFieldsTest::testExternalDestinations()

Tests that external URLs in the 'destinations' query parameter are blocked.

File

core/modules/field_ui/src/Tests/ManageFieldsTest.php, line 614
Contains \Drupal\field_ui\Tests\ManageFieldsTest.

Class

ManageFieldsTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\field_ui\Tests

Code

public function testExternalDestinations() {
  $options = [
    'query' => [
      'destinations' => [
        'http://example.com',
      ],
    ],
  ];
  $this
    ->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body/storage', [], 'Save field settings', $options);

  // The external redirect should not fire.
  $this
    ->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options);
  $this
    ->assertResponse(200);
  $this
    ->assertRaw('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
}