1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00
profanity/tests/functionaltests/test_connect.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

96 lines
2.3 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>
2015-05-26 18:22:05 -04:00
#include <expect.h>
2015-05-17 17:05:43 -04:00
#include "proftest.h"
2015-05-16 20:11:03 -04:00
2015-05-26 20:06:17 -04:00
void
connect_jid_requests_roster(void **state)
{
2015-06-13 14:41:11 -04:00
prof_connect();
2015-05-26 20:06:17 -04:00
2015-05-27 18:11:58 -04:00
assert_true(stbbr_received(
"<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>"
2015-05-26 20:06:17 -04:00
));
}
void
connect_jid_sends_presence_after_receiving_roster(void **state)
2015-05-24 21:18:31 -04:00
{
2015-06-13 14:41:11 -04:00
prof_connect();
2015-05-24 14:24:01 -04:00
2015-05-27 18:11:58 -04:00
assert_true(stbbr_received(
"<presence id='*'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
2015-05-26 18:22:05 -04:00
"</presence>"
2015-05-24 14:24:01 -04:00
));
}
2015-05-24 16:46:44 -04:00
2015-05-26 20:06:17 -04:00
void
connect_jid_requests_bookmarks(void **state)
{
2015-06-13 14:41:11 -04:00
prof_connect();
2015-05-26 20:06:17 -04:00
2015-05-27 18:11:58 -04:00
assert_true(stbbr_received(
"<iq id='*' type='get'>"
"<query xmlns='jabber:iq:private'>"
"<storage xmlns='storage:bookmarks'/>"
2015-05-26 20:06:17 -04:00
"</query>"
"</iq>"
));
}
void
connect_bad_password(void **state)
{
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
2015-06-13 14:41:11 -04:00
prof_input("badpassword");
2015-05-26 20:06:17 -04:00
assert_true(prof_output_exact("Login failed."));
2015-05-26 20:06:17 -04:00
}
2015-05-27 14:48:25 -04:00
void
2015-05-28 15:02:16 -04:00
connect_shows_presence_updates(void **state)
2015-05-27 14:48:25 -04:00
{
2015-06-13 14:41:11 -04:00
prof_connect();
2015-05-27 14:48:25 -04:00
2015-06-13 14:41:11 -04:00
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
2015-05-27 14:48:25 -04:00
"<show>dnd</show>"
"<status>busy!</status>"
"</presence>"
2015-06-13 14:41:11 -04:00
);
assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\""));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
2015-05-27 14:48:25 -04:00
"<show>chat</show>"
"<status>Talk to me!</status>"
"</presence>"
2015-06-13 14:41:11 -04:00
);
assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\""));
stbbr_send(
"<presence to='stabber@localhost' from='buddy2@localhost/work'>"
2015-05-27 14:48:25 -04:00
"<show>away</show>"
"<status>Out of office</status>"
"</presence>"
);
assert_true(prof_output_exact("Buddy2 (work) is away, \"Out of office\""));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<show>xa</show>"
"<status>Gone :(</status>"
"</presence>"
);
assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\""));
2015-05-27 14:48:25 -04:00
}