Files
cproof/tests/functionaltests/test_disco.c
jabber.developer2 a2a2db7c45 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.
2026-02-16 11:16:01 +03:00

37 lines
968 B
C

#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();
}