test(autoping): add test for autoping warning exclusion on user JIDs
All checks were successful
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Successful in 31s
CI Code / Code Coverage (pull_request) Successful in 3m33s
CI Code / Linux (debian) (pull_request) Successful in 5m7s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m12s
CI Code / Linux (arch) (pull_request) Successful in 7m9s

This commit is contained in:
2026-06-20 20:47:05 +00:00
parent 2012e15c0b
commit 7fd0cded3d
4 changed files with 26 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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),

View File

@@ -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",
"<iq to='stabber@localhost/profanity' type='result' from='buddy1@localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='person' type='chat' name='Buddy1'/>"
"<feature var='urn:xmpp:ping'/>"
"</query>"
"</iq>"
);
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));
}

View File

@@ -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);