Compare commits
3 Commits
fix/xep-00
...
ci/separat
| Author | SHA1 | Date | |
|---|---|---|---|
|
d4254db814
|
|||
|
31538580fb
|
|||
|
37ca2de308
|
14
.github/workflows/ci-code.yml
vendored
14
.github/workflows/ci-code.yml
vendored
@@ -29,10 +29,10 @@ jobs:
|
||||
name: Linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: docker build -f Dockerfile.${{ matrix.flavor }} -t profanity .
|
||||
- name: Run tests
|
||||
run: |
|
||||
docker build -f Dockerfile.${{ matrix.flavor }} -t profanity .
|
||||
docker run profanity ./ci-build.sh
|
||||
run: docker run profanity ./ci-build.sh
|
||||
|
||||
code-style:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -107,7 +107,7 @@ jobs:
|
||||
name: Code Coverage
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build and run coverage
|
||||
run: |
|
||||
docker build -f Dockerfile.arch -t profanity-cov .
|
||||
docker run profanity-cov ./ci-build.sh --coverage-only
|
||||
- name: Build
|
||||
run: docker build -f Dockerfile.arch -t profanity-cov .
|
||||
- name: Run coverage
|
||||
run: docker run profanity-cov ./ci-build.sh --coverage-only
|
||||
@@ -1,9 +1,10 @@
|
||||
FROM archlinux
|
||||
FROM archlinux:latest
|
||||
|
||||
ENV TERM=xterm
|
||||
ENV CC="ccache gcc"
|
||||
|
||||
RUN pacman -Syu --noconfirm
|
||||
RUN pacman -Syyu --noconfirm
|
||||
|
||||
# reflector is optional - if it fails due to network issues, continue with default mirrorlist
|
||||
RUN pacman -S --needed --noconfirm reflector && \
|
||||
(reflector --latest 20 --protocol https --sort rate --save /etc/pacman.d/mirrorlist || true)
|
||||
|
||||
@@ -186,7 +186,6 @@ functionaltest_sources = \
|
||||
tests/functionaltests/test_muc.c tests/functionaltests/test_muc.h \
|
||||
tests/functionaltests/test_disconnect.c tests/functionaltests/test_disconnect.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
|
||||
|
||||
main_source = src/main.c
|
||||
|
||||
@@ -86,7 +86,6 @@ extract_test_count() {
|
||||
# and checks that the test framework reports the failure correctly
|
||||
verify_test_failure_detection()
|
||||
{
|
||||
echo
|
||||
echo "==> Verifying test failure detection..."
|
||||
|
||||
# Create a simple failing test
|
||||
|
||||
@@ -129,7 +129,6 @@ static void _ping_get_handler(xmpp_stanza_t* const stanza);
|
||||
static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _disco_items_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx);
|
||||
static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
@@ -204,11 +203,7 @@ _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const us
|
||||
_disco_items_get_handler(stanza);
|
||||
}
|
||||
if (discoitems && (g_strcmp0(type, STANZA_TYPE_RESULT) == 0)) {
|
||||
// Only handle onconnect here, user requests use id_handler
|
||||
const char* id = xmpp_stanza_get_id(stanza);
|
||||
if (g_strcmp0(id, "discoitemsreq_onconnect") == 0) {
|
||||
_disco_items_result_handler(stanza);
|
||||
}
|
||||
_disco_items_result_handler(stanza);
|
||||
}
|
||||
|
||||
xmpp_stanza_t* lastactivity = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LASTACTIVITY);
|
||||
@@ -642,11 +637,7 @@ void
|
||||
iq_disco_items_request(const char* jid)
|
||||
{
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
auto_char char* id = connection_create_stanza_id();
|
||||
xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, id, jid, NULL);
|
||||
|
||||
iq_id_handler_add(id, _disco_items_response_id_handler, NULL, NULL);
|
||||
|
||||
xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, "discoitemsreq", jid, NULL);
|
||||
iq_send_stanza(iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
@@ -2523,12 +2514,13 @@ _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userda
|
||||
static void
|
||||
_disco_items_result_handler(xmpp_stanza_t* const stanza)
|
||||
{
|
||||
// This handler is only for onconnect disco#items requests
|
||||
log_debug("Received disco#items response (onconnect)");
|
||||
log_debug("Received disco#items response");
|
||||
const char* id = xmpp_stanza_get_id(stanza);
|
||||
const char* from = xmpp_stanza_get_from(stanza);
|
||||
GSList* items = NULL;
|
||||
|
||||
if (g_strcmp0(id, "discoitemsreq_onconnect") != 0) {
|
||||
if ((g_strcmp0(id, "discoitemsreq") != 0) && (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) {
|
||||
log_warning("_disco_items_result_handler: Received unexpected disco id: %s", id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2563,80 +2555,23 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza)
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
|
||||
connection_set_disco_items(items);
|
||||
if (g_strcmp0(id, "discoitemsreq") == 0) {
|
||||
cons_show_disco_items(items, from);
|
||||
} else if (g_strcmp0(id, "discoitemsreq_onconnect") == 0) {
|
||||
connection_set_disco_items(items);
|
||||
|
||||
while (late_delivery_windows) {
|
||||
LateDeliveryUserdata* del_data = late_delivery_windows->data;
|
||||
_iq_mam_request(del_data->win, del_data->startdate, del_data->enddate);
|
||||
free(del_data);
|
||||
late_delivery_windows = g_slist_delete_link(late_delivery_windows,
|
||||
late_delivery_windows);
|
||||
while (late_delivery_windows) {
|
||||
LateDeliveryUserdata* del_data = late_delivery_windows->data;
|
||||
_iq_mam_request(del_data->win, del_data->startdate, del_data->enddate);
|
||||
free(del_data);
|
||||
late_delivery_windows = g_slist_delete_link(late_delivery_windows,
|
||||
late_delivery_windows);
|
||||
}
|
||||
}
|
||||
|
||||
g_slist_free_full(items, (GDestroyNotify)_item_destroy);
|
||||
}
|
||||
|
||||
static int
|
||||
_disco_items_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
const char* from = xmpp_stanza_get_from(stanza);
|
||||
const char* type = xmpp_stanza_get_type(stanza);
|
||||
|
||||
if (from) {
|
||||
log_debug("Received disco#items response from: %s", from);
|
||||
} else {
|
||||
log_debug("Received disco#items response");
|
||||
}
|
||||
|
||||
// Handle error responses
|
||||
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
|
||||
auto_char char* error_message = stanza_get_error_message(stanza);
|
||||
if (from) {
|
||||
cons_show_error("Service discovery failed for %s: %s", from, error_message);
|
||||
} else {
|
||||
cons_show_error("Service discovery failed: %s", error_message);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Handle result responses
|
||||
xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
if (query == NULL) {
|
||||
cons_show_disco_items(NULL, from);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GSList* items = NULL;
|
||||
xmpp_stanza_t* child = xmpp_stanza_get_children(query);
|
||||
|
||||
while (child) {
|
||||
const char* stanza_name = xmpp_stanza_get_name(child);
|
||||
if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
|
||||
const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
if (item_jid) {
|
||||
DiscoItem* item = malloc(sizeof(struct disco_item_t));
|
||||
if (item) {
|
||||
item->jid = strdup(item_jid);
|
||||
const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
|
||||
if (item_name) {
|
||||
item->name = strdup(item_name);
|
||||
} else {
|
||||
item->name = NULL;
|
||||
}
|
||||
items = g_slist_append(items, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
|
||||
cons_show_disco_items(items, from);
|
||||
g_slist_free_full(items, (GDestroyNotify)_item_destroy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
iq_feature_retrieval_complete_handler(void)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "test_muc.h"
|
||||
#include "test_disconnect.h"
|
||||
#include "test_lastactivity.h"
|
||||
#include "test_disco.h"
|
||||
|
||||
/* 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)
|
||||
@@ -144,7 +143,7 @@ main(int argc, char* argv[])
|
||||
};
|
||||
|
||||
/* ============================================================
|
||||
* GROUP 3: Presence, Disconnect, Disco
|
||||
* GROUP 3: Presence, Disconnect
|
||||
* Online/away/xa/dnd/chat status management
|
||||
* ============================================================ */
|
||||
const struct CMUnitTest group3_tests[] = {
|
||||
@@ -166,9 +165,6 @@ main(int argc, char* argv[])
|
||||
|
||||
/* Disconnect - clean session termination */
|
||||
PROF_FUNC_TEST(disconnect_ends_session),
|
||||
|
||||
/* Service Discovery - XEP-0030 */
|
||||
PROF_FUNC_TEST(disco_items_error_handling),
|
||||
};
|
||||
|
||||
/* ============================================================
|
||||
@@ -218,7 +214,7 @@ main(int argc, char* argv[])
|
||||
} groups[] = {
|
||||
{ "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 3: Presence/Disconnect/Disco", group3_tests, ARRAY_SIZE(group3_tests) },
|
||||
{ "Group 3: Presence/Disconnect", group3_tests, ARRAY_SIZE(group3_tests) },
|
||||
{ "Group 4: MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
|
||||
};
|
||||
const int num_groups = ARRAY_SIZE(groups);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#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 +0,0 @@
|
||||
void disco_items_error_handling(void** state);
|
||||
Reference in New Issue
Block a user