def setUp(self): super(SearchViewTest, self).setUp() self.translation = self.component.translation_set.get( language_code='cs' ) self.translate_url = self.translation.get_translate_url() self.update_fulltext_index() reset_rate_limit('search', address='127.0.0.1')
def clean(self): username = self.cleaned_data.get('username') password = self.cleaned_data.get('password') if username and password: if not check_rate_limit(self.request): raise forms.ValidationError( _('Too many authentication attempts!') ) self.user_cache = authenticate( username=username, password=password ) if self.user_cache is None: try: notify_account_activity( try_get_user(username), self.request, 'failed-auth', method='Password', name=username, ) except User.DoesNotExist: pass rotate_token(self.request) raise forms.ValidationError( self.error_messages['invalid_login'], code='invalid_login', ) elif not self.user_cache.is_active: raise forms.ValidationError( self.error_messages['inactive'], code='inactive', ) else: notify_account_activity( self.user_cache, self.request, 'login', method='Password', name=username, ) reset_rate_limit(self.request) return self.cleaned_data
def clean(self): username = self.cleaned_data.get('username') password = self.cleaned_data.get('password') if username and password: if not check_rate_limit('login', self.request): raise forms.ValidationError( _('Too many authentication attempts from this location!') ) self.user_cache = authenticate( self.request, username=username, password=password ) if self.user_cache is None: for user in try_get_user(username, True): notify_account_activity( user, self.request, 'failed-auth', method=ugettext('Password'), name=username, ) rotate_token(self.request) raise forms.ValidationError( self.error_messages['invalid_login'], code='invalid_login', ) elif not self.user_cache.is_active: raise forms.ValidationError( self.error_messages['inactive'], code='inactive', ) else: notify_account_activity( self.user_cache, self.request, 'login', method=ugettext('Password'), name=username, ) reset_rate_limit('login', self.request) return self.cleaned_data
def setUp(self): super(RegistrationTest, self).setUp() reset_rate_limit(address='127.0.0.1')
def setUp(self): super(ViewTest, self).setUp() reset_rate_limit(address='127.0.0.1')
def setUp(self): super(BaseRegistrationTest, self).setUp() reset_rate_limit(address='127.0.0.1')
def setUp(self): # Ensure no rate limits are there reset_rate_limit(address='1.2.3.4') reset_rate_limit(address='7.8.9.0')
def setUp(self): # Ensure no rate limits are there for address in META.values(): reset_rate_limit(address=address)
def setUp(self): super(ViewTest, self).setUp() reset_rate_limit('login', address='127.0.0.1') reset_rate_limit('message', address='127.0.0.1')
def setUp(self): # Ensure no rate limits are there reset_rate_limit('test', address='1.2.3.4')
def setUp(self): super(BaseRegistrationTest, self).setUp() reset_rate_limit('registration', address='127.0.0.1') reset_rate_limit('login', address='127.0.0.1')