diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-09-05 12:33:04 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-09-05 12:33:04 -0700 |
commit | d89da6c42a6e1376949b7ea75ea70ae26de3013f (patch) | |
tree | 75b97f861cff3827adeda54e48a1ca2dc7400dec /modules/simpletest | |
parent | cb8c655a183f1777b9b9b8a0d063b339c0f106ff (diff) | |
download | brdo-d89da6c42a6e1376949b7ea75ea70ae26de3013f.tar.gz brdo-d89da6c42a6e1376949b7ea75ea70ae26de3013f.tar.bz2 |
Issue #799932 by David_Rothstein, Stefan Freudenberg: Fixed Simpletest HTTP authentication credentials should use the 'password' form element.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/simpletest.pages.inc | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/modules/simpletest/simpletest.pages.inc b/modules/simpletest/simpletest.pages.inc index a39e8b792..d2d4a91bc 100644 --- a/modules/simpletest/simpletest.pages.inc +++ b/modules/simpletest/simpletest.pages.inc @@ -428,6 +428,9 @@ function simpletest_result_status_image($status) { /** * Provides settings form for SimpleTest variables. + * + * @ingroup forms + * @see simpletest_settings_form_validate() */ function simpletest_settings_form($form, &$form_state) { $form['general'] = array( @@ -467,16 +470,41 @@ function simpletest_settings_form($form, &$form_state) { ), '#default_value' => variable_get('simpletest_httpauth_method', CURLAUTH_BASIC), ); + $username = variable_get('simpletest_httpauth_username'); + $password = variable_get('simpletest_httpauth_password'); $form['httpauth']['simpletest_httpauth_username'] = array( '#type' => 'textfield', '#title' => t('Username'), - '#default_value' => variable_get('simpletest_httpauth_username', ''), + '#default_value' => $username, ); + if ($username && $password) { + $form['httpauth']['simpletest_httpauth_username']['#description'] = t('Leave this blank to delete both the existing username and password.'); + } $form['httpauth']['simpletest_httpauth_password'] = array( - '#type' => 'textfield', + '#type' => 'password', '#title' => t('Password'), - '#default_value' => variable_get('simpletest_httpauth_password', ''), ); + if ($password) { + $form['httpauth']['simpletest_httpauth_password']['#description'] = t('To change the password, enter the new password here.'); + } return system_settings_form($form); } + +/** + * Validation handler for simpletest_settings_form(). + */ +function simpletest_settings_form_validate($form, &$form_state) { + // If a username was provided but a password wasn't, preserve the existing + // password. + if (!empty($form_state['values']['simpletest_httpauth_username']) && empty($form_state['values']['simpletest_httpauth_password'])) { + $form_state['values']['simpletest_httpauth_password'] = variable_get('simpletest_httpauth_password', ''); + } + + // If a password was provided but a username wasn't, the credentials are + // incorrect, so throw an error. + if (empty($form_state['values']['simpletest_httpauth_username']) && !empty($form_state['values']['simpletest_httpauth_password'])) { + form_set_error('simpletest_httpauth_username', t('HTTP authentication credentials must include a username in addition to a password.')); + } +} + |