function CaptchaSessionReuseAttackTestCase::testCaptchaSessionReuseAttackDetectionOnLoginForm in CAPTCHA 7
Same name and namespace in other branches
- 6.2 captcha.test \CaptchaSessionReuseAttackTestCase::testCaptchaSessionReuseAttackDetectionOnLoginForm()
File
- ./captcha.test, line 1072
- Tests for CAPTCHA module.
Class
- CaptchaSessionReuseAttackTestCase
Code
function testCaptchaSessionReuseAttackDetectionOnLoginForm() {
captcha_set_form_id_setting('user_login', 'captcha/Math');
variable_set('captcha_persistence', CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL_PER_FORM_INSTANCE);
$this
->drupalGet('user');
$this
->assertCaptchaPresence(TRUE);
$captcha_sid = $this
->getCaptchaSidFromForm();
$captcha_token = $this
->getCaptchaTokenFromForm();
$solution = $this
->getMathCaptchaSolutionFromForm();
$edit = array(
'name' => $this->normal_user->name,
'pass' => $this->normal_user->pass_raw,
'captcha_response' => $solution,
);
$this
->drupalPost(NULL, $edit, t('Log in'));
$this
->assertCaptchaResponseAccepted();
$this
->assertCaptchaPresence(FALSE);
$pass = $this
->assertLink(t('Log out'), 0, t('User %name successfully logged in.', array(
'%name' => $this->normal_user->name,
)), t('User login'));
$this
->drupalLogout();
$edit += array(
'captcha_sid' => $captcha_sid,
'captcha_token' => $captcha_token,
);
$this
->drupalPost('user', $edit, t('Log in'));
$this
->assertCaptchaSessionIdReuseAttackDetection();
$this
->assertCaptchaPresence(TRUE);
}