Files
cproof/tests/functionaltests/test_disco.c
Jabber Developer 770a46c1c9
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
tests: Add disco tests
2026-02-02 17:43:29 +01:00

121 lines
4.0 KiB
C

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