diff options
author | Fabrice Bellet <fabrice@bellet.info> | 2017-11-26 17:36:27 +0100 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2018-03-23 13:56:14 -0400 |
commit | 025d84b53bd4ffc0626dd25aa8351319f4d77944 (patch) | |
tree | 447cab969a282b061bd4d77b42d007a59b74824f /tests | |
parent | ae3e5acc775ee6c1701ff9a2404b14e4d5dd6c20 (diff) | |
download | libnice-025d84b53bd4ffc0626dd25aa8351319f4d77944.tar.gz |
test-new-dribble: make credentials swap asymmetric
the first case of test-new-dribble (standard-test) is updated, by making
the credentials swap between the left and right agent asymmetric.
Previously, ragent started to receive stun requests without initially
knowing lagent candidates. Now, ragent also ignores lagent credentials.
This modification allows to test changes introduced by the previous
commit.
Reviewed-by: Olivier CrĂȘte <olivier.crete@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D1890
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-new-dribble.c | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/tests/test-new-dribble.c b/tests/test-new-dribble.c index 3e60ae3..947f55d 100644 --- a/tests/test-new-dribble.c +++ b/tests/test-new-dribble.c @@ -269,7 +269,7 @@ static gpointer stun_thread_func (const gpointer user_data) return NULL; } -static void set_credentials (NiceAgent *lagent, guint lstream, +static void swap_credentials (NiceAgent *lagent, guint lstream, NiceAgent *ragent, guint rstream) { gchar *ufrag = NULL, *password = NULL; @@ -279,12 +279,6 @@ static void set_credentials (NiceAgent *lagent, guint lstream, g_free (ufrag); g_free (password); - - nice_agent_get_local_credentials (ragent, rstream, &ufrag, &password); - nice_agent_set_remote_credentials (lagent, lstream, ufrag, password); - - g_free (ufrag); - g_free (password); } static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer data) @@ -500,12 +494,10 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent) g_cancellable_reset (global_cancellable); 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); + 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); @@ -514,9 +506,9 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent) 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_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); @@ -557,22 +549,21 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent) g_cancellable_reset (global_cancellable); g_assert (ragent_candidate_gathering_done); - swap_candidates (ragent, global_rs_id, - lagent, global_ls_id, - FALSE); + g_debug ("Setting local candidates of ragent as remote candidates of lagent"); + 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); + g_debug ("Setting local candidates of ragent as remote candidates of lagent"); + swap_candidates (ragent, global_rs_id, lagent, global_ls_id, FALSE); + swap_credentials (lagent, global_ls_id, ragent, global_rs_id); - swap_candidates (lagent, global_ls_id, - ragent, global_rs_id, - FALSE); + 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 (ragent, global_rs_id, lagent, global_ls_id); while (!data_received) g_main_context_iteration (NULL, TRUE); @@ -628,15 +619,14 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent) 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); + g_debug ("Setting local candidates of ragent as remote candidates of lagent"); + swap_candidates (ragent, global_rs_id, lagent, global_ls_id, FALSE); + swap_credentials (ragent, global_rs_id, lagent, global_ls_id); - swap_candidates (lagent, global_ls_id, - ragent, global_rs_id, - FALSE); + 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 (!data_received) g_main_context_iteration (NULL, TRUE); @@ -655,7 +645,8 @@ static void new_candidate_test(NiceAgent *lagent, NiceAgent *ragent) g_debug ("test-dribblemode:%s", G_STRFUNC); init_test (lagent, ragent, TRUE); - set_credentials (lagent, global_ls_id, ragent, global_rs_id); + swap_credentials (lagent, global_ls_id, ragent, global_rs_id); + swap_credentials (ragent, global_rs_id, lagent, global_ls_id); nice_agent_gather_candidates (lagent, global_ls_id); while (!got_stun_packet) |