#include #include "prof_cmocka.h" #include #include #include #include "proftest.h" void send_enable_carbons(void **state) { prof_connect(); prof_input("/carbons on"); assert_true(stbbr_received( "" )); } void connect_with_carbons_enabled(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "" )); } void send_disable_carbons(void **state) { prof_input("/carbons on"); prof_connect(); prof_input("/carbons off"); assert_true(stbbr_received( "" )); } void receive_carbon(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "" )); stbbr_send( "" "10" "On my mobile" "" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" "" "" "" "test carbon from recipient" "" "" "" "" ); assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient")); } void receive_self_carbon(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "" )); stbbr_send( "" "10" "On my mobile" "" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" "" "" "" "self sent carbon" "" "" "" "" ); assert_true(prof_output_regex("me: .+self sent carbon")); } void receive_private_carbon(void **state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "" )); stbbr_send( "" "10" "On my mobile" "" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" "Private carbon" "" "" ); assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon")); } /* Regression tests for issue #148 (REQ-INP-01) on the carbon path. The * forwarded message is server-controlled: a missing 'from' reached * xmpp_jid_bare(), which dereferences the jid it is handed, and an invalid * 'to' left a NULL jid_create() result that the carbon dispatch * dereferenced. Both terminated the client. */ static void _carbons_on_with_buddy1(void) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( "" )); stbbr_send( "" "10" "On my mobile" "" ); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); } /* a good carbon still arrives, so the client survived and carbons still work */ static void _assert_carbons_still_work(void) { stbbr_send( "" "" "" "" "still alive" "" "" "" "" ); assert_true(prof_output_regex("me: .+still alive")); } void carbon_missing_forwarded_from_no_crash(void **state) { _carbons_on_with_buddy1(); stbbr_send( "" "" "" "" "forwarded without a from" "" "" "" "" ); _assert_carbons_still_work(); } void carbon_invalid_to_no_crash(void **state) { _carbons_on_with_buddy1(); stbbr_send( "" "" "" "" "forwarded to an invalid jid" "" "" "" "" ); _assert_carbons_still_work(); }