Compare commits
1 Commits
6548329616
...
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 \
|
||||
|
||||
@@ -57,7 +57,6 @@ typedef struct prof_account_t
|
||||
gchar* muc_service;
|
||||
gchar* muc_nick;
|
||||
gboolean enabled;
|
||||
gboolean autoping_received;
|
||||
gchar* otr_policy;
|
||||
GList* otr_manual;
|
||||
GList* otr_opportunistic;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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,26 +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 supports_ping = g_hash_table_contains(features, "urn:xmpp:ping");
|
||||
gboolean is_autoping_disabled = prefs_get_autoping() == 0;
|
||||
|
||||
// if "autoping" in disco + user wasn't alerted earlier after login + prefs for autoping recommendation alert is set
|
||||
// then cons_show("Autoping is disabled, but server supports autoping.")
|
||||
|
||||
if (supports_ping && is_autoping_disabled) { // && !connection->disco_ping_alert_shown
|
||||
// TODO: later add preference check: if (prefs_autoping_recommendation_enabled())
|
||||
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.");
|
||||
// connection->disco_ping_alert_shown = TRUE;
|
||||
}
|
||||
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