tests: fix functional test test_ping

This commit is contained in:
Michael Vetter
2026-03-05 12:34:56 +01:00
parent d7142479ae
commit edd36f784f

View File

@@ -10,31 +10,29 @@
void void
ping_server(void** state) ping_server(void** state)
{ {
stbbr_for_id("prof_disco_info_onconnect_*", stbbr_for_query("http://jabber.org/protocol/disco#info",
"<iq id='prof_disco_info_onconnect_*' to='stabber@localhost/profanity' type='result' from='localhost'>" "<iq id='*' to='stabber@localhost/profanity' type='result' from='localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>" "<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Prosody'/>" "<identity category='server' type='im' name='Prosody'/>"
"<feature var='urn:xmpp:ping'/>" "<feature var='urn:xmpp:ping'/>"
"</query>" "</query>"
"</iq>"); "</iq>");
stbbr_for_id("prof_ping_*", stbbr_for_xmlns("urn:xmpp:ping",
"<iq id='prof_ping_*' type='result' to='stabber@localhost/profanity'/>"); "<iq id='*' type='result' to='stabber@localhost/profanity'/>");
stbbr_for_id("prof_ping_*",
"<iq id='prof_ping_*' type='result' to='stabber@localhost/profanity'/>");
prof_connect(); prof_connect();
prof_input("/ping"); prof_input("/ping");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_ping_*' type='get'>" "<iq id='*' type='get'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>")); "</iq>"));
assert_true(prof_output_exact("Ping response from server")); assert_true(prof_output_exact("Ping response from server"));
prof_input("/ping"); prof_input("/ping");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_ping_*' type='get'>" "<iq id='*' type='get'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>")); "</iq>"));
assert_true(prof_output_exact("Ping response from server")); assert_true(prof_output_exact("Ping response from server"));
@@ -43,8 +41,8 @@ ping_server(void** state)
void void
ping_server_not_supported(void** state) ping_server_not_supported(void** state)
{ {
stbbr_for_id("prof_disco_info_onconnect_*", stbbr_for_query("http://jabber.org/protocol/disco#info",
"<iq id='prof_disco_info_onconnect_*' to='stabber@localhost/profanity' type='result' from='localhost'>" "<iq id='*' to='stabber@localhost/profanity' type='result' from='localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>" "<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Stabber'/>" "<identity category='server' type='im' name='Stabber'/>"
"</query>" "</query>"
@@ -67,14 +65,14 @@ ping_responds_to_server_request(void** state)
"</iq>"); "</iq>");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>")); "<iq id='pingtest1' to='localhost' type='result'/>"));
} }
void void
ping_jid(void** state) ping_jid(void** state)
{ {
stbbr_for_id("prof_caps_*", stbbr_for_id("*",
"<iq id='prof_caps_*' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>" "<iq id='*' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>" "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
"<identity category='client' type='console' name='Profanity0.6.0'/>" "<identity category='client' type='console' name='Profanity0.6.0'/>"
"<feature var='urn:xmpp:ping'/>" "<feature var='urn:xmpp:ping'/>"
@@ -83,6 +81,9 @@ ping_jid(void** state)
"</query>" "</query>"
"</iq>"); "</iq>");
stbbr_for_xmlns("urn:xmpp:ping",
"<iq id='*' type='result' from='buddy1@localhost/mobile' to='stabber@localhost/profanity'/>");
prof_connect(); prof_connect();
stbbr_send( stbbr_send(
@@ -99,17 +100,14 @@ ping_jid(void** state)
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_caps_*' to='buddy1@localhost/mobile' type='get'>" "<iq id='*' to='buddy1@localhost/mobile' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>" "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
"</iq>")); "</iq>"));
stbbr_for_id("prof_ping_*",
"<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_*' type='result'/>");
prof_input("/ping buddy1@localhost/mobile"); prof_input("/ping buddy1@localhost/mobile");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_ping_*' type='get' to='buddy1@localhost/mobile'>" "<iq id='*' type='get' to='buddy1@localhost/mobile'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>")); "</iq>"));
assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile")); assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile"));
@@ -118,8 +116,8 @@ ping_jid(void** state)
void void
ping_jid_not_supported(void** state) ping_jid_not_supported(void** state)
{ {
stbbr_for_id("prof_caps_*", stbbr_for_id("*",
"<iq id='prof_caps_*' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>" "<iq id='*' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>" "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
"<identity category='client' type='console' name='Profanity0.6.0'/>" "<identity category='client' type='console' name='Profanity0.6.0'/>"
"<feature var='http://jabber.org/protocol/disco#info'/>" "<feature var='http://jabber.org/protocol/disco#info'/>"
@@ -143,7 +141,7 @@ ping_jid_not_supported(void** state)
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_caps_*' to='buddy1@localhost/mobile' type='get'>" "<iq id='*' to='buddy1@localhost/mobile' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>" "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
"</iq>")); "</iq>"));