Skip to content

Commit

Permalink
Properly test auth_type reauthenticate
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Mar 12, 2014
1 parent fff414e commit ef3bbd7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions allauth/socialaccount/providers/facebook/tests.py
Expand Up @@ -28,6 +28,7 @@
.EmailVerificationMethod.NONE,
SOCIALACCOUNT_PROVIDERS={
'facebook': {
'AUTH_PARAMS': {},
'VERIFIED_EMAIL': False}})
class FacebookTests(create_oauth2_tests(registry.by_id(FacebookProvider.id))):
def get_mocked_response(self):
Expand Down Expand Up @@ -75,6 +76,23 @@ def test_media_js(self):
self.assertTrue("appId: 'app123id'" in script)

def test_login_by_token(self):
resp = self.client.get(reverse('account_login'))
with patch('allauth.socialaccount.providers.facebook.views'
'.requests') as requests_mock:
mocks = [self.get_mocked_response().json()]
requests_mock.get.return_value.json \
= lambda: mocks.pop()
resp = self.client.post(reverse('facebook_login_by_token'),
data={'access_token': 'dummy'})
self.assertEqual('http://testserver/accounts/profile/',
resp['location'])

@override_settings(
SOCIALACCOUNT_PROVIDERS={
'facebook': {
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'VERIFIED_EMAIL': False}})
def test_login_by_token_reauthenticate(self):
resp = self.client.get(reverse('account_login'))
nonce = json.loads(resp.context['fb_login_options'])['auth_nonce']
with patch('allauth.socialaccount.providers.facebook.views'
Expand Down

0 comments on commit ef3bbd7

Please sign in to comment.