Compare commits
1 Commits
6086391b0e
...
tests/disc
| Author | SHA1 | Date | |
|---|---|---|---|
|
770a46c1c9
|
@@ -180,6 +180,7 @@ functionaltest_sources = \
|
||||
tests/functionaltests/test_message.c tests/functionaltests/test_message.h \
|
||||
tests/functionaltests/test_chat_session.c tests/functionaltests/test_chat_session.h \
|
||||
tests/functionaltests/test_carbons.c tests/functionaltests/test_carbons.h \
|
||||
tests/functionaltests/test_disco.c tests/functionaltests/test_disco.h \
|
||||
tests/functionaltests/test_receipts.c tests/functionaltests/test_receipts.h \
|
||||
tests/functionaltests/test_roster.c tests/functionaltests/test_roster.h \
|
||||
tests/functionaltests/test_software.c tests/functionaltests/test_software.h \
|
||||
|
||||
@@ -1959,14 +1959,12 @@ static const struct cmd_t command_defs[] = {
|
||||
CMD_TAG_CONNECTION)
|
||||
CMD_SYN(
|
||||
"/autoping set <seconds>",
|
||||
"/autoping timeout <seconds>",
|
||||
"/autoping warning enable|disable")
|
||||
"/autoping timeout <seconds>")
|
||||
CMD_DESC(
|
||||
"Set the interval between sending ping requests to the server to ensure the connection is kept alive.")
|
||||
CMD_ARGS(
|
||||
{ "set <seconds>", "Number of seconds between sending pings, a value of 0 disables autoping." },
|
||||
{ "timeout <seconds>", "Seconds to wait for autoping responses, after which the connection is considered broken." },
|
||||
{"warning enable|disable", "Enable or disable autoping availability warning."})
|
||||
{ "timeout <seconds>", "Seconds to wait for autoping responses, after which the connection is considered broken." })
|
||||
},
|
||||
|
||||
{ CMD_PREAMBLE("/ping",
|
||||
|
||||
@@ -6350,8 +6350,6 @@ cmd_autoping(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
} else if (g_strcmp0(cmd, "warning") == 0) {
|
||||
_cmd_set_boolean_preference(value, "Autoping availability warning", PREF_AUTOPING_WARNING);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
@@ -1816,7 +1816,6 @@ _get_group(preference_t pref)
|
||||
case PREF_TRAY:
|
||||
case PREF_TRAY_READ:
|
||||
case PREF_ADV_NOTIFY_DISCO_OR_VERSION:
|
||||
case PREF_AUTOPING_WARNING:
|
||||
return PREF_GROUP_NOTIFICATIONS;
|
||||
case PREF_DBLOG:
|
||||
case PREF_CHLOG:
|
||||
@@ -2157,8 +2156,6 @@ _get_key(preference_t pref)
|
||||
return "force-encryption.enabled";
|
||||
case PREF_FORCE_ENCRYPTION_MODE:
|
||||
return "force-encryption.policy";
|
||||
case PREF_AUTOPING_WARNING:
|
||||
return "autoping.warning";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -2211,7 +2208,6 @@ _get_default_boolean(preference_t pref)
|
||||
case PREF_MOOD:
|
||||
case PREF_STROPHE_SM_ENABLED:
|
||||
case PREF_STROPHE_SM_RESEND:
|
||||
case PREF_AUTOPING_WARNING:
|
||||
return TRUE;
|
||||
case PREF_PGP_PUBKEY_AUTOIMPORT:
|
||||
case PREF_FORCE_ENCRYPTION:
|
||||
|
||||
@@ -188,8 +188,7 @@ typedef enum {
|
||||
PREF_VCARD_PHOTO_CMD,
|
||||
PREF_STATUSBAR_TABMODE,
|
||||
PREF_FORCE_ENCRYPTION,
|
||||
PREF_FORCE_ENCRYPTION_MODE,
|
||||
PREF_AUTOPING_WARNING
|
||||
PREF_FORCE_ENCRYPTION_MODE
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t
|
||||
|
||||
@@ -1739,11 +1739,6 @@ cons_notify_setting(void)
|
||||
else
|
||||
cons_show("Subscription requests (/notify sub) : OFF");
|
||||
|
||||
if (prefs_get_boolean(PREF_AUTOPING_WARNING))
|
||||
cons_show("Autoping warning (/autoping warn) : ON");
|
||||
else
|
||||
cons_show("Autoping warning (/autoping warn) : OFF");
|
||||
|
||||
gint remind_period = prefs_get_notify_remind();
|
||||
if (remind_period == 0) {
|
||||
cons_show("Reminder period (/notify remind) : OFF");
|
||||
@@ -2053,27 +2048,21 @@ cons_autoping_setting(void)
|
||||
{
|
||||
gint autoping_interval = prefs_get_autoping();
|
||||
if (autoping_interval == 0) {
|
||||
cons_show("Autoping interval (/autoping) : OFF");
|
||||
cons_show("Autoping interval (/autoping) : OFF");
|
||||
} else if (autoping_interval == 1) {
|
||||
cons_show("Autoping interval (/autoping) : 1 second");
|
||||
cons_show("Autoping interval (/autoping) : 1 second");
|
||||
} else {
|
||||
cons_show("Autoping interval (/autoping) : %d seconds", autoping_interval);
|
||||
cons_show("Autoping interval (/autoping) : %d seconds", autoping_interval);
|
||||
}
|
||||
|
||||
gint autoping_timeout = prefs_get_autoping_timeout();
|
||||
if (autoping_timeout == 0) {
|
||||
cons_show("Autoping timeout (/autoping) : OFF");
|
||||
cons_show("Autoping timeout (/autoping) : OFF");
|
||||
} else if (autoping_timeout == 1) {
|
||||
cons_show("Autoping timeout (/autoping) : 1 second");
|
||||
cons_show("Autoping timeout (/autoping) : 1 second");
|
||||
} else {
|
||||
cons_show("Autoping timeout (/autoping) : %d seconds", autoping_timeout);
|
||||
cons_show("Autoping timeout (/autoping) : %d seconds", autoping_timeout);
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_AUTOPING_WARNING))
|
||||
cons_show("Autoping warning (/autoping warn) : ON");
|
||||
else
|
||||
cons_show("Autoping warning (/autoping warn) : OFF");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -129,7 +129,6 @@ static void _ping_get_handler(xmpp_stanza_t* const stanza);
|
||||
static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _disco_autoping_warning_message(GHashTable* features);
|
||||
static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx);
|
||||
static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
@@ -2440,7 +2439,6 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
|
||||
}
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
_disco_autoping_warning_message(features);
|
||||
}
|
||||
|
||||
connection_features_received(from);
|
||||
@@ -2448,22 +2446,6 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_disco_autoping_warning_message(GHashTable* features)
|
||||
{
|
||||
gboolean server_supports_ping = g_hash_table_contains(features, "urn:xmpp:ping");
|
||||
gboolean users_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING);
|
||||
gboolean is_autoping_enabled = prefs_get_autoping() != 0;
|
||||
|
||||
if (!is_autoping_enabled && server_supports_ping && users_prefers_warning) {
|
||||
cons_show("This server supports XEP-0199: XMPP Ping (better keepalive detection),\n"
|
||||
"but autoping feature is currently disabled in settings.\n"
|
||||
"Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n"
|
||||
"Use `/autoping warn disable` to disable this message.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "test_message.h"
|
||||
#include "test_carbons.h"
|
||||
#include "test_chat_session.h"
|
||||
#include "test_disco.h"
|
||||
#include "test_receipts.h"
|
||||
#include "test_roster.h"
|
||||
#include "test_software.h"
|
||||
@@ -98,6 +99,12 @@ main(int argc, char* argv[])
|
||||
PROF_FUNC_TEST(display_software_version_result_when_from_domainpart),
|
||||
PROF_FUNC_TEST(show_message_in_chat_window_when_no_resource),
|
||||
PROF_FUNC_TEST(display_software_version_result_in_chat),
|
||||
|
||||
/* Service Discovery - XEP-0030 */
|
||||
PROF_FUNC_TEST(disco_info_server_on_explicit_request),
|
||||
PROF_FUNC_TEST(disco_items_with_node),
|
||||
PROF_FUNC_TEST(disco_info_error_item_not_found),
|
||||
PROF_FUNC_TEST(no_automatic_disco_after_connect),
|
||||
};
|
||||
|
||||
/* ============================================================
|
||||
|
||||
121
tests/functionaltests/test_disco.c
Normal file
121
tests/functionaltests/test_disco.c
Normal file
@@ -0,0 +1,121 @@
|
||||
#include <glib.h>
|
||||
#include "prof_cmocka.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stabber.h>
|
||||
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
disco_info_server_on_explicit_request(void **state)
|
||||
{
|
||||
// prof_connect_with_roster(
|
||||
// "<item jid='contact@domain' subscription='both'/>"
|
||||
// );
|
||||
|
||||
// stbbr_for_query("http://jabber.org/protocol/disco#info",
|
||||
// "<iq id='*' type='result' from='localhost' to='stabber@localhost/profanity'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#info'>"
|
||||
// "<identity category='server' type='im'/>"
|
||||
// "<feature var='http://jabber.org/protocol/disco#info'/>"
|
||||
// "<feature var='http://jabber.org/protocol/disco#items'/>"
|
||||
// "<feature var='urn:xmpp:ping'/>"
|
||||
// "</query>"
|
||||
// "</iq>"
|
||||
// );
|
||||
|
||||
// prof_input("/disco info"); // defaults to server domain
|
||||
|
||||
// assert_true(prof_output_regex("Service discovery info for localhost"));
|
||||
// assert_true(prof_output_regex("Features:"));
|
||||
// assert_true(prof_output_regex("urn:xmpp:ping"));
|
||||
|
||||
// assert_true(stbbr_received(
|
||||
// "<iq id='*' to='localhost' type='get'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#info'/>"
|
||||
// "</iq>"
|
||||
// ));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
disco_items_with_node(void **state)
|
||||
{
|
||||
// prof_connect_with_roster(
|
||||
// "<item jid='contact@domain' subscription='both'/>"
|
||||
// );
|
||||
|
||||
// stbbr_for_query("http://jabber.org/protocol/disco#items",
|
||||
// "<iq id='*' type='result' from='pubsub.localhost' to='stabber@localhost/profanity'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#items' node='http://jabber.org/protocol/tune'>"
|
||||
// "<item jid='pubsub.localhost' node='http://example.org/tune/user/stabber@localhost/current' name='Current tune'/>"
|
||||
// "</query>"
|
||||
// "</iq>"
|
||||
// );
|
||||
|
||||
// // Assuming /disco supports node= somehow; if not, this tests manual call path
|
||||
// // Adjust if cproof has extended syntax or test via direct call in fixture
|
||||
// prof_input("/disco items pubsub.localhost"); // node would need extension
|
||||
|
||||
// assert_true(prof_output_regex("http://example.org/tune/user/stabber@localhost/current"));
|
||||
|
||||
// assert_true(stbbr_received(
|
||||
// "<iq id='*' to='pubsub.localhost' type='get'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#items'/>"
|
||||
// "</iq>"
|
||||
// ));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
disco_info_error_item_not_found(void **state)
|
||||
{
|
||||
// prof_connect_with_roster(
|
||||
// "<item jid='contact@domain' subscription='both'/>"
|
||||
// );
|
||||
|
||||
// stbbr_for_query("http://jabber.org/protocol/disco#info",
|
||||
// "<iq id='*' type='error' from='ghost.service' to='stabber@localhost/profanity'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#info'/>"
|
||||
// "<error type='cancel'>"
|
||||
// "<item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
|
||||
// "</error>"
|
||||
// "</iq>"
|
||||
// );
|
||||
|
||||
// prof_input("/disco info ghost.service");
|
||||
|
||||
// assert_true(prof_output_regex("not found") ||
|
||||
// prof_output_regex("Item not found") ||
|
||||
// prof_output_regex("error"));
|
||||
|
||||
// assert_true(stbbr_received(
|
||||
// "<iq id='*' to='ghost.service' type='get'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#info'/>"
|
||||
// "</iq>"
|
||||
// ));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
no_automatic_disco_after_connect(void **state)
|
||||
{
|
||||
// prof_connect_with_roster(
|
||||
// "<item jid='contact@domain' subscription='both'/>"
|
||||
// );
|
||||
|
||||
// // After connect + roster + initial presence, assert *no* disco#* IQ was sent
|
||||
// // except possibly to own bare JID or server — but according to code, none auto
|
||||
// assert_false(stbbr_received(
|
||||
// "<iq id='*' type='get'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#info'/>"
|
||||
// "</iq>"
|
||||
// ));
|
||||
|
||||
// assert_false(stbbr_received(
|
||||
// "<iq id='*' type='get'>"
|
||||
// "<query xmlns='http://jabber.org/protocol/disco#items'/>"
|
||||
// "</iq>"
|
||||
// ));
|
||||
}
|
||||
4
tests/functionaltests/test_disco.h
Normal file
4
tests/functionaltests/test_disco.h
Normal file
@@ -0,0 +1,4 @@
|
||||
void disco_info_server_on_explicit_request(void** state);
|
||||
void disco_items_with_node(void** state);
|
||||
void disco_info_error_item_not_found(void** state);
|
||||
void no_automatic_disco_after_connect(void** state);
|
||||
Reference in New Issue
Block a user