From caa8a3f7fcf99f61ecfaa374f828105d37daeda4 Mon Sep 17 00:00:00 2001 From: Aditya Bansal Date: Mon, 3 Jul 2017 17:09:52 +0530 Subject: [PATCH] Make test_google_oauth2_token_failure() work without internet. --- zerver/tests/test_auth_backends.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index fb83042c7c..dbce2d5474 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -1211,10 +1211,12 @@ class FetchAPIKeyTest(ZulipTestCase): @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.GoogleMobileOauth2Backend',)) def test_google_oauth2_token_failure(self): # type: () -> None - result = self.client_post("/api/v1/fetch_api_key", - dict(username="google-oauth2-token", - password="token")) - self.assert_json_error(result, "Your username or password is incorrect.", 403) + payload = dict(email_verified=False) + with mock.patch('apiclient.sample_tools.client.verify_id_token', return_value=payload): + result = self.client_post("/api/v1/fetch_api_key", + dict(username="google-oauth2-token", + password="token")) + self.assert_json_error(result, "Your username or password is incorrect.", 403) @override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.GoogleMobileOauth2Backend',)) def test_google_oauth2_token_unregistered(self):