function BotchaSessionReuseAttackTestCase::testBotchaSessionReuseAttackDetectionOnCommentPreview in BOTCHA Spam Prevention 6
Same name and namespace in other branches
- 7 botcha.test \BotchaSessionReuseAttackTestCase::testBotchaSessionReuseAttackDetectionOnCommentPreview()
File
- ./botcha.test, line 886
- Tests for BOTCHA module.
Class
- BotchaSessionReuseAttackTestCase
Code
function testBotchaSessionReuseAttackDetectionOnCommentPreview() {
$node = $this
->createNodeWithCommentsEnabled();
botcha_set_form_id_setting(self::COMMENT_FORM_ID, 'test');
$this
->drupalLogin($this->normal_user);
$this
->drupalGet('comment/reply/' . $node->nid);
$this
->assertBotchaPresence(TRUE);
$form_build_id = $this
->getFormBuildIdFromForm();
$edit = $this
->setCommentFormValues();
$this
->drupalPost(NULL, $edit, t('Preview'));
$this
->assertBotchaResponseAccepted();
$this
->assertBotchaPresence(TRUE);
$edit = $this
->setCommentFormValues();
$edit['form_build_id'] = $form_build_id;
$this
->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));
$this
->assertBotchaSessionIdReuseAttackDetection();
$this
->assertBotchaPresence(TRUE);
$values = $this
->getCommentFormValuesFromForm();
$this
->assertEqual($values['subject'], $edit['subject'], 'Subject should be preserved');
$this
->assertEqual($values['comment'], $edit['comment'], 'Comment body should be preserved');
unset($edit['form_build_id']);
$this
->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));
$this
->assertBotchaResponseAccepted();
$this
->assertBotchaPresence(TRUE);
}