From 7fd0cded3d29d46890f9d1f02cb9342a1f46971d Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Sat, 20 Jun 2026 20:47:05 +0000 Subject: [PATCH] test(autoping): add test for autoping warning exclusion on user JIDs --- src/xmpp/iq.c | 1 - tests/functionaltests/functionaltests.c | 1 + tests/functionaltests/test_autoping.c | 25 ++++++++++++++++++++++++- tests/functionaltests/test_autoping.h | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 4b3708a9..c9e1f0bb 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2431,7 +2431,6 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con child = xmpp_stanza_get_next(child); } - // only fire on server responses (no '@' in JID), not user disco#info if (!from || !strstr(from, "@")) { _disco_autoping_warning_message(features); } diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index 388da85f..b42e3a21 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -155,6 +155,7 @@ main(int argc, char* argv[]) PROF_FUNC_TEST(autoping_warning_not_shown_when_server_unsupported), PROF_FUNC_TEST(autoping_warning_not_shown_when_autoping_enabled), PROF_FUNC_TEST(autoping_warning_not_shown_when_user_disabled), + PROF_FUNC_TEST(autoping_warning_not_shown_for_user_jid), /* Service Discovery - XEP-0030 */ PROF_FUNC_TEST(disco_info_shows_identity), diff --git a/tests/functionaltests/test_autoping.c b/tests/functionaltests/test_autoping.c index f3539c26..070254ae 100644 --- a/tests/functionaltests/test_autoping.c +++ b/tests/functionaltests/test_autoping.c @@ -194,7 +194,7 @@ autoping_warning_not_shown_when_autoping_enabled(void** state) void autoping_warning_not_shown_when_user_disabled(void** state) { - // User opted out -> no warning. Command takes on|off ("enable|disable" doc is wrong). + // User opted out -> no warning. _stub_server_disco(TRUE); prof_input("/autoping set 0"); @@ -208,3 +208,26 @@ autoping_warning_not_shown_when_user_disabled(void** state) prof_timeout(NEGATIVE_ASSERT_TIMEOUT); assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); } + +void +autoping_warning_not_shown_for_user_jid(void** state) +{ + // disco#info from a user JID (with '@') should not trigger the warning, + // only server responses (no '@') should. + stbbr_for_query("http://jabber.org/protocol/disco#info", + "" + "" + "" + "" + "" + "" + ); + + prof_input("/autoping set 0"); + assert_true(prof_output_exact("Autoping disabled.")); + + prof_connect(); + + prof_timeout(NEGATIVE_ASSERT_TIMEOUT); + assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); +} diff --git a/tests/functionaltests/test_autoping.h b/tests/functionaltests/test_autoping.h index c4915cbf..73d29931 100644 --- a/tests/functionaltests/test_autoping.h +++ b/tests/functionaltests/test_autoping.h @@ -8,3 +8,4 @@ void autoping_warning_shown_when_disabled(void** state); void autoping_warning_not_shown_when_server_unsupported(void** state); void autoping_warning_not_shown_when_autoping_enabled(void** state); void autoping_warning_not_shown_when_user_disabled(void** state); +void autoping_warning_not_shown_for_user_jid(void** state);