You are here

function SecureSiteDigestGuestSetTest::setUp in Secure Site 8

Implements setUp().

Overrides WebTestBase::setUp

File

src/Tests/DigestAuth/SecureSiteDigestGuestSetTest.php, line 40
Contains Drupal\securesite\Tests\DigestAuth\SecureSiteDigestGuestSetTest

Class

SecureSiteDigestGuestSetTest
Functional tests for digest authentication with guest credentials set.

Namespace

Drupal\securesite\Tests\DigestAuth

Code

function setUp() {
  parent::setUp();

  //todo wtf is this function?
  _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);

  // Should work with all authentication methods enabled.
  $config
    ->set('securesite_type', array(
    SECURESITE_FORM,
    SECURESITE_BASIC,
    SECURESITE_DIGEST,
  ));
  $config
    ->save();

  //todo curl options
  $this->curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;

  // Store guest credentials.
  $this->user = $this
    ->drupalCreateUser(array(
    'administer site configuration',
    'access secured pages',
  ));
  $this->curl_options[CURLOPT_USERPWD] = $this->user->name . ':' . $this->user->pass_raw;
  $this->guest_name = $this
    ->randomName();
  $this->guest_pass = user_password();
  $this
    ->drupalPostForm('admin/settings/securesite', array(
    'securesite_guest_name' => $this->guest_name,
    'securesite_guest_pass' => $this->guest_pass,
    'securesite_type[' . SECURESITE_DIGEST . ']' => TRUE,
  ), 'Save configuration');
  $this
    ->curlClose();
}