Compare commits

...

1 Commits

Author SHA1 Message Date
770a46c1c9 tests: Add disco tests
Some checks failed
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 34s
CI Code / Code Coverage (pull_request) Failing after 3h14m35s
CI Code / Linux (ubuntu) (pull_request) Failing after 3h14m37s
CI Code / Linux (debian) (pull_request) Failing after 3h14m37s
CI Code / Linux (arch) (pull_request) Failing after 3h14m38s
2026-02-02 17:43:29 +01:00
4 changed files with 133 additions and 0 deletions

View File

@@ -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 \

View File

@@ -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),
};
/* ============================================================

View 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>"
// ));
}

View 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);