Python allauth.account.adapter.DefaultAccountAdapter() Examples
The following are 2
code examples of allauth.account.adapter.DefaultAccountAdapter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
allauth.account.adapter
, or try the search function
.
Example #1
Source File: test_adapter.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
def test_pre_authenticate_fails(self): UserFactory.create(username='john_snow', password='Winteriscoming!') credentials = {'username': 'john_snow', 'password': 'knowsnothing'} request = self.client.get( reverse('account:login'), {'login': 'john_snow', 'password': 'knowsnothing'}) cache_key = all_auth()._get_login_attempts_cache_key( request, **credentials) data = [] dt = timezone.now() data.append(time.mktime(dt.timetuple())) cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT) with pytest.raises(ValidationError): a().pre_authenticate(request, **credentials) # fake a user waiting 2 seconds dt = timezone.now() - timedelta(seconds=2) data.append(time.mktime(dt.timetuple())) cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT) a().pre_authenticate(request, **credentials)
Example #2
Source File: test_adapter.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
def test_pre_authenticate_maxes_out(self): UserFactory.create(username='john_snow', password='Winteriscoming!') credentials = {'username': 'john_snow', 'password': 'knowsnothing'} request = self.client.get( reverse('account:login'), {'login': 'john_snow', 'password': 'knowsnothing'}) cache_key = all_auth()._get_login_attempts_cache_key( request, **credentials) data = [None] * 1000 dt = timezone.now() data.append(time.mktime(dt.timetuple())) cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT) with pytest.raises(ValidationError): a().pre_authenticate(request, **credentials) dt = timezone.now() - timedelta(seconds=ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT) data.append(time.mktime(dt.timetuple())) cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT) a().pre_authenticate(request, **credentials)