Files
cproof/tests/functionaltests/test_roster.c
jabber.developer2 caac08a7d7
Some checks failed
CI Code / Linux (debian) (pull_request) Waiting to run
CI Code / Linux (ubuntu) (pull_request) Waiting to run
CI Code / Check spelling (pull_request) Successful in 20s
CI Code / Check coding style (pull_request) Successful in 34s
CI Code / Linux (arch) (pull_request) Failing after 3h11m46s
fix(tests): replace libexpect with forkpty() for functional tests
Remove dependency on libexpect which had a segfault bug on Arch Linux.

- Replace exp_spawnl() with forkpty() for PTY creation
- Replace exp_expectl() with custom POSIX regex matching
- Update configure.ac to check for forkpty() instead of libexpect
- Update Makefile.am to link with libutil instead of libexpect/libtcl
- Remove expect/tcl packages from all Dockerfiles
- Add Valgrind suppressions for stabber/pthread false positives
2025-12-29 21:19:30 +03:00

139 lines
3.5 KiB
C

#include <glib.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <stabber.h>
#include "proftest.h"
void
sends_new_item(void **state)
{
prof_connect();
stbbr_for_query("jabber:iq:roster",
"<iq type='set' from='stabber@localhost'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name=''/>"
"</query>"
"</iq>"
);
prof_input("/roster add bob@localhost");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name=''/>"
"</query>"
"</iq>"
));
assert_true(prof_output_exact("Roster item added: bob@localhost"));
}
void
sends_new_item_nick(void **state)
{
prof_connect();
stbbr_for_query("jabber:iq:roster",
"<iq type='set' from='stabber@localhost'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name='Bobby'/>"
"</query>"
"</iq>"
);
prof_input("/roster add bob@localhost Bobby");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name='Bobby'/>"
"</query>"
"</iq>"
));
assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)"));
}
void
sends_remove_item(void **state)
{
prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both'/>"
"<item jid='buddy2@localhost' subscription='both'/>"
);
stbbr_for_query("jabber:iq:roster",
"<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
);
prof_input("/roster remove buddy1@localhost");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
));
assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
}
void
sends_remove_item_nick(void **state)
{
prof_connect_with_roster(
"<item jid='buddy1@localhost' name='Bobby' subscription='both'/>"
"<item jid='buddy2@localhost' subscription='both'/>"
);
stbbr_for_query("jabber:iq:roster",
"<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
);
prof_input("/roster remove Bobby");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
));
assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
}
void
sends_nick_change(void **state)
{
prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both'/>"
);
prof_input("/roster nick buddy1@localhost Buddy1");
assert_true(prof_output_exact("Nickname for buddy1@localhost set to: Buddy1."));
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' name='Buddy1'/>"
"</query>"
"</iq>"
));
}