- Add 8 tests for disco info and disco items commands - Fix XEP-0030 compliance bug: show message for empty disco#items results - Tests cover: identity display, features, server/jid queries, error handling, items display, empty results, and connection requirement
115 lines
2.9 KiB
C
115 lines
2.9 KiB
C
#include <glib.h>
|
|
#include "prof_cmocka.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include <stabber.h>
|
|
|
|
#include "proftest.h"
|
|
|
|
void
|
|
autoping_set_interval(void** state)
|
|
{
|
|
prof_connect();
|
|
|
|
prof_input("/autoping set 60");
|
|
assert_true(prof_output_exact("Autoping interval set to 60 seconds."));
|
|
}
|
|
|
|
void
|
|
autoping_set_zero_disables(void** state)
|
|
{
|
|
prof_connect();
|
|
|
|
prof_input("/autoping set 0");
|
|
assert_true(prof_output_exact("Autoping disabled."));
|
|
}
|
|
|
|
void
|
|
autoping_timeout_set(void** state)
|
|
{
|
|
prof_connect();
|
|
|
|
prof_input("/autoping timeout 30");
|
|
assert_true(prof_output_exact("Autoping timeout set to 30 seconds."));
|
|
}
|
|
|
|
void
|
|
autoping_timeout_zero_disables(void** state)
|
|
{
|
|
prof_connect();
|
|
|
|
prof_input("/autoping timeout 0");
|
|
assert_true(prof_output_exact("Autoping timeout disabled."));
|
|
}
|
|
|
|
void
|
|
autoping_sends_ping_after_interval(void** state)
|
|
{
|
|
/*
|
|
* This test verifies that autoping sends a ping IQ after the configured
|
|
* interval. We set a short interval (1 second) and verify the ping is sent.
|
|
*/
|
|
|
|
// Register disco#info response with ping support
|
|
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'/>"
|
|
"<feature var='urn:xmpp:ping'/>"
|
|
"</query>"
|
|
"</iq>"
|
|
);
|
|
|
|
// Register ping response
|
|
stbbr_for_query("urn:xmpp:ping",
|
|
"<iq from='localhost' to='stabber@localhost/profanity' type='result'/>"
|
|
);
|
|
|
|
prof_connect();
|
|
|
|
// Set short autoping interval
|
|
prof_input("/autoping set 1");
|
|
assert_true(prof_output_exact("Autoping interval set to 1 seconds."));
|
|
|
|
// Wait for autoping to trigger (interval + some buffer)
|
|
sleep(2);
|
|
|
|
// Verify ping was sent (no 'to' attribute means server ping)
|
|
assert_true(stbbr_received(
|
|
"<iq id='*' type='get'>"
|
|
"<ping xmlns='urn:xmpp:ping'/>"
|
|
"</iq>"
|
|
));
|
|
}
|
|
|
|
void
|
|
autoping_server_not_supporting_ping(void** state)
|
|
{
|
|
/*
|
|
* When server doesn't support ping, autoping should show error.
|
|
*/
|
|
|
|
// Register disco#info response WITHOUT ping support
|
|
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();
|
|
|
|
// Set short autoping interval
|
|
prof_input("/autoping set 1");
|
|
assert_true(prof_output_exact("Autoping interval set to 1 seconds."));
|
|
|
|
// Wait for autoping to trigger
|
|
sleep(2);
|
|
|
|
// Should show error about ping not being supported
|
|
assert_true(prof_output_regex("Server ping not supported"));
|
|
}
|