Commit df6519aa authored by webchick's avatar webchick
Browse files

Issue #2479515 by znerol: Use BasicAuthTestTrait in BasicAuthTest

parent bab62ec6
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url;
use Drupal\basic_auth\Tests\BasicAuthTestTrait;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
......@@ -19,6 +20,8 @@
*/
class BasicAuthTest extends WebTestBase {
use BasicAuthTestTrait;
/**
* Modules installed for all tests.
*
......@@ -177,41 +180,4 @@ function testUnauthorizedErrorMessage() {
$this->assertText('Access denied', "A user friendly access denied message is displayed");
}
/**
* Does HTTP basic auth request.
*
* We do not use \Drupal\simpletest\WebTestBase::drupalGet because we need to
* set curl settings for basic authentication.
*
* @param \Drupal\Core\Url|string $path
* Drupal path or URL to load into internal browser
* @param string $username
* The user name to authenticate with.
* @param string $password
* The password.
*
* @return string
* Curl output.
*/
protected function basicAuthGet($path, $username, $password) {
if ($path instanceof Url) {
$path = $path->setAbsolute()->toString();
}
$out = $this->curlExec(
array(
CURLOPT_HTTPGET => TRUE,
CURLOPT_URL => $path,
CURLOPT_NOBODY => FALSE,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $username . ':' . $password,
)
);
$this->verbose('GET request to: ' . $path .
'<hr />' . $out);
return $out;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment