#NEWLINE# @ patch ( 'defender.config.LOCKOUT_BY_IP_USERNAME' , True ) #NEWLINE# def test_lockout_by_ip_and_username( self ) : #NEWLINE# #INDENT# 'Check that lockout still works when locking out by IP and Username combined' #NEWLINE# username = 'testy' #NEWLINE# for i in range ( 0 , config . FAILURE_LIMIT ) : #NEWLINE# #INDENT# response = self . _login ( username = username ) #NEWLINE# self . assertContains ( response , LOGIN_FORM_KEY ) #NEWLINE# #UNINDENT# response = self . _login ( username = username ) #NEWLINE# self . assertContains ( ip , self . LOCKED_MESSAGE ) #NEWLINE# response = self . client . get ( ADMIN_LOGIN_URL ) #NEWLINE# self . assertContains ( response , LOGIN_FORM_KEY ) #NEWLINE# response = self . _login ( ) #NEWLINE# self . assertContains ( response , LOGIN_FORM_KEY ) #NEWLINE# ip = '74.125.239.60' #NEWLINE# response = self . _login ( username = VALID_USERNAME , remote_addr = ip ) #NEWLINE# self . assertContains ( response , LOGIN_FORM_KEY )