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

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

151 lines
4.1 KiB
C
Raw Normal View History

2015-07-05 12:29:33 -04:00
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <stabber.h>
#include <expect.h>
#include "proftest.h"
void
send_enable_carbons(void **state)
{
prof_connect();
prof_input("/carbons on");
assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
2015-07-05 12:29:33 -04:00
));
}
2015-07-14 19:23:46 -04:00
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>"
2015-07-14 19:23:46 -04:00
));
}
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>"
2015-07-14 19:23:46 -04:00
));
}
2015-07-20 16:28:25 -04:00
void
receive_carbon(void **state)
{
prof_input("/carbons on");
prof_connect();
assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
2015-07-20 16:28:25 -04:00
));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
2015-07-20 16:28:25 -04:00
"<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"));
2015-07-20 16:28:25 -04:00
stbbr_send(
2017-01-23 17:25:36 -05:00
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
"<received xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns='urn:xmpp:forward:0'>"
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
2015-07-20 16:28:25 -04:00
"<body>test carbon from recipient</body>"
"</message>"
"</forwarded>"
"</received>"
"</message>"
);
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(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
2015-07-20 16:28:25 -04:00
));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
2015-07-20 16:28:25 -04:00
"<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"));
2015-07-20 16:28:25 -04:00
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'>"
2015-07-20 16:28:25 -04:00
"<body>self sent carbon</body>"
"</message>"
"</forwarded>"
"</sent>"
"</message>"
);
assert_true(prof_output_regex("me: .+self sent carbon"));
}
2016-08-28 12:27:26 -04:00
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"));
}