You are here

public function RestrictIpAccessTest::testBlacklistedPaths in Restrict IP 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/RestrictIpAccessTest.php \Drupal\Tests\restrict_ip\Functional\RestrictIpAccessTest::testBlacklistedPaths()
  2. 3.x tests/src/Functional/RestrictIpAccessTest.php \Drupal\Tests\restrict_ip\Functional\RestrictIpAccessTest::testBlacklistedPaths()

File

tests/src/Functional/RestrictIpAccessTest.php, line 149

Class

RestrictIpAccessTest
@group restrict_ip

Namespace

Drupal\Tests\restrict_ip\Functional

Code

public function testBlacklistedPaths() {
  $adminUser = $this
    ->drupalCreateUser([
    'administer restricted ip addresses',
    'access administration pages',
    'administer modules',
  ]);
  $this
    ->drupalLogin($adminUser);
  $this
    ->createArticleContentType();
  $this
    ->createArticle();
  $this
    ->createArticle();
  $this
    ->drupalGet('admin/config/people/restrict_ip');
  $this
    ->assertStatusCodeEquals(200);
  $this
    ->checkCheckbox('#edit-enable');
  $this
    ->selectRadio('#edit-white-black-list-2');
  $this
    ->fillTextValue('edit-page-blacklist', 'node/1');
  $this
    ->click('#edit-submit');
  $this
    ->drupalGet('node/1');
  $this
    ->assertSession()
    ->pageTextContains('The page you are trying to access cannot be accessed from your IP address.');
  $this
    ->drupalGet('node/2');
  $this
    ->assertSession()
    ->pageTextNotContains('The page you are trying to access cannot be accessed from your IP address.');
}