Fix Google oauth2 logging to use %s for strings.

This has more consistent results in Python 2 vs. Python 3.
This commit is contained in:
Tim Abbott
2016-09-13 17:28:43 -07:00
parent 95a348382b
commit 6d8af06e32
2 changed files with 11 additions and 11 deletions

View File

@@ -355,7 +355,7 @@ class GoogleLoginTest(ZulipTestCase):
result = self.google_oauth2_test(token_response, None)
self.assertEquals(result.status_code, 400)
self.assertEquals(m.call_args_list[0][0][0],
"User error converting Google oauth2 login to token: 'Response text'")
"User error converting Google oauth2 login to token: Response text")
def test_google_oauth2_500_token_response(self):
# type: () -> None
@@ -364,7 +364,7 @@ class GoogleLoginTest(ZulipTestCase):
result = self.google_oauth2_test(token_response, None)
self.assertEquals(result.status_code, 400)
self.assertEquals(m.call_args_list[0][0][0],
"Could not convert google oauth2 code to access_token: 'Response text'")
"Could not convert google oauth2 code to access_token: Response text")
def test_google_oauth2_400_account_response(self):
# type: () -> None
@@ -374,7 +374,7 @@ class GoogleLoginTest(ZulipTestCase):
result = self.google_oauth2_test(token_response, account_response)
self.assertEquals(result.status_code, 400)
self.assertEquals(m.call_args_list[0][0][0],
"Google login failed making info API call: 'Response text'")
"Google login failed making info API call: Response text")
def test_google_oauth2_500_account_response(self):
# type: () -> None
@@ -384,7 +384,7 @@ class GoogleLoginTest(ZulipTestCase):
result = self.google_oauth2_test(token_response, account_response)
self.assertEquals(result.status_code, 400)
self.assertEquals(m.call_args_list[0][0][0],
"Google login failed making API call: 'Response text'")
"Google login failed making API call: Response text")
def test_google_oauth2_no_fullname(self):
# type: () -> None
@@ -421,7 +421,7 @@ class GoogleLoginTest(ZulipTestCase):
result = self.client_get("/accounts/login/google/done/?error=some_other_error")
self.assertEquals(result.status_code, 400)
self.assertEquals(m.call_args_list[0][0][0],
"Error from google oauth2 login: u'some_other_error'")
"Error from google oauth2 login: some_other_error")
def test_google_oauth2_missing_csrf(self):
# type: () -> None

View File

@@ -471,7 +471,7 @@ def finish_google_oauth2(request):
if error == 'access_denied':
return redirect('/')
elif error is not None:
logging.warning('Error from google oauth2 login: %r' % (request.GET.get("error"),))
logging.warning('Error from google oauth2 login: %s' % (request.GET.get("error"),))
return HttpResponse(status=400)
csrf_state = request.GET.get('state')
@@ -499,10 +499,10 @@ def finish_google_oauth2(request):
},
)
if resp.status_code == 400:
logging.warning('User error converting Google oauth2 login to token: %r' % (resp.text,))
logging.warning('User error converting Google oauth2 login to token: %s' % (resp.text,))
return HttpResponse(status=400)
elif resp.status_code != 200:
logging.error('Could not convert google oauth2 code to access_token: %r' % (resp.text,))
logging.error('Could not convert google oauth2 code to access_token: %s' % (resp.text,))
return HttpResponse(status=400)
access_token = resp.json()['access_token']
@@ -511,10 +511,10 @@ def finish_google_oauth2(request):
params={'access_token': access_token}
)
if resp.status_code == 400:
logging.warning('Google login failed making info API call: %r' % (resp.text,))
logging.warning('Google login failed making info API call: %s' % (resp.text,))
return HttpResponse(status=400)
elif resp.status_code != 200:
logging.error('Google login failed making API call: %r' % (resp.text,))
logging.error('Google login failed making API call: %s' % (resp.text,))
return HttpResponse(status=400)
body = resp.json()
@@ -529,7 +529,7 @@ def finish_google_oauth2(request):
if email['type'] == 'account':
break
else:
logging.error('Google oauth2 account email not found: %r' % (body,))
logging.error('Google oauth2 account email not found: %s' % (body,))
return HttpResponse(status=400)
email_address = email['value']
user_profile = authenticate(username=email_address, use_dummy_backend=True)