// Typical use case for gateways that don't support resources void display_software_version_result_when_from_domainpart(void **state) { prof_connect(); stbbr_send( "<presence to=\"stabber@localhost\" from=\"buddy1@localhost\">" "<priority>10</priority>" "<status>I'm here</status>" "</presence>" ); prof_output_exact("Buddy1 is online, \"I'm here\""); stbbr_for_query("jabber:iq:version", "<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"localhost\">" "<query xmlns=\"jabber:iq:version\">" "<name>Some Gateway</name>" "<version>1.0</version>" "</query>" "</iq>" ); prof_input("/software buddy1@localhost/__prof_default"); // assert_true(prof_output_exact("buddy1@localhost/__prof_default:")); // assert_true(prof_output_exact("Name : Some Gateway")); assert_true(prof_output_exact("Version : 1.0")); }
void receive_private_carbon(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" )); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<priority>10</priority>" "<status>On my mobile</status>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>" "<body>Private carbon</body>" "<private xmlns='urn:xmpp:carbons:2'/>" "</message>" ); assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon")); }
void receive_self_carbon(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" )); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<priority>10</priority>" "<status>On my mobile</status>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>" "<sent xmlns='urn:xmpp:carbons:2'>" "<forwarded xmlns='urn:xmpp:forward:0'>" "<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>" "<body>self sent carbon</body>" "</message>" "</forwarded>" "</sent>" "</message>" ); assert_true(prof_output_regex("me: .+self sent carbon")); }
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 display_software_version_result(void **state) { prof_connect(); stbbr_send( "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">" "<priority>10</priority>" "<status>I'm here</status>" "</presence>" ); prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""); stbbr_for_query("jabber:iq:version", "<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/mobile\">" "<query xmlns=\"jabber:iq:version\">" "<name>Profanity</name>" "<version>0.4.7dev.master.2cb2f83</version>" "</query>" "</iq>" ); prof_input("/software buddy1@localhost/mobile"); // assert_true(prof_output_exact("buddy1@localhost/mobile:")); // assert_true(prof_output_exact("Name : Profanity")); assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83")); }
void sends_message_to_fulljid_when_received_from_fulljid(void **state) { prof_connect(); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<priority>10</priority>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<body>First message</body>" "</message>" ); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Hi there"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<body>Hi there</body>" "</message>" )); }
void connect_with_carbons_enabled(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" )); }
void disconnect_ends_session(void **state) { prof_connect(); prof_input("/disconnect"); assert_true(prof_output_exact("stabber@localhost logged out successfully.")); prof_input("/roster"); assert_true(prof_output_exact("You are not currently connected.")); }
void sends_message_to_barejid_when_contact_offline(void **state) { prof_connect(); prof_input("/msg buddy1@localhost Hi there"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost' type='chat'>" "<body>Hi there</body>" "</message>" )); }
void send_disable_carbons(void **state) { prof_input("/carbons on"); prof_connect(); prof_input("/carbons off"); assert_true(stbbr_received( "<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>" )); }
void ping_responds(void **state) { prof_connect(); stbbr_send( "<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>" "<ping xmlns='urn:xmpp:ping'/>" "</iq>" ); assert_true(stbbr_received( "<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>" )); }
void new_session_when_message_received_from_different_fulljid(void **state) { prof_connect(); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<priority>10</priority>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>" "<priority>8</priority>" "<show>away</show>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (laptop) is away")); stbbr_send( "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<body>From first resource</body>" "</message>" ); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Outgoing 1"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<body>Outgoing 1</body>" "</message>" )); stbbr_send( "<message id='message1' to='stabber@localhost' from='buddy1@localhost/laptop' type='chat'>" "<body>From second resource</body>" "</message>" ); assert_true(prof_output_regex("Buddy1/laptop:.+From second resource")); prof_input("/msg buddy1@localhost Outgoing 2"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost/laptop' type='chat'>" "<body>Outgoing 2</body>" "</message>" )); }
void send_receipt_request(void **state) { prof_input("/receipts request on"); prof_connect(); prof_input("/msg [email protected] Hi there"); assert_true(stbbr_received( "<message id=\"*\" type=\"chat\" to=\"[email protected]\">" "<body>Hi there</body>" "<request xmlns=\"urn:xmpp:receipts\"/>" "</message>" )); }
void show_message_in_chat_window_when_no_resource(void **state) { prof_connect(); stbbr_send( "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">" "<priority>10</priority>" "<status>I'm here</status>" "</presence>" ); prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""); prof_input("/msg Buddy1"); prof_input("/software"); assert_true(prof_output_exact("Unknown resource for /software command.")); }
void send_software_version_request(void **state) { prof_connect(); stbbr_send( "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">" "<priority>10</priority>" "<status>I'm here</status>" "</presence>" ); prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""); prof_input("/software buddy1@localhost/mobile"); stbbr_received( "<iq id=\"*\" to=\"buddy1@localhost/mobile\" type=\"get\">" "<query xmlns=\"jabber:iq:version\"/>" "</iq>" ); }
void send_receipt_on_request(void **state) { prof_input("/receipts send on"); prof_connect(); stbbr_send( "<message id=\"msg12213\" type=\"chat\" to=\"stabber@localhost/profanity\" from=\"[email protected]/profanity\">" "<body>Wants a receipt</body>" "<request xmlns=\"urn:xmpp:receipts\"/>" "</message>" ); assert_true(stbbr_received( "<message id=\"*\" to=\"[email protected]/profanity\">" "<received id=\"msg12213\" xmlns=\"urn:xmpp:receipts\"/>" "</message>" )); }
void sends_message_to_barejid_when_contact_online(void **state) { prof_connect(); stbbr_send( "<presence to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>" "<priority>10</priority>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (mobile) is online")); prof_input("/msg buddy1@localhost Hi there"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost' type='chat'>" "<body>Hi there</body>" "</message>" )); }
void resets_to_barejid_after_presence_received(void **state) { prof_connect(); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<priority>10</priority>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<body>First message</body>" "</message>" ); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Outgoing 1"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<body>Outgoing 1</body>" "</message>" )); stbbr_send( "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>" "<priority>5</priority>" "<show>dnd</show>" "</presence>" ); assert_true(prof_output_exact("Buddy1 (laptop) is dnd")); prof_input("/msg buddy1@localhost Outgoing 2"); assert_true(stbbr_received( "<message id='*' to='buddy1@localhost' type='chat'>" "<body>Outgoing 2</body>" "</message>" )); }
void shows_message_when_software_version_error(void **state) { prof_connect(); stbbr_send( "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">" "<priority>10</priority>" "<status>I'm here</status>" "</presence>" ); prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""); stbbr_for_query("jabber:iq:version", "<iq id=\"*\" lang=\"en\" type=\"error\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/laptop\">" "<query xmlns=\"jabber:iq:version\"/>" "<error code=\"503\" type=\"cancel\">" "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>" "</error>" "</iq>" ); prof_input("/software buddy1@localhost/laptop"); assert_true(prof_output_exact("Could not get software version: service-unavailable")); }