@ -20,6 +20,15 @@ EXPECTED_BASE_HEADERS = {
class FakeCheckpointHttpApiPlugin ( HttpApi ) :
class FakeCheckpointHttpApiPlugin ( HttpApi ) :
def __init__ ( self , conn ) :
def __init__ ( self , conn ) :
super ( FakeCheckpointHttpApiPlugin , self ) . __init__ ( conn )
super ( FakeCheckpointHttpApiPlugin , self ) . __init__ ( conn )
self . hostvars = {
' domain ' : None
}
def get_option ( self , var ) :
return self . hostvars [ var ]
def set_option ( self , var , val ) :
self . hostvars [ var ] = val
class TestCheckpointHttpApi ( unittest . TestCase ) :
class TestCheckpointHttpApi ( unittest . TestCase ) :
@ -52,6 +61,19 @@ class TestCheckpointHttpApi(unittest.TestCase):
assert resp == ( 500 , { ' errorMessage ' : ' ERROR ' } )
assert resp == ( 500 , { ' errorMessage ' : ' ERROR ' } )
def test_login_to_global_domain ( self ) :
temp_domain = self . checkpoint_plugin . hostvars [ ' domain ' ]
self . checkpoint_plugin . hostvars [ ' domain ' ] = ' test_domain '
self . connection_mock . send . return_value = self . _connection_response (
{ ' sid ' : ' SID ' , ' uid ' : ' UID ' }
)
self . checkpoint_plugin . login ( ' USERNAME ' , ' PASSWORD ' )
self . connection_mock . send . assert_called_once_with ( ' /web_api/login ' , mock . ANY , headers = mock . ANY ,
method = mock . ANY )
self . checkpoint_plugin . hostvars [ ' domain ' ] = temp_domain
@staticmethod
@staticmethod
def _connection_response ( response , status = 200 ) :
def _connection_response ( response , status = 200 ) :
response_mock = mock . Mock ( )
response_mock = mock . Mock ( )