Changeset 7300 for main/waeup.sirp/trunk/src/waeup/sirp/browser
- Timestamp:
- 7 Dec 2011, 06:10:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py
r7299 r7300 188 188 ## TestCaptcha 189 189 ## 190 class IdCaptcha(object): 191 """The IdCaptcha allows all solutions that equal a challenge. 192 193 The challenge is a permutation of 'abcdefg'. 190 class StaticCaptcha(object): 191 """The StaticCaptcha always has the same solution: 'the-solution'. 194 192 195 193 It is of no use for real world but for tests. In tests we cannot … … 197 195 works like a real one but is easy to solve even for machines. 198 196 199 It is called IdCaptcha because solutions and challenges for this 200 captcha type are mapped by identitiy function. 197 The HTML form piece generated is even prefilled with the correct 198 solution. So in tests it is not necessary to always 'type' the 199 solution string in the correct field. 200 201 You can, however, fill in a wrong solution and it will be detected 202 as such. 201 203 """ 202 204 grok.implements(ICaptcha) … … 220 222 """Display challenge and input field for solution as HTML. 221 223 """ 222 challenge = list('abcdef')223 random().shuffle(challenge)224 challenge = ''.join(challenge)225 224 html = ( 226 225 u'<input type="hidden" name="challenge"' 227 u' value=" %s" /><br />'226 u' value="the-solution" /><br />' 228 227 u'Type: %s<br />' 229 u'<input type="text" name="solution" /><br />' % (230 challenge, challenge))228 u'<input type="text" name="solution" value="the-solution"' 229 u' /><br />') 231 230 return html 232 231 233 grok.global_utility( IdCaptcha, name=u'Testing captcha')232 grok.global_utility(StaticCaptcha, name=u'Testing captcha') 234 233 235 234
Note: See TracChangeset for help on using the changeset viewer.