void ping_multiple(void **state) { stbbr_for_id("prof_ping_2", "<iq id='prof_ping_2' type='result' to='stabber@localhost/profanity'/>" ); stbbr_for_id("prof_ping_3", "<iq id='prof_ping_3' type='result' to='stabber@localhost/profanity'/>" ); prof_connect(); prof_input("/ping"); assert_true(stbbr_received( "<iq id='prof_ping_2' type='get'>" "<ping xmlns='urn:xmpp:ping'/>" "</iq>" )); assert_true(prof_output_exact("Ping response from server")); prof_input("/ping"); assert_true(stbbr_received( "<iq id='prof_ping_3' type='get'>" "<ping xmlns='urn:xmpp:ping'/>" "</iq>" )); assert_true(prof_output_exact("Ping response from server")); }
void rooms_query(void **state) { stbbr_for_id("confreq", "<iq id='confreq' type='result' to='stabber@localhost/profanity' from='conference.localhost'>" "<query xmlns='http://jabber.org/protocol/disco#items'>" "<item jid='*****@*****.**' name='A chat room'/>" "<item jid='*****@*****.**' name='Another chat room'/>" "</query>" "</iq>" ); prof_connect(); prof_input("/rooms conference.localhost"); assert_true(prof_output_exact("[email protected], (A chat room)")); assert_true(prof_output_exact("[email protected], (Another chat room)")); assert_true(stbbr_last_received( "<iq id='confreq' to='conference.localhost' type='get'>" "<query xmlns='http://jabber.org/protocol/disco#items'/>" "</iq>" )); }
void prof_connect_with_roster(char *roster) { GString *roster_str = g_string_new( "<iq type='result' to='stabber@localhost/profanity'>" "<query xmlns='jabber:iq:roster' ver='362'>" ); g_string_append(roster_str, roster); g_string_append(roster_str, "</query>" "</iq>" ); stbbr_for_query("jabber:iq:roster", roster_str->str); g_string_free(roster_str, TRUE); stbbr_for_id("prof_presence_1", "<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>" "<priority>0</priority>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://www.profanity.im' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>" "</presence>" ); prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow"); prof_input("password"); // Allow time for profanity to connect exp_timeout = 30; assert_true(prof_output_regex("stabber@localhost logged in successfully, .+online.+ \\(priority 0\\)\\.")); exp_timeout = 10; stbbr_wait_for("prof_presence_*"); }
void prof_connect_with_roster(char *roster) { GString *roster_str = g_string_new( "<iq type=\"result\" to=\"stabber@localhost/profanity\">" "<query xmlns=\"jabber:iq:roster\" ver=\"362\">" ); g_string_append(roster_str, roster); g_string_append(roster_str, "</query>" "</iq>" ); stbbr_for_query("jabber:iq:roster", roster_str->str); g_string_free(roster_str, TRUE); stbbr_for_id("prof_presence_1", "<presence id=\"prof_presence_1\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"stabber@localhost/profanity\">" "<priority>0</priority>" "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" node=\"http://www.profanity.im\" ver=\"f8mrtdyAmhnj8Ca+630bThSL718=\"/>" "</presence>" ); prof_input("/connect stabber@localhost port 5230"); prof_input("password"); // Allow time for profanity to connect exp_timeout = 30; assert_true(prof_output_regex("stabber@localhost logged in successfully, .+online.+ \\(priority 0\\)\\.")); exp_timeout = 10; stbbr_wait_for("prof_presence_*"); }
int main(void) { stbbr_start(STBBR_LOGDEBUG, 5230, 5231); stbbr_auth_passwd("password"); stbbr_for_id("roster", "<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">" "<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>"); stbbr_for_id("prof_presence_1", "<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>"); stbbr_for_id("prof_msg_2", "<message id=\"message1\" to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\" type=\"chat\">" "<body>Welcome!!</body>" "</message>"); stbbr_for_id("prof_msg_3", "<message id=\"message2\" to=\"stabber@localhost\" from=\"buddy1@localhost/laptop\" type=\"chat\">" "<body>From me laptop</body>" "</message>"); pthread_exit(NULL); }