SecureSiteDigestGuestUnsetTest.php in Secure Site 8
File
src/Tests/DigestAuth/SecureSiteDigestGuestUnsetTest.php
View source
<?php
namespace Drupal\securesite\Tests\DigestAuth;
use Drupal\simpletest\WebTestBase;
class SecureSiteDigestGuestUnsetTest extends WebTestBase {
public static $modules = array(
'securesite',
);
public static function getInfo() {
return array(
'name' => t('Digest authentication: Guest credentials unset'),
'description' => t('Test HTTP digest authentication with guest credentials unset. Digest scripts must be configured on the live site before these tests can be run.'),
'group' => t('Secure Site'),
);
}
function setUp() {
parent::setUp();
_securesite_copy_script_config($this);
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
'access secured pages',
));
$config = \Drupal::config('securesite.settings');
$config
->set('securesite_enabled', SECURESITE_ALWAYS);
$config
->set('securesite_type', array(
SECURESITE_FORM,
SECURESITE_BASIC,
SECURESITE_DIGEST,
));
$config
->save();
$this->curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
}
function testSecureSiteTypeDigestGuestUnsetEmpty() {
$this->curl_options[CURLOPT_USERPWD] = ':';
$this
->drupalHead(NULL);
$this
->assertResponse(200, t('Requesting home page with empty credentials.'));
$this
->assertFalse($this
->drupalGetHeader('Authentication-Info'), t('Checking digest authentication bypass for empty guest credentials.'));
}
function testSecureSiteTypeDigestGuestUnsetRandom() {
$this->curl_options[CURLOPT_USERPWD] = $this
->randomName() . ':' . user_password();
$this
->drupalHead(NULL);
$this
->assertResponse(200, t('Requesting home page with random credentials.'));
$this
->assertFalse($this
->drupalGetHeader('Authentication-Info'), t('Checking digest authentication bypass for random guest credentials.'));
}
}