2020-07-07 03:43:28 -04:00
|
|
|
#include <cmocka.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <setjmp.h>
|
2013-12-14 11:17:53 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
2013-12-15 14:38:23 -05:00
|
|
|
#include <string.h>
|
2013-12-14 11:17:53 -05:00
|
|
|
|
|
|
|
#include "xmpp/xmpp.h"
|
2013-12-18 18:06:43 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
#include "ui/stub_ui.h"
|
2020-07-07 03:43:28 -04:00
|
|
|
#include "ui/ui.h"
|
2013-12-18 18:06:43 -05:00
|
|
|
|
2016-05-22 18:59:52 -04:00
|
|
|
#include "command/cmd_funcs.h"
|
2013-12-26 08:37:22 -05:00
|
|
|
#include "config/accounts.h"
|
2013-12-18 17:49:43 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
#define CMD_CONNECT "/connect"
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
static void
|
|
|
|
test_with_connection_status(jabber_conn_status_t status)
|
2013-12-14 11:17:53 -05:00
|
|
|
{
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, status);
|
2013-12-18 17:49:43 -05:00
|
|
|
|
2014-04-12 10:20:19 -04:00
|
|
|
expect_cons_show("You are either connected already, or a login is in process.");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, NULL);
|
2013-12-14 13:43:19 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_disconnecting(void** state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
|
|
|
test_with_connection_status(JABBER_DISCONNECTING);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_connecting(void** state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
|
|
|
test_with_connection_status(JABBER_CONNECTING);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_connected(void** state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
2013-12-15 13:08:26 -05:00
|
|
|
test_with_connection_status(JABBER_CONNECTED);
|
2013-12-14 13:43:19 -05:00
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_when_no_account(void** state)
|
2015-07-26 19:04:48 -04:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", NULL };
|
2015-07-26 19:04:48 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
expect_string(accounts_get_account, name, "user@server.org");
|
|
|
|
will_return(accounts_get_account, NULL);
|
|
|
|
|
|
|
|
will_return(ui_ask_password, strdup("password"));
|
|
|
|
|
|
|
|
expect_cons_show("Connecting as user@server.org");
|
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_string(session_connect_with_details, jid, "user@server.org");
|
|
|
|
expect_string(session_connect_with_details, passwd, "password");
|
|
|
|
expect_value(session_connect_with_details, altdomain, NULL);
|
|
|
|
expect_value(session_connect_with_details, port, 0);
|
|
|
|
will_return(session_connect_with_details, JABBER_CONNECTING);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_fail_message(void** state)
|
2015-07-26 19:04:48 -04:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", NULL };
|
2015-07-26 19:04:48 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
expect_any(accounts_get_account, name);
|
|
|
|
will_return(accounts_get_account, NULL);
|
|
|
|
|
|
|
|
will_return(ui_ask_password, strdup("password"));
|
|
|
|
|
|
|
|
expect_cons_show("Connecting as user@server.org");
|
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_any(session_connect_with_details, jid);
|
|
|
|
expect_any(session_connect_with_details, passwd);
|
|
|
|
expect_any(session_connect_with_details, altdomain);
|
|
|
|
expect_any(session_connect_with_details, port);
|
|
|
|
will_return(session_connect_with_details, JABBER_DISCONNECTED);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
expect_cons_show_error("Connection attempt for user@server.org failed.");
|
|
|
|
|
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_lowercases_argument_with_no_account(void** state)
|
2015-07-26 19:04:48 -04:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "USER@server.ORG", NULL };
|
2015-07-26 19:04:48 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
2019-02-22 05:07:19 -05:00
|
|
|
expect_string(accounts_get_account, name, "USER@server.ORG");
|
2015-07-26 19:04:48 -04:00
|
|
|
will_return(accounts_get_account, NULL);
|
|
|
|
|
|
|
|
will_return(ui_ask_password, strdup("password"));
|
|
|
|
|
|
|
|
expect_cons_show("Connecting as user@server.org");
|
|
|
|
|
2019-02-22 05:07:19 -05:00
|
|
|
expect_string(session_connect_with_details, jid, "user@server.org");
|
|
|
|
expect_string(session_connect_with_details, passwd, "password");
|
|
|
|
expect_value(session_connect_with_details, altdomain, NULL);
|
|
|
|
expect_value(session_connect_with_details, port, 0);
|
2016-05-05 19:53:03 -04:00
|
|
|
will_return(session_connect_with_details, JABBER_CONNECTING);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_lowercases_argument_with_account(void** state)
|
2019-02-22 05:07:19 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "Jabber_org", NULL };
|
|
|
|
ProfAccount* account = account_new("Jabber_org", "me@jabber.org", "password", NULL,
|
|
|
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
2019-02-22 05:07:19 -05:00
|
|
|
|
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
|
|
|
|
|
|
|
expect_any(accounts_get_account, name);
|
|
|
|
will_return(accounts_get_account, account);
|
|
|
|
|
|
|
|
expect_cons_show("Connecting with account Jabber_org as me@jabber.org");
|
|
|
|
|
|
|
|
expect_memory(session_connect_with_account, account, account, sizeof(account));
|
|
|
|
will_return(session_connect_with_account, JABBER_CONNECTING);
|
|
|
|
|
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_asks_password_when_not_in_account(void** state)
|
2015-07-26 19:04:48 -04:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "jabber_org", NULL };
|
|
|
|
ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
|
|
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
expect_any(accounts_get_account, name);
|
|
|
|
will_return(accounts_get_account, account);
|
|
|
|
|
|
|
|
will_return(ui_ask_password, strdup("password"));
|
|
|
|
|
|
|
|
expect_cons_show("Connecting with account jabber_org as me@jabber.org");
|
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_any(session_connect_with_account, account);
|
|
|
|
will_return(session_connect_with_account, JABBER_CONNECTING);
|
2015-07-26 19:04:48 -04:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_no_server_value(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "server", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 16:18:25 -05:00
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_server_no_port_value(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "server", "aserver", "port", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 16:18:25 -05:00
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_no_port_value(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 16:18:25 -05:00
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_port_no_server_value(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "5678", "server", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 16:18:25 -05:00
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_port_0(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "0", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
|
|
|
expect_cons_show("Value 0 out of range. Must be in 1..65535.");
|
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_port_minus1(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "-1", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
|
|
|
expect_cons_show("Value -1 out of range. Must be in 1..65535.");
|
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_port_65536(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "65536", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
|
|
|
expect_cons_show("Value 65536 out of range. Must be in 1..65535.");
|
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 16:18:25 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_port_contains_chars(void** state)
|
2014-01-18 16:18:25 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "52f66", NULL };
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 16:18:25 -05:00
|
|
|
|
|
|
|
expect_cons_show("Could not convert \"52f66\" to a number.");
|
|
|
|
expect_cons_show("");
|
2014-01-18 17:45:24 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:45:24 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_server_provided_twice(void** state)
|
2014-01-18 17:45:24 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
|
2014-01-18 17:45:24 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 17:45:24 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 17:45:24 -05:00
|
|
|
expect_cons_show("");
|
2014-01-18 17:50:17 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:50:17 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_port_provided_twice(void** state)
|
2014-01-18 17:50:17 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
|
2014-01-18 17:50:17 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 17:50:17 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 17:50:17 -05:00
|
|
|
expect_cons_show("");
|
2014-01-18 17:55:15 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:55:15 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_invalid_first_property(void** state)
|
2014-01-18 17:55:15 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "wrong", "server", NULL };
|
2014-01-18 17:55:15 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 17:55:15 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 17:55:15 -05:00
|
|
|
expect_cons_show("");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:55:15 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_usage_when_invalid_second_property(void** state)
|
2014-01-18 17:55:15 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
|
2014-01-18 17:55:15 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-01-18 17:55:15 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
2014-01-18 17:55:15 -05:00
|
|
|
expect_cons_show("");
|
2014-01-18 16:18:25 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:02:51 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_with_server_when_provided(void** state)
|
2014-01-18 17:02:51 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "server", "aserver", NULL };
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-12-24 16:34:11 -05:00
|
|
|
|
|
|
|
expect_string(accounts_get_account, name, "user@server.org");
|
|
|
|
will_return(accounts_get_account, NULL);
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
will_return(ui_ask_password, strdup("password"));
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
expect_cons_show("Connecting as user@server.org");
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_string(session_connect_with_details, jid, "user@server.org");
|
|
|
|
expect_string(session_connect_with_details, passwd, "password");
|
|
|
|
expect_string(session_connect_with_details, altdomain, "aserver");
|
|
|
|
expect_value(session_connect_with_details, port, 0);
|
|
|
|
will_return(session_connect_with_details, JABBER_CONNECTING);
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:02:51 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_with_port_when_provided(void** state)
|
2014-01-18 17:02:51 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "5432", NULL };
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-12-24 16:34:11 -05:00
|
|
|
|
|
|
|
expect_string(accounts_get_account, name, "user@server.org");
|
|
|
|
will_return(accounts_get_account, NULL);
|
2013-12-15 15:38:26 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
will_return(ui_ask_password, strdup("password"));
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
expect_cons_show("Connecting as user@server.org");
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_string(session_connect_with_details, jid, "user@server.org");
|
|
|
|
expect_string(session_connect_with_details, passwd, "password");
|
|
|
|
expect_value(session_connect_with_details, altdomain, NULL);
|
|
|
|
expect_value(session_connect_with_details, port, 5432);
|
|
|
|
will_return(session_connect_with_details, JABBER_CONNECTING);
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2014-01-18 17:02:51 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_with_server_and_port_when_provided(void** state)
|
2014-01-18 17:02:51 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-12-24 16:34:11 -05:00
|
|
|
|
|
|
|
expect_string(accounts_get_account, name, "user@server.org");
|
|
|
|
will_return(accounts_get_account, NULL);
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
will_return(ui_ask_password, strdup("password"));
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
expect_cons_show("Connecting as user@server.org");
|
2014-01-18 17:02:51 -05:00
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_string(session_connect_with_details, jid, "user@server.org");
|
|
|
|
expect_string(session_connect_with_details, passwd, "password");
|
|
|
|
expect_string(session_connect_with_details, altdomain, "aserver");
|
|
|
|
expect_value(session_connect_with_details, port, 5432);
|
|
|
|
will_return(session_connect_with_details, JABBER_CONNECTING);
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2013-12-15 14:56:48 -05:00
|
|
|
assert_true(result);
|
2013-12-15 15:52:30 -05:00
|
|
|
}
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_shows_message_when_connecting_with_account(void** state)
|
2013-12-15 16:23:58 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "jabber_org", NULL };
|
|
|
|
ProfAccount* account = account_new("jabber_org", "user@jabber.org", "password", NULL,
|
|
|
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
expect_any(accounts_get_account, name);
|
|
|
|
will_return(accounts_get_account, account);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2013-12-19 16:05:39 -05:00
|
|
|
expect_cons_show("Connecting with account jabber_org as user@jabber.org/laptop");
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_any(session_connect_with_account, account);
|
|
|
|
will_return(session_connect_with_account, JABBER_CONNECTING);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2013-12-15 16:31:27 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_connect_connects_with_account(void** state)
|
2013-12-15 16:31:27 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { "jabber_org", NULL };
|
|
|
|
ProfAccount* account = account_new("jabber_org", "me@jabber.org", "password", NULL,
|
|
|
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2014-12-24 16:34:11 -05:00
|
|
|
|
|
|
|
expect_any(accounts_get_account, name);
|
|
|
|
will_return(accounts_get_account, account);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2014-12-24 16:34:11 -05:00
|
|
|
expect_cons_show("Connecting with account jabber_org as me@jabber.org");
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
expect_memory(session_connect_with_account, account, account, sizeof(account));
|
|
|
|
will_return(session_connect_with_account, JABBER_CONNECTING);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
2013-12-15 16:23:58 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|