@ -752,23 +752,33 @@ class ShouldUseSSOTest(unittest.TestCase):
@mock.patch ( ' newauth.Enabled ' , return_value = False )
def testDisabled ( self , _ ) :
self . assertFalse (
gerrit_util . ShouldUseSSO ( ' fake-host ' , ' firefly@google.com ' ) )
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' ,
' firefly@google.com ' ) )
@mock.patch ( ' gerrit_util.ssoHelper.find_cmd ' , return_value = ' ' )
def testMissingCommand ( self , _ ) :
self . assertFalse (
gerrit_util . ShouldUseSSO ( ' fake-host ' , ' firefly@google.com ' ) )
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' ,
' firefly@google.com ' ) )
def testBadHost ( self ) :
self . assertFalse (
gerrit_util . ShouldUseSSO ( ' fake-host.coreboot.org ' ,
' firefly@google.com ' ) )
def testEmptyEmail ( self ) :
self . assertTrue ( gerrit_util . ShouldUseSSO ( ' fake-host ' , ' ' ) )
self . assertTrue (
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' , ' ' ) )
def testGoogleEmail ( self ) :
self . assertTrue (
gerrit_util . ShouldUseSSO ( ' fake-host ' , ' firefly@google.com ' ) )
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' ,
' firefly@google.com ' ) )
def testGmail ( self ) :
self . assertFalse (
gerrit_util . ShouldUseSSO ( ' fake-host ' , ' firefly@gmail.com ' ) )
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' ,
' firefly@gmail.com ' ) )
@mock.patch ( ' gerrit_util.GetAccountEmails ' ,
return_value = [ {
@ -776,8 +786,11 @@ class ShouldUseSSOTest(unittest.TestCase):
} ] )
def testLinkedChromium ( self , email ) :
self . assertTrue (
gerrit_util . ShouldUseSSO ( ' fake-host ' , ' firefly@chromium.org ' ) )
email . assert_called_with ( ' fake-host ' , ' self ' , authenticator = mock . ANY )
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' ,
' firefly@chromium.org ' ) )
email . assert_called_with ( ' fake-host.googlesource.com ' ,
' self ' ,
authenticator = mock . ANY )
@mock.patch ( ' gerrit_util.GetAccountEmails ' ,
return_value = [ {
@ -785,8 +798,11 @@ class ShouldUseSSOTest(unittest.TestCase):
} ] )
def testUnlinkedChromium ( self , email ) :
self . assertFalse (
gerrit_util . ShouldUseSSO ( ' fake-host ' , ' firefly@chromium.org ' ) )
email . assert_called_with ( ' fake-host ' , ' self ' , authenticator = mock . ANY )
gerrit_util . ShouldUseSSO ( ' fake-host.googlesource.com ' ,
' firefly@chromium.org ' ) )
email . assert_called_with ( ' fake-host.googlesource.com ' ,
' self ' ,
authenticator = mock . ANY )
if __name__ == ' __main__ ' :