Пример #1
0
def test_login__no_active_session(mocker):
    """
    Scenario: test login when there is no active session

    Given:
     - User has authorization to login
     - There is an active session
    When:
     - User wishes to login using login command
    Then:
     - Result is as expected
    """
    import Zscaler
    mock_header = 'JSESSIONID=MOCK_ID; Path=/; Secure; HttpOnly'
    Zscaler.API_KEY = 'Lcb38EvjtZVc'
    mocker.patch.object(demisto, 'debug')
    mocker.patch.object(Zscaler, 'get_integration_context', return_value={})
    mocker.patch.object(Zscaler, 'test_module')
    mocker.patch.object(Zscaler,
                        'http_request',
                        return_value=ObjectMocker(
                            {'headers': {
                                'Set-Cookie': mock_header
                            }}))
    Zscaler.login()

    assert Zscaler.DEFAULT_HEADERS['cookie'] == 'JSESSIONID=MOCK_ID'
Пример #2
0
def test_login__active_session(mocker):
    """
    Scenario: test login with an active session

    Given:
     - User has authorization to login
     - There is an active session
    When:
     - login is called
    Then:
     - No login request is done
     - Result is as expected
    """
    import Zscaler
    mock_id = 'mock_id'
    mocker.patch.object(demisto, 'debug')
    mocker.patch.object(Zscaler, 'get_integration_context', return_value={Zscaler.SESSION_ID_KEY: mock_id})
    mocker.patch.object(Zscaler, 'test_module')
    Zscaler.login()

    assert Zscaler.DEFAULT_HEADERS['cookie'] == mock_id