Ejemplo n.º 1
0
static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
{
  g_debug ("test-dribblemode:%s", G_STRFUNC);

  init_test (lagent, ragent, FALSE);

  nice_agent_set_remote_credentials (lagent, global_ls_id,
                                     "wrong", "wrong");
  nice_agent_set_remote_credentials (ragent, global_rs_id,
                                     "wrong2", "wrong2");

  nice_agent_gather_candidates (lagent, global_ls_id);
  while (!got_stun_packet)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
            !lagent_candidate_gathering_done);

  nice_agent_gather_candidates (ragent, global_rs_id);
  while (!ragent_candidate_gathering_done)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);
  g_assert (ragent_candidate_gathering_done);

  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   FALSE);
  while (global_lagent_state != NICE_COMPONENT_STATE_FAILED)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  // Set the correct credentials and swap candidates
  set_credentials (lagent, global_ls_id, ragent, global_rs_id);
  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   FALSE);

  swap_candidates (lagent, global_ls_id,
                   ragent, global_rs_id,
                   FALSE);

  while (!data_received)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (data_received);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);
  g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);

  // Wait for lagent to finish gathering candidates
  while (!lagent_candidate_gathering_done)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (lagent_candidate_gathering_done);

  cleanup (lagent, ragent);
}
Ejemplo n.º 2
0
static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
{
  NiceCandidate *cand =  NULL;

  g_debug ("test-dribblemode:%s", G_STRFUNC);

  init_test (lagent, ragent, FALSE);

  nice_agent_gather_candidates (lagent, global_ls_id);
  while (!got_stun_packet)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
            !lagent_candidate_gathering_done);

  nice_agent_gather_candidates (ragent, global_rs_id);
  while (!ragent_candidate_gathering_done)
      g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (ragent_candidate_gathering_done);

  add_bad_candidate (lagent, global_ls_id, cand);

  // lagent will finish candidate gathering causing this mainloop to quit
  while (!lagent_candidate_gathering_done)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  // connchecks will fail causing this mainloop to quit
  while (global_lagent_state != NICE_COMPONENT_STATE_FAILED)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (global_lagent_state == NICE_COMPONENT_STATE_FAILED &&
            !data_received);
  set_credentials (lagent, global_ls_id, ragent, global_rs_id);

  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   FALSE);

  swap_candidates (lagent, global_ls_id,
                   ragent, global_rs_id,
                   FALSE);

  while (!data_received)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (lagent_candidate_gathering_done);

  g_assert (global_lagent_state >= NICE_COMPONENT_STATE_CONNECTED);
  g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);

  cleanup (lagent, ragent);
}
Ejemplo n.º 3
0
static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
{
  g_debug ("test-dribblemode:%s", G_STRFUNC);

  init_test (lagent, ragent, FALSE);

  nice_agent_set_remote_credentials (lagent, global_ls_id,
                                     "wrong", "wrong");
  nice_agent_set_remote_credentials (ragent, global_rs_id,
                                     "wrong2", "wrong2");

  nice_agent_gather_candidates (lagent, global_ls_id);
  g_main_loop_run (global_mainloop);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
            !lagent_candidate_gathering_done);

  nice_agent_gather_candidates (ragent, global_rs_id);
  if (!ragent_candidate_gathering_done) {
    g_main_loop_run (global_mainloop);
    g_assert (ragent_candidate_gathering_done);
  }

  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   FALSE);
  g_main_loop_run (global_mainloop);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_FAILED);

  // Set the correct credentials and swap candidates
  set_credentials (lagent, global_ls_id, ragent, global_rs_id);
  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   FALSE);

  swap_candidates (lagent, global_ls_id,
                   ragent, global_rs_id,
                   FALSE);

  g_main_loop_run (global_mainloop);

  g_assert (data_received);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);
  g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);

  // Wait for lagent to finish gathering candidates
  g_main_loop_run (global_mainloop);
  g_assert (lagent_candidate_gathering_done);

  cleanup (lagent, ragent);
}
Ejemplo n.º 4
0
static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
{
  g_debug ("test-dribblemode:%s", G_STRFUNC);

  got_stun_packet = FALSE;
  init_test (lagent, ragent, FALSE);

  nice_agent_gather_candidates (lagent, global_ls_id);
  while (!got_stun_packet)
    g_main_context_iteration (NULL, TRUE);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
            !lagent_candidate_gathering_done);

  nice_agent_gather_candidates (ragent, global_rs_id);
  while (!ragent_candidate_gathering_done)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);
  g_assert (ragent_candidate_gathering_done);


  g_debug ("Setting local candidates of ragent as remote candidates of lagent");
  swap_candidates (ragent, global_rs_id, lagent, global_ls_id, TRUE);
  swap_credentials (ragent, global_rs_id, lagent, global_ls_id);

  while (!data_received)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);
  g_assert (global_lagent_state >= NICE_COMPONENT_STATE_CONNECTED &&
            data_received);

  g_debug ("Setting local candidates of lagent as remote candidates of ragent");
  swap_candidates (lagent, global_ls_id, ragent, global_rs_id, FALSE);
  swap_credentials (lagent, global_ls_id, ragent, global_rs_id);

  while (!lagent_candidate_gathering_done)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (lagent_candidate_gathering_done);

  while (global_ragent_state < NICE_COMPONENT_STATE_CONNECTED)
    g_main_context_iteration (NULL, TRUE);
  g_cancellable_reset (global_cancellable);

  g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);
  g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);

  cleanup (lagent, ragent);
}
Ejemplo n.º 5
0
static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
{
  NiceCandidate *cand =  NULL;

  g_debug ("test-dribblemode:%s", G_STRFUNC);

  init_test (lagent, ragent, FALSE);

  nice_agent_gather_candidates (lagent, global_ls_id);
  g_main_loop_run (global_mainloop);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
            !lagent_candidate_gathering_done);

  nice_agent_gather_candidates (ragent, global_rs_id);
  if (!ragent_candidate_gathering_done) {
    g_main_loop_run (global_mainloop);
    g_assert (ragent_candidate_gathering_done);
  }

  add_bad_candidate (lagent, global_ls_id, cand);

  // lagent will finish candidate gathering causing this mainloop to quit
  g_main_loop_run (global_mainloop);

  // connchecks will fail causing this mainloop to quit
  g_main_loop_run (global_mainloop);

  g_assert (global_lagent_state == NICE_COMPONENT_STATE_FAILED &&
            !data_received);
  set_credentials (lagent, global_ls_id, ragent, global_rs_id);

  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   FALSE);

  swap_candidates (lagent, global_ls_id,
                   ragent, global_rs_id,
                   FALSE);

  g_main_loop_run (global_mainloop);

  g_assert (lagent_candidate_gathering_done);

  g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);
  g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);

  cleanup (lagent, ragent);
}
Ejemplo n.º 6
0
static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
{
  g_debug ("test-dribblemode:%s", G_STRFUNC);

  init_test (lagent, ragent, FALSE);

  nice_agent_gather_candidates (lagent, global_ls_id);
  g_main_loop_run (global_mainloop);
  g_assert (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
            !lagent_candidate_gathering_done);

  nice_agent_gather_candidates (ragent, global_rs_id);
  if (!ragent_candidate_gathering_done) {
    g_main_loop_run (global_mainloop);
    g_assert (ragent_candidate_gathering_done);
  }

  set_credentials (lagent, global_ls_id, ragent, global_rs_id);

  g_debug ("Setting local candidates of ragent as remote candidates of lagent");
  swap_candidates (ragent, global_rs_id,
                   lagent, global_ls_id,
                   TRUE);

  g_main_loop_run (global_mainloop);
  g_assert (global_lagent_state >= NICE_COMPONENT_STATE_CONNECTED &&
            data_received);

  g_debug ("Setting local candidates of lagent as remote candidates of ragent");
  swap_candidates (lagent, global_ls_id,
                   ragent, global_rs_id,
                   FALSE);
  g_main_loop_run (global_mainloop);

  g_assert (lagent_candidate_gathering_done);

  g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);
  g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);

  cleanup (lagent, ragent);
}