6 # Test that avatar publishing works as expected, especially as it
7 # tends to have a lot of corner cases w.r.t. image integrity.
9 use Test
::More
'no_plan';
12 use MIME
::Base64
qw(encode_base64 decode_base64);
15 use_ok
'Thrasher::Test', qw(:all);
16 use_ok
'Thrasher', qw(:all);
17 use_ok
'Thrasher::Component';
18 use_ok
'Thrasher::Plugin', qw(:all);
19 use_ok
'Thrasher::Plugin::PEPAvatar';
20 use_ok
'Thrasher::Backend::Test';
21 use_ok
'Thrasher::Callbacks', qw(:all);
22 use_ok
'Thrasher::Avatar', qw(:all);
25 my $JID = transport_jid
;
27 # Lie that we detected PEP, so this stuff actually comes out in XML
28 succeeded
('pep_detected');
30 # The user wishes to set a good PNG avatar; ensure the correct XML
31 # goes out, and that when the server replies with the expected
32 # packets, the component correctly ignores it.
34 my $comp = logged_in_comp
;
36 set_avatar
($comp, 'romeo@montague.lit', 'juliet@' . $JID, $small_png);
38 my $expected_xml = clean_xml
(<<EXPECTED);
39 <iq from='juliet\@test.transport'
42 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
43 <publish xmlns='urn:xmpp:avatar:metadata'>
45 <item id='0765a59164829a0fe4eb243ffb14bdd64a3d8f5d'>
49 id='0765a59164829a0fe4eb243ffb14bdd64a3d8f5d'
58 <iq from='juliet\@test.transport'
61 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
62 <publish xmlns='urn:xmpp:avatar:data'>
64 <item id='0765a59164829a0fe4eb243ffb14bdd64a3d8f5d'>
65 <data>$small_png_base64</data>
73 is
(clean_xml
(output
), $expected_xml,
74 'expected pub_sub output on setting a PNG avatar');
78 my $comp = logged_in_comp
;
80 set_avatar
($comp, 'romeo@montague.lit', "juliet\@$JID", $small_gif);
82 my $expected = clean_xml
(<<EXPECTED);
83 <iq from='juliet\@test.transport'
86 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
87 <publish xmlns='urn:xmpp:avatar:metadata'>
89 <item id='$small_gif_png_sha1'>
91 <info bytes='$small_gif_png_len'
93 id='$small_gif_png_sha1'
102 <iq from='juliet\@test.transport'
105 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
106 <publish xmlns='urn:xmpp:avatar:data'>
108 <item id='$small_gif_png_sha1'>
109 <data>$small_gif_png_base64</data>
117 is
(clean_xml
(output
), $expected,
118 'proper handling of the GIF case; converted to PNG');
122 my $comp = logged_in_comp
;
124 set_avatar
($comp, 'romeo@montague.lit', "juliet\@$JID", $binary_garbage);
126 is
(output
, '', 'no XML output');
127 logged
("failed to determine a type for the image",
128 'correct error message output by the PEP plugin');