You are here

public function BasicAuthTest::testControllerNotCalledBeforeAuth in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php \Drupal\Tests\basic_auth\Functional\BasicAuthTest::testControllerNotCalledBeforeAuth()

Tests if the controller is called before authentication.

See also

https://www.drupal.org/node/2817727

File

core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php, line 248

Class

BasicAuthTest
Tests for BasicAuth authentication provider.

Namespace

Drupal\Tests\basic_auth\Functional

Code

public function testControllerNotCalledBeforeAuth() {
  $this
    ->drupalGet('/basic_auth_test/state/modify');
  $this
    ->assertSession()
    ->statusCodeEquals(401);
  $this
    ->drupalGet('/basic_auth_test/state/read');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertRaw('nope');
  $account = $this
    ->drupalCreateUser();
  $this
    ->basicAuthGet('/basic_auth_test/state/modify', $account
    ->getAccountName(), $account->pass_raw);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertRaw('Done');
  $this->mink
    ->resetSessions();
  $this
    ->drupalGet('/basic_auth_test/state/read');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertRaw('yep');
}