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