You are here

public function ShieldTest::testAuthMessage in Shield 8

Validate the authentication message reflects.

Throws

\Behat\Mink\Exception\ExpectationException

File

tests/src/Functional/ShieldTest.php, line 75

Class

ShieldTest
Tests Shield module.

Namespace

Drupal\Tests\shield\Functional

Code

public function testAuthMessage() {

  // Configure shield so it is enabled.
  $this
    ->config('shield.settings')
    ->set('shield_enable', TRUE)
    ->save();

  // Assert the prompted message is the configured one.
  $this
    ->drupalGet('user');
  $this
    ->assertSession()
    ->responseHeaderContains('WWW-Authenticate', 'Basic realm="Hello world!"');

  // Update the shield message.
  $this
    ->config('shield.settings')
    ->set('print', 'Hello entire world!')
    ->save();

  // Assert the prompted message is the update one.
  $this
    ->drupalGet('user');
  $this
    ->assertSession()
    ->responseHeaderContains('WWW-Authenticate', 'Basic realm="Hello entire world!"');
}