diff --git a/external/stabber b/external/stabber
index 3e5c2200..14b664f4 160000
--- a/external/stabber
+++ b/external/stabber
@@ -1 +1 @@
-Subproject commit 3e5c2200715666aad403d0076e8ab584b329965e
+Subproject commit 14b664f4c74b7feb3204ac7128b3d22e12f44721
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index ab779075..bc2e546a 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -140,7 +140,7 @@ static const struct cmd_t command_defs[] = {
},
{ CMD_PREAMBLE("/connect",
- parse_args, 0, 7, NULL)
+ parse_args, 0, 9, NULL)
CMD_MAINFUNC(cmd_connect)
CMD_TAGS(
CMD_TAG_CONNECTION)
diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index d924bfb5..222f33e4 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -27,16 +27,16 @@ int main(int argc, char* argv[]) {
const struct CMUnitTest all_tests[] = {
PROF_FUNC_TEST(connect_jid_requests_roster),
- // PROF_FUNC_TEST(connect_jid_sends_presence_after_receiving_roster),
- // PROF_FUNC_TEST(connect_jid_requests_bookmarks),
- // PROF_FUNC_TEST(connect_bad_password),
- // PROF_FUNC_TEST(connect_shows_presence_updates),
+ PROF_FUNC_TEST(connect_jid_sends_presence_after_receiving_roster),
+ PROF_FUNC_TEST(connect_jid_requests_bookmarks),
+ PROF_FUNC_TEST(connect_bad_password),
+ PROF_FUNC_TEST(connect_shows_presence_updates),
- // PROF_FUNC_TEST(ping_server),
- // PROF_FUNC_TEST(ping_server_not_supported),
- // PROF_FUNC_TEST(ping_responds_to_server_request),
- // PROF_FUNC_TEST(ping_jid),
- // PROF_FUNC_TEST(ping_jid_not_supported),
+ PROF_FUNC_TEST(ping_server),
+ PROF_FUNC_TEST(ping_server_not_supported),
+ PROF_FUNC_TEST(ping_responds_to_server_request),
+ PROF_FUNC_TEST(ping_jid),
+ PROF_FUNC_TEST(ping_jid_not_supported),
// PROF_FUNC_TEST(rooms_query),
diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c
index c5fa27ee..bfe80934 100644
--- a/tests/functionaltests/proftest.c
+++ b/tests/functionaltests/proftest.c
@@ -139,23 +139,22 @@ prof_start(void)
int
init_prof_test(void **state)
{
- fprintf(stderr, "\n[TEST] init_prof_test() called\n");
gboolean started = FALSE;
for (int p = 5230; p < 5250; ++p) {
- fprintf(stderr, "[TEST] Trying to start stabber on port %d\n", p);
if (stbbr_start(STBBR_LOGDEBUG, p, 0) == 0) {
stub_port = p;
- fprintf(stderr, "[TEST] Stabber started successfully on port %d\n", p);
started = TRUE;
break;
}
- fprintf(stderr, "[TEST] Port %d failed, trying next\n", p);
}
if (!started) {
assert_true(FALSE); // could not start stabber on any port in range
return -1;
}
+ // Give stabber server thread time to start listening
+ usleep(100000); // 100ms
+
config_orig = getenv("XDG_CONFIG_HOME");
data_orig = getenv("XDG_DATA_HOME");
@@ -206,12 +205,20 @@ init_prof_test(void **state)
int
close_prof_test(void **state)
{
- prof_input("/quit");
- waitpid(exp_pid, NULL, 0);
+ if (fd > 0) {
+ prof_input("/quit");
+ // Give profanity time to process quit command
+ sleep(1);
+ waitpid(exp_pid, NULL, 0);
+ }
_cleanup_dirs();
- setenv("XDG_CONFIG_HOME", config_orig, 1);
- setenv("XDG_DATA_HOME", data_orig, 1);
+ if (config_orig) {
+ setenv("XDG_CONFIG_HOME", config_orig, 1);
+ }
+ if (data_orig) {
+ setenv("XDG_DATA_HOME", data_orig, 1);
+ }
stbbr_stop();
return 0;
@@ -255,67 +262,26 @@ prof_connect_with_roster(const char *roster)
stbbr_for_query("jabber:iq:roster", roster_str->str);
g_string_free(roster_str, TRUE);
- // Set up stabber to expect password "password"
stbbr_auth_passwd("password");
char connect_cmd[128];
- snprintf(connect_cmd, sizeof(connect_cmd), "/connect stabber@localhost server 127.0.0.1 port %d tls disable", stub_port);
- fprintf(stderr, "\n[TEST] Sending connect command: %s\n", connect_cmd);
- fprintf(stderr, "[TEST] stub_port = %d\n", stub_port);
+ snprintf(connect_cmd, sizeof(connect_cmd), "/connect stabber@localhost server 127.0.0.1 port %d tls disable auth legacy", stub_port);
prof_input(connect_cmd);
- // Check password prompt appears
assert_true(prof_output_regex("password:"));
-
prof_input("password");
- // Allow time for profanity to connect
exp_timeout = 60;
-
- // First check: did we get any connection message?
- gboolean got_connecting = prof_output_regex("Connecting as stabber@localhost");
- gboolean got_success = FALSE;
- gboolean got_failure = FALSE;
-
- if (got_connecting) {
- fprintf(stderr, "\nDEBUG: Saw 'Connecting as' message, waiting longer for result...\n");
- sleep(5); // Give extra time for SASL + bind
-
- // Try to dump whatever is on the screen by sending Enter and reading response
- prof_input("");
- usleep(500000); // 0.5s
-
- // Now wait for success or failure
- got_success = prof_output_regex("logged in successfully");
- if (!got_success) {
- got_failure = prof_output_regex("failed|Failed|error|Error|disconnect|Disconnect");
- if (!got_failure) {
- fprintf(stderr, "\nDEBUG: No success or failure after 5s, sending /who to trigger output...\n");
- // Send a command to see if connection is actually established
- prof_input("/who");
- usleep(500000);
- got_success = prof_output_regex("logged in successfully|online");
- }
- }
- } else {
- // Maybe we went straight to success?
- got_success = prof_output_regex("logged in successfully");
- }
-
- fprintf(stderr, "\nDEBUG: got_connecting=%d got_success=%d got_failure=%d\n",
- got_connecting, got_success, got_failure);
-
- if (got_success) {
- assert_true(prof_output_regex(".+online.+ \\(priority 0\\)\\."));
- } else {
- assert_true(FALSE);
- }
+ assert_true(prof_output_regex("Connecting as stabber@localhost"));
+ assert_true(prof_output_regex("logged in successfully"));
+ assert_true(prof_output_regex(".+online.+ \\(priority 0\\)\\."));
exp_timeout = 10;
// Wait for presence stanza to be sent (content-based, not ID-based)
+ // Match the actual attribute order from stanza_attach_caps
assert_true(stbbr_received(
""
- ""
+ ""
""
));
}
diff --git a/tests/functionaltests/test_ping.c b/tests/functionaltests/test_ping.c
index d3936358..ec555c18 100644
--- a/tests/functionaltests/test_ping.c
+++ b/tests/functionaltests/test_ping.c
@@ -2,6 +2,7 @@
#include "prof_cmocka.h"
#include
#include
+#include
#include
#include
@@ -23,26 +24,35 @@ ping_server(void **state)
// Respond to ping IQs independent of the request id
stbbr_for_query("urn:xmpp:ping",
- ""
+ ""
);
prof_connect();
+
+ // Give profanity time to process disco#info
+ sleep(2);
prof_input("/ping");
+ // Check that ping IQ was sent
assert_true(stbbr_received(
- ""
+ ""
""
""
));
- assert_true(prof_output_exact("Ping response from server"));
+ // Now check for the response message
+ prof_timeout(30);
+ assert_true(prof_output_regex("Ping response from server"));
+ prof_timeout_reset();
prof_input("/ping");
assert_true(stbbr_received(
- ""
+ ""
""
""
));
- assert_true(prof_output_exact("Ping response from server"));
+ prof_timeout(30);
+ assert_true(prof_output_regex("Ping response from server"));
+ prof_timeout_reset();
}
void
@@ -59,7 +69,7 @@ ping_server_not_supported(void **state)
prof_connect();
prof_input("/ping");
- assert_true(prof_output_exact("Server does not support ping requests."));
+ assert_true(prof_output_regex("Server does not support ping requests"));
}
void
@@ -68,13 +78,13 @@ ping_responds_to_server_request(void **state)
prof_connect();
stbbr_send(
- ""
- ""
+ ""
+ ""
""
);
assert_true(stbbr_received(
- ""
+ ""
));
}
@@ -109,7 +119,7 @@ void ping_jid(void **state)
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received(
- ""
+ ""
""
""
));
@@ -122,11 +132,11 @@ void ping_jid(void **state)
prof_input("/ping buddy1@localhost/mobile");
assert_true(stbbr_received(
- ""
+ ""
""
""
));
- assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile"));
+ assert_true(prof_output_regex("Ping response from buddy1@localhost/mobile"));
}
void ping_jid_not_supported(void **state)
@@ -158,7 +168,7 @@ void ping_jid_not_supported(void **state)
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received(
- ""
+ ""
""
""
));