mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-29 04:16:22 +00:00
test(disco): add functional test for disco#items error handling
Verifies that /disco items displays error responses (e.g. service-unavailable) to the user, per XEP-0030 Section 7.
This commit is contained in:
@@ -186,6 +186,7 @@ functionaltest_sources = \
|
|||||||
tests/functionaltests/test_muc.c tests/functionaltests/test_muc.h \
|
tests/functionaltests/test_muc.c tests/functionaltests/test_muc.h \
|
||||||
tests/functionaltests/test_disconnect.c tests/functionaltests/test_disconnect.h \
|
tests/functionaltests/test_disconnect.c tests/functionaltests/test_disconnect.h \
|
||||||
tests/functionaltests/test_lastactivity.c tests/functionaltests/test_lastactivity.h \
|
tests/functionaltests/test_lastactivity.c tests/functionaltests/test_lastactivity.h \
|
||||||
|
tests/functionaltests/test_disco.c tests/functionaltests/test_disco.h \
|
||||||
tests/functionaltests/functionaltests.c
|
tests/functionaltests/functionaltests.c
|
||||||
|
|
||||||
main_source = src/main.c
|
main_source = src/main.c
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "test_muc.h"
|
#include "test_muc.h"
|
||||||
#include "test_disconnect.h"
|
#include "test_disconnect.h"
|
||||||
#include "test_lastactivity.h"
|
#include "test_lastactivity.h"
|
||||||
|
#include "test_disco.h"
|
||||||
|
|
||||||
/* Macro to wrap each test with setup/teardown functions */
|
/* Macro to wrap each test with setup/teardown functions */
|
||||||
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
|
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
|
||||||
@@ -143,7 +144,7 @@ main(int argc, char* argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* GROUP 3: Presence, Disconnect
|
* GROUP 3: Presence, Disconnect, Disco
|
||||||
* Online/away/xa/dnd/chat status management
|
* Online/away/xa/dnd/chat status management
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
const struct CMUnitTest group3_tests[] = {
|
const struct CMUnitTest group3_tests[] = {
|
||||||
@@ -165,6 +166,9 @@ main(int argc, char* argv[])
|
|||||||
|
|
||||||
/* Disconnect - clean session termination */
|
/* Disconnect - clean session termination */
|
||||||
PROF_FUNC_TEST(disconnect_ends_session),
|
PROF_FUNC_TEST(disconnect_ends_session),
|
||||||
|
|
||||||
|
/* Service Discovery - XEP-0030 */
|
||||||
|
PROF_FUNC_TEST(disco_items_error_handling),
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
@@ -214,7 +218,7 @@ main(int argc, char* argv[])
|
|||||||
} groups[] = {
|
} groups[] = {
|
||||||
{ "Group 1: Connect/Ping/Rooms/Software", group1_tests, ARRAY_SIZE(group1_tests) },
|
{ "Group 1: Connect/Ping/Rooms/Software", group1_tests, ARRAY_SIZE(group1_tests) },
|
||||||
{ "Group 2: Message/Receipts/Roster/Session", group2_tests, ARRAY_SIZE(group2_tests) },
|
{ "Group 2: Message/Receipts/Roster/Session", group2_tests, ARRAY_SIZE(group2_tests) },
|
||||||
{ "Group 3: Presence/Disconnect", group3_tests, ARRAY_SIZE(group3_tests) },
|
{ "Group 3: Presence/Disconnect/Disco", group3_tests, ARRAY_SIZE(group3_tests) },
|
||||||
{ "Group 4: MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
|
{ "Group 4: MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
|
||||||
};
|
};
|
||||||
const int num_groups = ARRAY_SIZE(groups);
|
const int num_groups = ARRAY_SIZE(groups);
|
||||||
|
|||||||
36
tests/functionaltests/test_disco.c
Normal file
36
tests/functionaltests/test_disco.c
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include <glib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <cmocka.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <stabber.h>
|
||||||
|
|
||||||
|
#include "proftest.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
disco_items_error_handling(void **state)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Test that /disco items displays error responses to user.
|
||||||
|
* Per XEP-0030 Section 7: errors like service-unavailable must be shown.
|
||||||
|
*/
|
||||||
|
stbbr_for_query("http://jabber.org/protocol/disco#items",
|
||||||
|
"<iq to='stabber@localhost/profanity' type='error' from='broken.localhost'>"
|
||||||
|
"<error type='cancel'>"
|
||||||
|
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
|
||||||
|
"</error>"
|
||||||
|
"</iq>"
|
||||||
|
);
|
||||||
|
|
||||||
|
prof_connect();
|
||||||
|
|
||||||
|
prof_input("/disco items broken.localhost");
|
||||||
|
|
||||||
|
prof_timeout(10);
|
||||||
|
/* Per XEP-0030, error should be displayed to user */
|
||||||
|
assert_true(prof_output_regex("Service discovery failed.*service-unavailable"));
|
||||||
|
prof_timeout_reset();
|
||||||
|
}
|
||||||
1
tests/functionaltests/test_disco.h
Normal file
1
tests/functionaltests/test_disco.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
void disco_items_error_handling(void** state);
|
||||||
Reference in New Issue
Block a user