diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2011-10-25 16:44:36 +0200 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2011-11-07 13:39:38 +0100 |
commit | c4e19a478599d12824dddcba83de907fa8adf310 (patch) | |
tree | 7ba9e6e112315a4fa3651190652b56f79daa0f22 /tests | |
parent | ac0030bef952d974c9a6c64f73f2710add65a5fa (diff) |
Accept from="server.com" as stanzas coming from server
Some servers does not set the full/bare jid.
Fixes fdo#39057
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wocky-porter-test.c | 80 |
1 files changed, 76 insertions, 4 deletions
diff --git a/tests/wocky-porter-test.c b/tests/wocky-porter-test.c index ca64f0f..08e9d4d 100644 --- a/tests/wocky-porter-test.c +++ b/tests/wocky-porter-test.c @@ -3091,10 +3091,9 @@ handler_from_anyone (void) send_query_from (test, "tybalt@capulet.lit", "anyone"); send_query_from (test, "tybalt@capulet.lit/FIXME", "anyone"); - /* Slightly counterintuitively, a stanza from our server's domain should not - * be matched by got_stanza_from_server(). - */ - send_query_from (test, "capulet.lit", "anyone"); + /* A stanza from our server's domain should be matched by + * got_stanza_from_server(). See fd.o#39057. */ + send_query_from (test, "capulet.lit", "server"); /* On the other hand, a stanza with no sender should be picked up by * got_stanza_from_server(). */ @@ -3290,12 +3289,83 @@ send_from_send_callback (void) teardown_test (test); } +static gboolean +test_reply_from_domain_handler_cb (WockyPorter *porter, + WockyStanza *stanza, + gpointer user_data) +{ + test_data_t *test = (test_data_t *) user_data; + WockyStanza *reply; + const gchar *id; + + test_expected_stanza_received (test, stanza); + + id = wocky_node_get_attribute (wocky_stanza_get_top_node (stanza), + "id"); + + /* Reply with from="domain" */ + reply = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, + WOCKY_STANZA_SUB_TYPE_RESULT, "example.com", "juliet@example.com", + '@', "id", id, + NULL); + wocky_porter_send_async (porter, reply, + NULL, test_send_iq_sent_cb, test); + g_queue_push_tail (test->expected_stanzas, reply); + test->outstanding++; + + return TRUE; +} + +static void +test_reply_from_domain (void) +{ + test_data_t *test = setup_test (); + WockyStanza *iq; + + g_test_bug ("39057"); + + /* Testing that when we send an iq to server, it can reply from the domain + instead of full/bare jid. This happens with xmpp.messenger.live.com. + + <iq type="get" id="1062691559">...</iq> + <iq from="domain.com" id="1062691559" + to="user@domain.com/resource">...</iq> + */ + + test_open_both_connections (test); + wocky_porter_start (test->sched_out); + wocky_porter_start (test->sched_in); + + /* register an IQ handler */ + wocky_porter_register_handler_from_anyone (test->sched_out, + WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_NONE, + 0, + test_reply_from_domain_handler_cb, test, NULL); + + /* Send an IQ query */ + iq = wocky_stanza_build (WOCKY_STANZA_TYPE_IQ, + WOCKY_STANZA_SUB_TYPE_GET, NULL, NULL, + '@', "id", "1", + NULL); + + wocky_porter_send_iq_async (test->sched_in, iq, + NULL, test_send_iq_reply_cb, test); + g_queue_push_tail (test->expected_stanzas, iq); + + test->outstanding += 2; + test_wait_pending (test); + + test_close_both_porters (test); + teardown_test (test); +} + int main (int argc, char **argv) { int result; test_init (argc, argv); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); g_test_add_func ("/xmpp-porter/initiation", test_instantiation); g_test_add_func ("/xmpp-porter/send", test_send); @@ -3352,6 +3422,8 @@ main (int argc, char **argv) close_from_send_callback); g_test_add_func ("/xmpp-porter/send-from-send-callback", send_from_send_callback); + g_test_add_func ("/xmpp-porter/reply-from-domain", + test_reply_from_domain); result = g_test_run (); test_deinit (); |