Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: appengine/chromium_rietveld/tests/test_auth_utils.py

Issue 2075803002: [Rietveld] Allow whitelisted email accounts to access Rietveld. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Support emails in all domains instead of just App Engine service accounts. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/chromium_rietveld/codereview/views.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_rietveld/tests/test_auth_utils.py
diff --git a/appengine/chromium_rietveld/tests/test_auth_utils.py b/appengine/chromium_rietveld/tests/test_auth_utils.py
index c38f88652b7f2351f596daecd491d5de131e51db..892a584d663e35182e572320f60fdb24e8f5fc23 100755
--- a/appengine/chromium_rietveld/tests/test_auth_utils.py
+++ b/appengine/chromium_rietveld/tests/test_auth_utils.py
@@ -39,6 +39,9 @@ OTHER_CLIENT_IDS = [
'dummy55.apps.googleusercontent.com',
'dummy89.apps.googleusercontent.com',
]
+WHILTELISTED_EMAILS = [
+ 'dummy1@appspot.gserviceaccount.com',
+]
@@ -51,7 +54,7 @@ class TestAuthUtils(TestCase):
self.oauth_login(TEST_EMAIL)
auth_utils.SecretKey.set_config(CLIENT_ID, 'dummy.secret',
- OTHER_CLIENT_IDS)
+ OTHER_CLIENT_IDS, WHILTELISTED_EMAILS)
def tearDown(self):
super(TestAuthUtils, self).tearDown()
@@ -189,6 +192,21 @@ class TestAuthUtils(TestCase):
self.assertTrue(auth_utils.is_current_user_admin())
+ def test_is_current_user_oauth_but_not_whitelisted_email(self):
+ self.cookie_logout()
+ self.oauth_login('not-whitelisted@appspot.gserviceaccount.com',
+ is_admin=False, client_id='anonymous')
+ self.assertIsNone(auth_utils.get_current_rietveld_oauth_user())
+
+ def test_is_current_user_oauth_and_whitelisted_email(self):
+ for email in WHILTELISTED_EMAILS:
+ self.cookie_logout()
+ self.oauth_logout()
+ self.oauth_login(email, is_admin=False, client_id='anonymous')
+ oauth_user = auth_utils.get_current_rietveld_oauth_user()
+ self.assertIsNotNone(oauth_user)
+ self.assertEqual(email, oauth_user.email())
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « appengine/chromium_rietveld/codereview/views.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698