| | 41 | response = self.publish(path, extra=extra, request_method='GET').getBody() |
|---|
| | 42 | patt = re.compile(".*?Your\+comment\+awaits\+moderation") |
|---|
| | 43 | match_obj = patt.match(response) |
|---|
| | 44 | self.assert_(match_obj) |
|---|
| | 45 | |
|---|
| | 46 | def test_editform_with_wrong_captcha(self): |
|---|
| | 47 | parameters = 'form.submitted=1&Creator=test_user&key=cat' |
|---|
| | 48 | path = '%s/discussion_reply_form?%s'%(self.absolute_url, parameters) |
|---|
| | 49 | extra = { |
|---|
| | 50 | 'evalkey':'1153994494.48', |
|---|
| | 51 | 'hashkey': 'AE89E6D9461FD8A28EAF5C35FA15047F', |
|---|
| | 52 | 'subject': 'testing', |
|---|
| | 53 | 'body_text': 'Text in Comment', |
|---|
| | 54 | 'discussion_reply:method': 'Save'} |
|---|
| | 55 | |
|---|
| | 56 | response = self.publish(path, extra=extra, request_method='GET').getBody() |
|---|
| | 57 | patt = re.compile("Please re enter validation code") |
|---|
| | 58 | match_obj = patt.search(response) |
|---|
| | 59 | |
|---|
| | 60 | self.assert_(match_obj) |
|---|
| | 61 | |
|---|
| | 62 | def test_editform_with_empty_key(self): |
|---|
| | 63 | parameters = 'form.submitted=1&Creator=test_user' |
|---|
| | 64 | path = '%s/discussion_reply_form?%s'%(self.absolute_url, parameters) |
|---|
| | 65 | extra = { |
|---|
| | 66 | 'evalkey':'1153994494.48', |
|---|
| | 67 | 'hashkey': 'AE89E6D9461FD8A28EAF5C35FA15047F', |
|---|
| | 68 | 'subject': 'testing', |
|---|
| | 69 | 'body_text': 'Text in Comment', |
|---|
| | 70 | 'discussion_reply:method': 'Save'} |
|---|
| | 71 | |
|---|
| | 72 | response = self.publish(path, extra=extra, request_method='GET').getBody() |
|---|
| | 73 | patt = re.compile("Please re enter validation code") |
|---|
| | 74 | match_obj = patt.search(response) |
|---|
| | 75 | |
|---|
| | 76 | self.assert_(match_obj) |
|---|
| | 77 | |
|---|
| | 78 | class TestQPlonePILCaptchas(PloneTestCase.FunctionalTestCase): |
|---|
| | 79 | |
|---|
| | 80 | def afterSetUp(self): |
|---|
| | 81 | self.addProduct('qPloneComments') |
|---|
| | 82 | self.addProduct('qPloneCaptchas') |
|---|
| | 83 | self.loginAsPortalOwner() |
|---|
| | 84 | self.portal.portal_properties['qPloneCaptchas'].current_lib = 'PIL' |
|---|
| | 85 | self.portal.invokeFactory('Document', 'index_html') |
|---|
| | 86 | self.portal['index_html'].allow_discussion = True |
|---|
| | 87 | self.absolute_url = self.portal['index_html'].absolute_url_path() |
|---|
| | 88 | |
|---|
| | 89 | def test_editform_with_right_captcha(self): |
|---|
| | 90 | parameters = 'form.submitted=1&Creator=test_user&key=man' |
|---|
| | 91 | path = '%s/discussion_reply_form?%s'%(self.absolute_url, parameters) |
|---|
| | 92 | extra = { |
|---|
| | 93 | 'evalkey':'1153996082.6', |
|---|
| | 94 | 'hashkey': '8545A37C98C09756B24626430812B807', |
|---|
| | 95 | 'subject': 'testing', |
|---|
| | 96 | 'body_text': 'Text in Comment', |
|---|
| | 97 | 'discussion_reply:method': 'Save'} |
|---|
| | 98 | |
|---|
| | 99 | response = self.publish(path, extra=extra, request_method='GET').getBody() |
|---|
| | 100 | patt = re.compile(".*?Your\+comment\+awaits\+moderation") |
|---|
| | 101 | match_obj = patt.match(response) |
|---|
| | 102 | self.assert_(match_obj) |
|---|
| | 103 | |
|---|
| | 104 | def test_editform_with_wrong_captcha(self): |
|---|
| | 105 | parameters = 'form.submitted=1&Creator=test_user&key=cat' |
|---|
| | 106 | path = '%s/discussion_reply_form?%s'%(self.absolute_url, parameters) |
|---|
| | 107 | extra = { |
|---|
| | 108 | 'evalkey':'1153996082.6', |
|---|
| | 109 | 'hashkey': '8545A37C98C09756B24626430812B807', |
|---|
| | 110 | 'subject': 'testing', |
|---|
| | 111 | 'body_text': 'Text in Comment', |
|---|
| | 112 | 'discussion_reply:method': 'Save'} |
|---|
| | 113 | |
|---|
| | 114 | response = self.publish(path, extra=extra, request_method='GET').getBody() |
|---|
| | 115 | patt = re.compile("Please re enter validation code") |
|---|
| | 116 | match_obj = patt.search(response) |
|---|
| | 117 | |
|---|
| | 118 | self.assert_(match_obj) |
|---|
| | 119 | |
|---|
| | 120 | def test_editform_with_empty_key(self): |
|---|
| | 121 | parameters = 'form.submitted=1&Creator=test_user' |
|---|
| | 122 | path = '%s/discussion_reply_form?%s'%(self.absolute_url, parameters) |
|---|
| | 123 | extra = { |
|---|
| | 124 | 'evalkey':'1153996082.6', |
|---|
| | 125 | 'hashkey': '8545A37C98C09756B24626430812B807', |
|---|
| | 126 | 'subject': 'testing', |
|---|
| | 127 | 'body_text': 'Text in Comment', |
|---|
| | 128 | 'discussion_reply:method': 'Save'} |
|---|
| | 129 | |
|---|
| | 130 | response = self.publish(path, extra=extra, request_method='GET').getBody() |
|---|
| | 131 | patt = re.compile("Please re enter validation code") |
|---|
| | 132 | match_obj = patt.search(response) |
|---|
| | 133 | |
|---|
| | 134 | self.assert_(match_obj) |
|---|