1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-08-11 18:54:16 -04:00
profanity/stabbertests/test_connect.c

51 lines
1.2 KiB
C
Raw Normal View History

2015-05-16 20:11:03 -04:00
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
2015-05-17 17:05:43 -04:00
#include <string.h>
#include <stabber.h>
#include "proftest.h"
#include "xmpp/xmpp.h"
#include "ui/stub_ui.h"
#include "command/command.h"
2015-05-16 20:11:03 -04:00
void
2015-05-23 19:56:13 -04:00
connect_jid(void **state)
2015-05-16 20:11:03 -04:00
{
2015-05-17 17:05:43 -04:00
char *connect = "/connect stabber@localhost port 5230";
char *password = "password";
stbbr_auth_passwd(password);
will_return(ui_ask_password, strdup(password));
expect_cons_show("Connecting as stabber@localhost");
cmd_process_input(strdup(connect));
prof_process_xmpp();
jabber_conn_status_t status = jabber_get_connection_status();
assert_true(status == JABBER_CONNECTED);
2015-05-16 20:11:03 -04:00
}
2015-05-23 19:56:13 -04:00
void
connect_bad_password(void **state)
{
char *connect = "/connect stabber@localhost port 5230";
stbbr_auth_passwd("password");
will_return(ui_ask_password, strdup("badpassword"));
expect_cons_show("Connecting as stabber@localhost");
expect_cons_show_error("Login failed.");
cmd_process_input(strdup(connect));
prof_process_xmpp();
jabber_conn_status_t status = jabber_get_connection_status();
assert_true(status == JABBER_DISCONNECTED);
}