Chris@0: getRawContent(). Chris@0: */ Chris@0: protected function basicAuthGet($path, $username, $password, array $options = []) { Chris@0: return $this->drupalGet($path, $options, $this->getBasicAuthHeaders($username, $password)); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Executes a form submission using basic authentication. Chris@0: * Chris@0: * @param string $path Chris@0: * Location of the post form. Chris@0: * @param array $edit Chris@0: * Field data in an associative array. Chris@0: * @param string $submit Chris@0: * Value of the submit button whose click is to be emulated. Chris@0: * @param string $username Chris@0: * The username to use for basic authentication. Chris@0: * @param string $password Chris@0: * The password to use for basic authentication. Chris@0: * @param array $options Chris@0: * Options to be forwarded to the url generator. Chris@0: * @param string $form_html_id Chris@0: * (optional) HTML ID of the form to be submitted. Chris@0: * @param string $extra_post Chris@0: * (optional) A string of additional data to append to the POST submission. Chris@0: * Chris@0: * @return string Chris@0: * The retrieved HTML string. Chris@0: * Chris@0: * @see \Drupal\simpletest\WebTestBase::drupalPostForm() Chris@0: */ Chris@0: protected function basicAuthPostForm($path, $edit, $submit, $username, $password, array $options = [], $form_html_id = NULL, $extra_post = NULL) { Chris@0: return $this->drupalPostForm($path, $edit, $submit, $options, $this->getBasicAuthHeaders($username, $password), $form_html_id, $extra_post); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns HTTP headers that can be used for basic authentication in Curl. Chris@0: * Chris@0: * @param string $username Chris@0: * The username to use for basic authentication. Chris@0: * @param string $password Chris@0: * The password to use for basic authentication. Chris@0: * Chris@0: * @return array Chris@0: * An array of raw request headers as used by curl_setopt(). Chris@0: */ Chris@0: protected function getBasicAuthHeaders($username, $password) { Chris@0: // Set up Curl to use basic authentication with the test user's credentials. Chris@0: return ['Authorization: Basic ' . base64_encode("$username:$password")]; Chris@0: } Chris@0: Chris@0: }