You are here

public function CaptchaSessionReuseAttackTestCase::testMultipleCaptchaProtectedFormsOnOnePage in CAPTCHA 6.2

Same name and namespace in other branches
  1. 7 captcha.test \CaptchaSessionReuseAttackTestCase::testMultipleCaptchaProtectedFormsOnOnePage()

File

./captcha.test, line 1108
Tests for CAPTCHA module.

Class

CaptchaSessionReuseAttackTestCase

Code

public function testMultipleCaptchaProtectedFormsOnOnePage() {

  // Set Test CAPTCHA on comment form and login block
  captcha_set_form_id_setting(self::COMMENT_FORM_ID, 'captcha/Test');
  captcha_set_form_id_setting('user_login_block', 'captcha/Math');
  $this
    ->allowCommentPostingForAnonymousVisitors();

  // Create a node with comments enabled.
  $node = $this
    ->createNodeWithCommentsEnabled();

  // Preview comment with correct CAPTCHA answer.
  $edit = $this
    ->getCommentFormValues();
  $comment_subject = $edit['subject'];
  $edit['captcha_response'] = 'Test 123';
  $this
    ->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));

  // Post should be accepted: no warnings,
  // no CAPTCHA reuse detection (which could be used by user log in block).
  $this
    ->assertCaptchaResponseAccepted();
  $this
    ->assertText($comment_subject);
}