/* * test_ping.c * * Copyright (C) 2015 - 2017 James Booth * Copyright (C) 2019 - 2026 Michael Vetter * * SPDX-License-Identifier: GPL-3.0-or-later */ #include #include "prof_cmocka.h" #include #include #include #include "proftest.h" void ping_server(void** state) { stbbr_for_query("http://jabber.org/protocol/disco#info", "" "" "" "" "" ""); stbbr_for_xmlns("urn:xmpp:ping", ""); prof_connect(); prof_input("/ping"); assert_true(stbbr_received( "" "" "")); assert_true(prof_output_exact("Ping response from server")); prof_input("/ping"); assert_true(stbbr_received( "" "" "")); assert_true(prof_output_exact("Ping response from server")); } 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_exact("Server does not support ping requests (urn:xmpp:ping).")); } void ping_responds_to_server_request(void** state) { prof_connect(); stbbr_send( "" "" ""); assert_true(stbbr_received( "")); } void ping_jid(void** state) { stbbr_for_id("*", "" "" "" "" "" "" "" ""); stbbr_for_xmlns("urn:xmpp:ping", ""); 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(stbbr_received( "" "" "")); assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile")); } void ping_jid_not_supported(void** state) { stbbr_for_id("*", "" "" "" "" "" "" ""); 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.")); }