[git_cl] Default to SSO with missing email

This is a safer default if SSO is available

Bug: b/351071334
Change-Id: I2d6b3b5c0fbe3fb7b9783de3d7548be7f14d7391
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5723448
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
changes/48/5723448/7
Allen Li 9 months ago committed by LUCI CQ
parent c1aaf922b6
commit 397bf12548

@ -183,6 +183,10 @@ def ShouldUseSSO(host: str, email: str) -> bool:
if not ssoHelper.find_cmd():
LOGGER.debug("SSO=False: no SSO command")
return False
if not email:
LOGGER.debug(
"SSO=True: email is empty or missing (and SSO command available)")
return True
if email.endswith('@google.com'):
LOGGER.debug("SSO=True: email is google.com")
return True

@ -744,7 +744,10 @@ class ShouldUseSSOTest(unittest.TestCase):
self.assertFalse(
gerrit_util.ShouldUseSSO('fake-host', 'firefly@google.com'))
def testGoogle(self):
def testEmptyEmail(self):
self.assertTrue(gerrit_util.ShouldUseSSO('fake-host', ''))
def testGoogleEmail(self):
self.assertTrue(
gerrit_util.ShouldUseSSO('fake-host', 'firefly@google.com'))

Loading…
Cancel
Save