示例#1
0
def test_list_members_command(args, response, expected_result, mocker):
    """
    Given:
      - a group ID with less than 100 members.
      - a group ID with more than 100 members.
    When:
      - calling list_members_command.
    Then:
      - ensure the command results are as expected (Members are found and MembersNextLink is shown when there are more
      than 100 members.
    """
    client = MsGraphClient(base_url='https://graph.microsoft.com/v1.0',
                           tenant_id='tenant-id',
                           auth_id='auth_and_token_url',
                           enc_key='enc_key',
                           app_name='ms-graph-groups',
                           verify='use_ssl',
                           proxy='proxies',
                           self_deployed='self_deployed',
                           handle_error=False)
    mocker.patch.object(client.ms_client,
                        'http_request',
                        return_value=response)
    mocker.patch.object(demisto, 'dt', return_value=RESPONSE_GET_GROUP)
    result = list_members_command(client, args)
    if args.get('group_id') == 'under100':
        assert 'MembersNextLink' not in result[1][
            'MSGraphGroups(val.ID === obj.ID)']
    else:  # above 100
        assert 'MembersNextLink' in result[1][
            'MSGraphGroups(val.ID === obj.ID)']

    assert expected_result == result[1]['MSGraphGroups(val.ID === obj.ID)'][
        'Members']  # entry context is found in the 2nd place in the result of the command
示例#2
0
def test_commands(command, args, response, expected_result, mocker):
    client = MsGraphClient(base_url='https://graph.microsoft.com/v1.0', tenant_id='tenant-id',
                           auth_id='auth_and_token_url', enc_key='enc_key', app_name='ms-graph-groups',
                           verify='use_ssl', proxy='proxies', self_deployed='self_deployed')
    mocker.patch.object(client.ms_client, 'http_request', return_value=response)
    result = command(client, args)
    assert expected_result == result[1]  # entry context is found in the 2nd place in the result of the command
示例#3
0
def test_suppress_errors(mocker, fun, mock_fun, mock_value, args,
                         expected_result):

    client = MsGraphClient(base_url='https://graph.microsoft.com/v1.0',
                           tenant_id='tenant-id',
                           auth_id='auth_and_token_url',
                           enc_key='enc_key',
                           app_name='ms-graph-groups',
                           verify='use_ssl',
                           proxy='proxies',
                           self_deployed='self_deployed',
                           handle_error=True)
    mocker.patch.object(client, mock_fun, side_effect=mock_value)
    results, _, _ = fun(client, args)
    assert results == expected_result