6 # Test that the vcard implementation works as expected. Only
7 # does avatars for now, but that's good.
9 use Test
::More
'no_plan';
12 use Thrasher
::Test
qw(:all);
15 use_ok
'Thrasher::Test', qw(:all);
17 use_ok
'Thrasher::Plugin', qw(:all);
18 use_ok
'Thrasher::Plugin::Vcard', qw(:all);
19 use_ok
'Thrasher::Callbacks', qw(:all);
20 use_ok
'Thrasher::Avatar', qw(:all);
21 use_ok
'Thrasher::Constants', qw(:all);
24 my $JID = transport_jid
();
27 my $comp = logged_in_comp
();
29 # Send a presence tag for the transport itself, which should
30 # not get modified by this plugin.
31 $comp->send_presence_xml(undef, '', undef);
32 is
(output
, "<presence from='$JID'/>",
33 "correctly does not decorate the transport's presences");
35 # Send a presence tag for a user with no avatar yet.
36 $comp->send_presence_xml('romeo@montague.lit',
39 "<presence from='juliet\@test.transport' to='romeo\@montague.lit'><x xmlns='vcard-temp:x:update'/></presence>",
40 'correctly indicates support for vcard avatars, but that '
41 .'the user does not yet have one');
43 my $vcard_query = <<VCARD_QUERY;
44 <iq from='romeo\@montague.lit'
48 <vCard xmlns='$NS_VCARD'/>
52 $comp->xml_in($vcard_query);
53 my $expected = clean_xml(<<EXPECTED);
54 <iq from='juliet\@test.transport'
56 to='romeo\@montague.lit'
58 <vCard xmlns='vcard-temp'/>
61 is
(output
, $expected, 'empty vCards correctly reply');
63 set_avatar
($comp, 'romeo@montague.lit', "juliet\@$JID",
65 $expected = clean_xml
(<<EXPECTED);
66 <presence from='juliet\@test.transport'
67 to='romeo\@montague.lit'>
68 <x xmlns='vcard-temp:x:update'>0765a59164829a0fe4eb243ffb14bdd64a3d8f5d</x>
71 # FIXME: Send this out or not?
73 # is(output, $expected, 'we get the proper avatar hash on avatar setting');
74 # That sort of automatically tests the presence code path, too
76 # Ask for the vcard again now that we have an avatar.
77 $comp->xml_in($vcard_query);
78 $expected = clean_xml
(<<EXPECTED);
79 <iq from='juliet\@test.transport'
81 to='romeo\@montague.lit'
83 <vCard xmlns='vcard-temp'>
85 <TYPE>image/png</TYPE>
86 <BINVAL>$small_png_base64</BINVAL>
91 is
(clean_xml
(output
()), $expected,
92 'get the expected vCard with the avatar in it.');