From 770a46c1c9cfcfe4c296e49993a5f00da2daad49 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Mon, 2 Feb 2026 17:43:29 +0100 Subject: [PATCH] tests: Add disco tests --- Makefile.am | 1 + tests/functionaltests/functionaltests.c | 7 ++ tests/functionaltests/test_disco.c | 121 ++++++++++++++++++++++++ tests/functionaltests/test_disco.h | 4 + 4 files changed, 133 insertions(+) create mode 100644 tests/functionaltests/test_disco.c create mode 100644 tests/functionaltests/test_disco.h diff --git a/Makefile.am b/Makefile.am index 89809594..d372525d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index e5f59d4e..3662e62c 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -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), }; /* ============================================================ diff --git a/tests/functionaltests/test_disco.c b/tests/functionaltests/test_disco.c new file mode 100644 index 00000000..4d830bd6 --- /dev/null +++ b/tests/functionaltests/test_disco.c @@ -0,0 +1,121 @@ +#include +#include "prof_cmocka.h" +#include +#include + +#include + +#include "proftest.h" + +void +disco_info_server_on_explicit_request(void **state) +{ + // prof_connect_with_roster( + // "" + // ); + + // stbbr_for_query("http://jabber.org/protocol/disco#info", + // "" + // "" + // "" + // "" + // "" + // "" + // "" + // "" + // ); + + // 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( + // "" + // "" + // "" + // )); +} + + +void +disco_items_with_node(void **state) +{ + // prof_connect_with_roster( + // "" + // ); + + // stbbr_for_query("http://jabber.org/protocol/disco#items", + // "" + // "" + // "" + // "" + // "" + // ); + + // // 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( + // "" + // "" + // "" + // )); +} + + +void +disco_info_error_item_not_found(void **state) +{ + // prof_connect_with_roster( + // "" + // ); + + // stbbr_for_query("http://jabber.org/protocol/disco#info", + // "" + // "" + // "" + // "" + // "" + // "" + // ); + + // 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( + // "" + // "" + // "" + // )); +} + + +void +no_automatic_disco_after_connect(void **state) +{ + // prof_connect_with_roster( + // "" + // ); + + // // 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( + // "" + // "" + // "" + // )); + + // assert_false(stbbr_received( + // "" + // "" + // "" + // )); +} \ No newline at end of file diff --git a/tests/functionaltests/test_disco.h b/tests/functionaltests/test_disco.h new file mode 100644 index 00000000..4d530b23 --- /dev/null +++ b/tests/functionaltests/test_disco.h @@ -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); -- 2.49.1