def METHOD_NAME(restart_required_logtest_daemons, wait_for_logtest_startup, connect_to_sockets_function,
                        test_case: list):
    '''
    description: Check if 'wazuh-logtest' correctly detects and removes the sessions under pre-defined scenarios.
                 To do this, the session input is sent and the output is received, then it checks if the received data
                 within the logtest socket is the same that the test case expected output.
    wazuh_min_version: 4.2.0
    tier: 0
    parameters:
        - restart_required_logtest_daemons:
            type: fixture
            brief: Wazuh logtests daemons handler.
        - wait_for_logtest_startup:
            type: fixture
            brief: Wait until logtest has begun.
        - connect_to_sockets_function:
            type: fixture
            brief: Function scope version of 'connect_to_sockets' which connects to the specified sockets for the test.
        - test_case:
            type: list
            brief: List of test_case stages. (dicts with input, output and stage keys)
    assertions:
        - Verify that every test case output matches with the actual received.
    input_description: Some test cases are defined in the module. These include some input configurations stored in
                       the 'remove_session.yaml' and the session creation data from the module.
    expected_output:
        - r'Failed test case stage <test_case_index>: .*'
    tags:
        - analysisd
    '''
    stage = test_case[0]
    if stage["stage"] != 'Remove session OK':
        receiver_sockets[0].send(stage['input'], size=True)
        reply = receiver_sockets[0].receive(size=True).rstrip(b'\x00').decode()
        expected = json.loads(stage['output'])
    else:
        session_token = create_session()
        receiver_sockets[0].send(stage['input'].format(session_token), size=True)
        reply = receiver_sockets[0].receive(size=True).rstrip(b'\x00').decode()
        expected = json.loads(stage['output'].format(session_token))
    result = json.loads(reply)
    if 'messages' in expected['data'] and 'messages' in result['data']:
        message_expected = expected['data']['messages'][0]
        message_recieved = result['data']['messages'][0]
        if message_recieved.split(': ')[-1] == message_expected.split(': ')[-1]:
            expected['data']['messages'][0] = result['data']['messages'][0]
    assert expected == result, 'Failed test case stage {}: {}'.format(
        test_case.index(stage) + 1,
        stage['stage'])