#include #include "prof_cmocka.h" #include #include #include #include #include #include "proftest.h" void ping_server(void **state) { // Respond to disco#info query regardless of the generated id stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" "" ); // Respond to ping IQs independent of the request id stbbr_for_query("urn:xmpp:ping", "" ); prof_connect(); // Give profanity time to process disco#info sleep(2); prof_input("/ping"); // Check that ping IQ was sent assert_true(stbbr_received( "" "" "" )); // Now check for the response message prof_timeout(30); assert_true(prof_output_regex("Ping response from server")); prof_timeout_reset(); prof_input("/ping"); assert_true(stbbr_received( "" "" "" )); prof_timeout(30); assert_true(prof_output_regex("Ping response from server")); prof_timeout_reset(); } void ping_server_not_supported(void **state) { stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" ); prof_connect(); prof_input("/ping"); assert_true(prof_output_regex("Server does not support ping requests")); } void ping_responds_to_server_request(void **state) { prof_connect(); stbbr_send( "" "" "" ); assert_true(stbbr_received( "" )); } void ping_jid(void **state) { // Caps/disco info response without relying on a fixed id stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" "" "" "" ); prof_connect(); stbbr_send( "" "10" "I'm here" "" "" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(stbbr_received( "" "" "" )); // Respond to ping result regardless of id stbbr_for_query("urn:xmpp:ping", "" ); prof_input("/ping buddy1@localhost/mobile"); assert_true(stbbr_received( "" "" "" )); assert_true(prof_output_regex("Ping response from buddy1@localhost/mobile")); } void ping_jid_not_supported(void **state) { stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" "" "" ); prof_connect(); stbbr_send( "" "10" "I'm here" "" "" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(stbbr_received( "" "" "" )); prof_input("/ping buddy1@localhost/mobile"); assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests.")); }