Fix multiple issues preventing functional tests from running:
Stabber submodule:
- Fix XMPP stream parsing for multiple stanzas per TCP packet
- Add virtual wrapper element for Expat to handle multiple roots
- Support non-<query/> IQ payloads (ping, blocklist, etc.)
- Relax stanza matching to allow extra attributes in received
Profanity changes:
- cmd_defs.c: Increase /connect args limit from 7 to 9
- proftest.c: Add startup delay, use legacy auth, debug logging
- test_ping.c: Use wildcard IDs, regex matching, timing fixes
- functionaltests.c: Enable connect and ping test suites
Results: 9/10 tests passing
TODO:
- [ ] Fix ping_server test (disco#info response handling)
- [ ] Uncomment and fix remaining test suites (rooms, message,
receipts, chat_session, presence, etc.)
- [ ] Remove STBBR_LOGDEBUG after stabilization
- [ ] Review timing/sleep() calls for optimization
179 lines
5.8 KiB
C
179 lines
5.8 KiB
C
#include <glib.h>
|
|
#include "prof_cmocka.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include <stabber.h>
|
|
#include <expect.h>
|
|
|
|
#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",
|
|
"<iq to='stabber@localhost/profanity' type='result' from='localhost'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
|
"<identity category='server' type='im' name='Prosody'/>"
|
|
"<feature var='urn:xmpp:ping'/>"
|
|
"</query>"
|
|
"</iq>"
|
|
);
|
|
|
|
// Respond to ping IQs independent of the request id
|
|
stbbr_for_query("urn:xmpp:ping",
|
|
"<iq from='localhost' to='stabber@localhost/profanity' type='result'/>"
|
|
);
|
|
|
|
prof_connect();
|
|
|
|
// Give profanity time to process disco#info
|
|
sleep(2);
|
|
|
|
prof_input("/ping");
|
|
// Check that ping IQ was sent
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='get' to='*'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"
|
|
));
|
|
// 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(
|
|
"<iq id='*' type='get' to='*'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"
|
|
));
|
|
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",
|
|
"<iq to='stabber@localhost/profanity' type='result' from='localhost'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
|
"<identity category='server' type='im' name='Stabber'/>"
|
|
"</query>"
|
|
"</iq>"
|
|
);
|
|
|
|
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(
|
|
"<iq id=\"pingtest1\" type=\"get\" to=\"stabber@localhost/profanity\" from=\"localhost\">"
|
|
"<ping xmlns=\"urn:xmpp:ping\"/>"
|
|
"</iq>"
|
|
);
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'></iq>"
|
|
));
|
|
}
|
|
|
|
void ping_jid(void **state)
|
|
{
|
|
// Caps/disco info response without relying on a fixed id
|
|
stbbr_for_query("http://jabber.org/protocol/disco#info",
|
|
"<iq 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='>"
|
|
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
|
"<feature var='urn:xmpp:ping'/>"
|
|
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
|
"<feature var='http://jabber.org/protocol/caps'/>"
|
|
"</query>"
|
|
"</iq>"
|
|
);
|
|
|
|
prof_connect();
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>I'm here</status>"
|
|
"<c "
|
|
"hash='sha-1' "
|
|
"xmlns='http://jabber.org/protocol/caps' "
|
|
"node='http://profanity-im.github.io' "
|
|
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
|
"/>"
|
|
"</presence>"
|
|
);
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' to='buddy1@localhost/mobile' type='get'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
|
"</iq>"
|
|
));
|
|
|
|
// Respond to ping result regardless of id
|
|
stbbr_for_query("urn:xmpp:ping",
|
|
"<iq from='buddy1@localhost/mobile' to='stabber@localhost' type='result'/>"
|
|
);
|
|
|
|
prof_input("/ping buddy1@localhost/mobile");
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='get' to='buddy1@localhost/mobile'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"
|
|
));
|
|
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",
|
|
"<iq 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='>"
|
|
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
|
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
|
"<feature var='http://jabber.org/protocol/caps'/>"
|
|
"</query>"
|
|
"</iq>"
|
|
);
|
|
|
|
prof_connect();
|
|
|
|
stbbr_send(
|
|
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
|
"<priority>10</priority>"
|
|
"<status>I'm here</status>"
|
|
"<c "
|
|
"hash='sha-1' "
|
|
"xmlns='http://jabber.org/protocol/caps' "
|
|
"node='http://profanity-im.github.io' "
|
|
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
|
"/>"
|
|
"</presence>"
|
|
);
|
|
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
|
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' to='buddy1@localhost/mobile' type='get'>"
|
|
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
|
"</iq>"
|
|
));
|
|
|
|
prof_input("/ping buddy1@localhost/mobile");
|
|
assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests."));
|
|
}
|