Add Google OAuth2 backend tests.

This commit is contained in:
Umair Khan
2016-10-26 15:35:57 +05:00
committed by Tim Abbott
parent 088d8eebad
commit 6dbe425675

View File

@@ -6,6 +6,7 @@ from django_auth_ldap.backend import _LDAPUser
from django.test.client import RequestFactory from django.test.client import RequestFactory
from typing import Any, Callable, Dict from typing import Any, Callable, Dict
from builtins import object from builtins import object
from oauth2client.crypt import AppIdentityError
import jwt import jwt
import mock import mock
@@ -177,6 +178,11 @@ class AuthBackendTest(TestCase):
result = backend.authenticate(return_data=ret) result = backend.authenticate(return_data=ret)
self.assertIsNone(result) self.assertIsNone(result)
self.assertTrue(ret["valid_attestation"]) self.assertTrue(ret["valid_attestation"])
with mock.patch('apiclient.sample_tools.client.verify_id_token',
side_effect=AppIdentityError):
ret = dict()
result = backend.authenticate(return_data=ret)
self.assertIsNone(result)
def test_ldap_backend(self): def test_ldap_backend(self):
# type: () -> None # type: () -> None