#include #include "prof_cmocka.h" #include #include #include #include "proftest.h" void message_send(void **state) { prof_connect(); prof_input("/msg somejid@someserver.com Hi there"); assert_true(stbbr_received( "" "Hi there" "" )); assert_true(prof_output_regex("me: .+Hi there")); } // TODO: `/message correct` XEP-0308 compliance (whether each correction links to the original message ID) // https://xmpp.org/extensions/xep-0308.html#rules void message_receive_console(void **state) { prof_connect(); stbbr_send( "" "How are you?" "" ); assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)")); } void message_receive_chatwin(void **state) { prof_connect(); prof_input("/msg someuser@chatserv.org"); assert_true(prof_output_exact("someuser@chatserv.org")); stbbr_send( "" "How are you?" "" ); assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?")); } // XEP-0359 disco gate: server announces urn:xmpp:sid:0 -> stanza-id trusted -> replay flagged as duplicate. void stanza_id_dedup_fires_when_server_announces_sid0(void **state) { stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" "" ); prof_connect(); stbbr_send( "" "first" "" "" ); assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)")); stbbr_send( "" "replay" "" "" ); assert_true(prof_output_exact("Got a message with duplicate (server-generated) stanza-id from someuser@chatserv.org/laptop.")); } // XEP-0359 disco gate: server does NOT announce urn:xmpp:sid:0 -> stanza-id untrusted -> no replay error. void stanza_id_not_trusted_when_server_does_not_announce_sid0(void **state) { stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" "" ); prof_connect(); stbbr_send( "" "first" "" "" ); assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)")); stbbr_send( "" "replay" "" "" ); prof_timeout(2); assert_false(prof_output_exact("Got a message with duplicate (server-generated) stanza-id")); prof_timeout_reset(); }