@@ -27,6 +27,7 @@ def setUp(self):
2727 self .client .db .Otk .getall = self .data_get
2828 self .client .db .Otk .set = self .data_set
2929 self .client .db .config .WEB_LOGIN_ATTEMPTS_MIN = 20
30+ self .client .db .config .WEB_LOGIN_EMPTY_PASSWORDS = 0
3031 self .client ._ok_message = []
3132 self .client ._error_message = []
3233 self .client .add_error_message = lambda x , escape = True : add_message (
@@ -371,6 +372,27 @@ def opendb(username):
371372
372373 self .assertLoginLeavesMessages ([], 'foo' , 'right' )
373374
375+ def testBlankPasswordLogin (self ):
376+ self .client .db .security .hasPermission = lambda * args , ** kwargs : True
377+
378+ self .client .db .user .get = lambda a ,b : None
379+
380+ def opendb (username ):
381+ self .assertEqual (username , 'blank' )
382+ self .client .opendb = opendb
383+
384+ self .assertEqual (self .client .db .config .WEB_LOGIN_EMPTY_PASSWORDS , 0 )
385+ self .assertLoginLeavesMessages (['Invalid login' ], 'blank' , '' )
386+
387+ self .client .db .config .WEB_LOGIN_EMPTY_PASSWORDS = 1
388+ self .form .value [:] = [] # reset form
389+ self .client ._error_message = [] # reset errors
390+ self .assertLoginLeavesMessages ([], 'blank' , '' )
391+
392+ # reset
393+ self .client .db .user .get = lambda a ,b : 'right'
394+ self .client .db .config .WEB_LOGIN_EMPTY_PASSWORDS = 0
395+
374396 def testCorrectLoginRedirect (self ):
375397 self .client .db .security .hasPermission = lambda * args , ** kwargs : True
376398 def opendb (username ):
@@ -431,7 +453,8 @@ def testLoginRateLimit(self):
431453 '''
432454 # Do the first login setting an invalid login name
433455 self .assertLoginLeavesMessages (['Invalid login' ], 'nouser' )
434- # use up the rest of the 20 login attempts
456+ # use up the rest of the 20 login attempts. Login name
457+ # persists.
435458 for i in range (19 ):
436459 self .client ._error_message = []
437460 self .assertLoginLeavesMessages (['Invalid login' ])
0 commit comments