1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00
profanity/functionaltests/test_connect.c

118 lines
3.4 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-24 15:31:18 -04:00
void
2015-05-26 18:22:05 -04:00
connect_jid(void **state)
2015-05-26 20:06:17 -04:00
{
2015-05-28 15:02:16 -04:00
prof_connect("stabber@localhost", "password");
2015-05-26 20:06:17 -04:00
assert_true(prof_output_exact("Connecting as stabber@localhost"));
assert_true(prof_output_regex("stabber@localhost logged in successfully, .+online.+ \\(priority 0\\)\\."));
2015-05-26 20:06:17 -04:00
}
void
connect_jid_requests_roster(void **state)
{
2015-05-28 15:02:16 -04:00
prof_connect("stabber@localhost", "password");
2015-05-26 20:06:17 -04:00
2015-05-27 18:11:58 -04:00
assert_true(stbbr_received(
2015-05-26 20:06:17 -04:00
"<iq id=\"*\" type=\"get\"><query xmlns=\"jabber:iq:roster\"/></iq>"
));
}
void
connect_jid_sends_presence_after_receiving_roster(void **state)
2015-05-24 21:18:31 -04:00
{
2015-06-01 19:41:50 -04:00
stbbr_for_query("jabber:iq:roster",
"<iq type=\"result\" to=\"stabber@localhost/profanity\">"
2015-05-24 21:18:31 -04:00
"<query xmlns=\"jabber:iq:roster\" ver=\"362\">"
"<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>"
"<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>"
"</query>"
"</iq>"
);
2015-05-28 15:02:16 -04:00
prof_connect("stabber@localhost", "password");
2015-05-24 14:24:01 -04:00
2015-05-27 18:11:58 -04:00
assert_true(stbbr_received(
2015-05-26 18:22:05 -04:00
"<presence id=\"*\">"
"<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>"
"</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-05-28 15:02:16 -04:00
prof_connect("stabber@localhost", "password");
2015-05-26 20:06:17 -04:00
2015-05-27 18:11:58 -04:00
assert_true(stbbr_received(
2015-05-26 20:06:17 -04:00
"<iq id=\"*\" type=\"get\">"
"<query xmlns=\"jabber:iq:private\">"
"<storage xmlns=\"storage:bookmarks\"/>"
"</query>"
"</iq>"
));
}
void
connect_bad_password(void **state)
{
2015-05-28 15:02:16 -04:00
prof_connect("stabber@localhost", "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-01 19:41:50 -04:00
stbbr_for_query("jabber:iq:roster",
"<iq type=\"result\" to=\"stabber@localhost/profanity\">"
2015-05-27 14:48:25 -04:00
"<query xmlns=\"jabber:iq:roster\" ver=\"362\">"
"<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>"
"<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>"
"</query>"
"</iq>"
);
2015-06-01 17:02:45 -04:00
stbbr_for_id("prof_presence_1",
2015-05-27 14:48:25 -04:00
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
"<show>dnd</show>"
"<status>busy!</status>"
"</presence>"
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/laptop\">"
"<show>chat</show>"
"<status>Talk to me!</status>"
"</presence>"
"<presence to=\"stabber@localhost\" from=\"buddy2@localhost/work\">"
"<show>away</show>"
"<status>Out of office</status>"
"</presence>"
);
2015-05-28 15:02:16 -04:00
prof_connect("stabber@localhost", "password");
assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\""));
assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\""));
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
}