Commit 6b81f43e authored by Dries's avatar Dries
Browse files

- Patch #669456 by boombatower: added support for more HTTP authentication settings in the tests.

parent 949ccddb
......@@ -415,8 +415,9 @@ public function run() {
// HTTP auth settings (<username>:<password>) for the simpletest browser
// when sending requests to the test site.
$username = variable_get('simpletest_username', NULL);
$password = variable_get('simpletest_password', NULL);
$this->httpauth_method = variable_get('simpletest_httpauth_method', CURLAUTH_BASIC);
$username = variable_get('simpletest_httpauth_username', NULL);
$password = variable_get('simpletest_httpauth_password', NULL);
if ($username && $password) {
$this->httpauth_credentials = $username . ':' . $password;
}
......@@ -675,6 +676,11 @@ class DrupalWebTestCase extends DrupalTestCase {
*/
protected $originalUser = NULL;
/**
* HTTP authentication method
*/
protected $httpauth_method = CURLAUTH_BASIC;
/**
* HTTP authentication credentials (<username>:<password>).
*/
......@@ -1305,6 +1311,7 @@ protected function curlInitialize() {
CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
);
if (isset($this->httpauth_credentials)) {
$curl_options[CURLOPT_HTTPAUTH] = $this->httpauth_method;
$curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials;
}
curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
......
......@@ -13,8 +13,9 @@ function simpletest_uninstall() {
simpletest_clean_environment();
// Remove settings variables.
variable_del('simpletest_username');
variable_del('simpletest_password');
variable_del('simpletest_httpauth_method');
variable_del('simpletest_httpauth_username');
variable_del('simpletest_httpauth_password');
variable_del('simpletest_clear_results');
variable_del('simpletest_verbose');
......
......@@ -442,18 +442,33 @@ function simpletest_settings_form($form, &$form_state) {
$form['httpauth'] = array(
'#type' => 'fieldset',
'#title' => t('HTTP authentication credentials'),
'#title' => t('HTTP authentication'),
'#description' => t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['httpauth']['simpletest_username'] = array(
$form['httpauth']['simpletest_httpauth_method'] = array(
'#type' => 'select',
'#title' => t('Method'),
'#options' => array(
CURLAUTH_BASIC => t('Basic'),
CURLAUTH_DIGEST => t('Digest'),
CURLAUTH_GSSNEGOTIATE => t('GSS negotiate'),
CURLAUTH_NTLM => t('NTLM'),
CURLAUTH_ANY => t('Any'),
CURLAUTH_ANYSAFE => t('Any safe'),
),
'#default_value' => variable_get('simpletest_httpauth_method', CURLAUTH_BASIC),
);
$form['httpauth']['simpletest_httpauth_username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => variable_get('simpletest_username', ''),
'#default_value' => variable_get('simpletest_httpauth_username', ''),
);
$form['httpauth']['simpletest_password'] = array(
$form['httpauth']['simpletest_httpauth_password'] = array(
'#type' => 'textfield',
'#title' => t('Password'),
'#default_value' => variable_get('simpletest_password', ''),
'#default_value' => variable_get('simpletest_httpauth_password', ''),
);
return system_settings_form($form);
......
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