SecureLoginTestConfig.php in Secure Login 8
File
tests/src/Functional/SecureLoginTestConfig.php
View source
<?php
namespace Drupal\Tests\securelogin\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class SecureLoginTestConfig extends SecureLoginTestBase {
use StringTranslationTrait;
protected function setUp() {
parent::setUp();
if (!$this->isSecure) {
$this
->config('securelogin.settings')
->set('base_url', 'https://example.org')
->save();
return;
}
$web_user = $this
->drupalCreateUser([
'administer site configuration',
]);
$this
->drupalLogin($web_user);
$this
->drupalGet('admin/config/people/securelogin');
$fields['base_url'] = 'https://example.org';
$this
->submitForm($fields, $this
->t('Save configuration'));
}
public function testSecureLoginBaseUrl() {
if (method_exists($this
->getSession()
->getDriver(), 'getClient')) {
$this
->getSession()
->getDriver()
->getClient()
->followRedirects(FALSE);
}
$maximumMetaRefreshCount = $this->maximumMetaRefreshCount;
$this->maximumMetaRefreshCount = 0;
$this
->drupalGet($this
->httpUrl('user/login'));
$this
->assertSession()
->statusCodeEquals(301);
$this
->assertSame(0, strpos($this
->getSession()
->getResponseHeader('Location'), 'https://example.org/user/login'), 'Location header uses the configured secure base URL.');
if (method_exists($this
->getSession()
->getDriver(), 'getClient')) {
$this
->getSession()
->getDriver()
->getClient()
->followRedirects(TRUE);
}
$this->maximumMetaRefreshCount = $maximumMetaRefreshCount;
}
}