diff --git a/gerrit_util.py b/gerrit_util.py index c09c331b65..8fafa8a569 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -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 diff --git a/tests/gerrit_util_test.py b/tests/gerrit_util_test.py index 113257a5ff..4d7629f176 100755 --- a/tests/gerrit_util_test.py +++ b/tests/gerrit_util_test.py @@ -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'))