Skip to content

Commit

Permalink
tests: AccountMigration: Fix with other unordered_map implementations
Browse files Browse the repository at this point in the history
Packets are found no matter in what order they were sent. The IQ IDs
are ignored while comparing.
  • Loading branch information
lnjX committed Nov 16, 2024
1 parent d46c01f commit bff137f
Showing 1 changed file with 93 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,45 +229,50 @@ void tst_QXmppAccountMigrationManager::testRealImportExport()
auto exportTask = manager->exportData();
QVERIFY(!exportTask.isFinished());

client->expect(u"<iq id='qxmpp2' from='[email protected]/QXmpp' type='get'>"
"<query xmlns='jabber:iq:roster'>"
"<annotate xmlns='urn:xmpp:mix:roster:0'/>"
"</query>"
"</iq>"_s);
client->inject(packetToXml(newRoster(client.get(), 1, "qxmpp2", QXmppIq::Result)));

client->expect(u"<iq id='qxmpp3' from='[email protected]/QXmpp' type='get'>"
"<query xmlns='jabber:iq:roster'>"
"<annotate xmlns='urn:xmpp:mix:roster:0'/>"
"</query>"
"</iq>"_s);
client->inject(packetToXml(newRoster(client.get(), 1, "qxmpp3", QXmppIq::Result)));

client->expect(u"<iq id='qxmpp4' to='[email protected]' type='get'>"
"<vCard xmlns='vcard-temp'>"
"<TITLE/>"
"<ROLE/>"
"</vCard>"
"</iq>"_s);
client->inject(packetToXml(newClientVCard(client.get(), 1, "qxmpp4", QXmppIq::Result)));

client->expect(u"<iq id='qxmpp7' to='[email protected]' type='get'>"
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"
"<items node='urn:xmpp:mix:nodes:participants'/>"
"</pubsub>"
"</iq>"_s);
client->inject(u"<iq id='qxmpp7' from='[email protected]' type='result'>"
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"
"<items node='urn:xmpp:mix:nodes:participants'>"
"<item id='mix2BareId'>"
"<participant xmlns='urn:xmpp:mix:core:1'>"
"<nick>Joe @ Mix 2 Gamer</nick>"
"<jid>[email protected]</jid>"
"</participant>"
"</item>"
"</items>"
"</pubsub>"
"</iq>"_s);
auto id = client->expectPacketRandomOrder(
u"<iq from='[email protected]/QXmpp' type='get'>"
"<query xmlns='jabber:iq:roster'>"
"<annotate xmlns='urn:xmpp:mix:roster:0'/>"
"</query>"
"</iq>"_s);
client->inject(packetToXml(newRoster(client.get(), 1, id, QXmppIq::Result)));

id = client->expectPacketRandomOrder(
u"<iq from='[email protected]/QXmpp' type='get'>"
"<query xmlns='jabber:iq:roster'>"
"<annotate xmlns='urn:xmpp:mix:roster:0'/>"
"</query>"
"</iq>"_s);
client->inject(packetToXml(newRoster(client.get(), 1, id, QXmppIq::Result)));

id = client->expectPacketRandomOrder(
u"<iq to='[email protected]' type='get'>"
"<vCard xmlns='vcard-temp'>"
"<TITLE/>"
"<ROLE/>"
"</vCard>"
"</iq>"_s);
client->inject(packetToXml(newClientVCard(client.get(), 1, id, QXmppIq::Result)));

id = client->expectPacketRandomOrder(
u"<iq to='[email protected]' type='get'>"
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"
"<items node='urn:xmpp:mix:nodes:participants'/>"
"</pubsub>"
"</iq>"_s);
client->inject(
u"<iq id='%1' from='[email protected]' type='result'>"
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"
"<items node='urn:xmpp:mix:nodes:participants'>"
"<item id='mix2BareId'>"
"<participant xmlns='urn:xmpp:mix:core:1'>"
"<nick>Joe @ Mix 2 Gamer</nick>"
"<jid>[email protected]</jid>"
"</participant>"
"</item>"
"</items>"
"</pubsub>"
"</iq>"_s.arg(id));

client->expectNoPacket();

Expand All @@ -276,51 +281,55 @@ void tst_QXmppAccountMigrationManager::testRealImportExport()
// import exported data
auto importTask = manager->importData(data);

client->expect(u"<iq id='qxmpp13' to='[email protected]' type='set'>"
"<client-join xmlns='urn:xmpp:mix:pam:2' channel='[email protected]'>"
"<join xmlns='urn:xmpp:mix:core:1'>"
"<subscribe node='urn:xmpp:mix:nodes:allowed'/>"
"<subscribe node='urn:xmpp:avatar:data'/>"
"<subscribe node='urn:xmpp:avatar:metadata'/>"
"<subscribe node='urn:xmpp:mix:nodes:banned'/>"
"<subscribe node='urn:xmpp:mix:nodes:config'/>"
"<subscribe node='urn:xmpp:mix:nodes:info'/>"
"<subscribe node='urn:xmpp:mix:nodes:jidmap'/>"
"<subscribe node='urn:xmpp:mix:nodes:messages'/>"
"<subscribe node='urn:xmpp:mix:nodes:participants'/>"
"<subscribe node='urn:xmpp:mix:nodes:presence'/>"
"<nick>Joe @ Mix 2 Gamer</nick>"
"</join>"
"</client-join>"
"</iq>"_s);
client->inject(u"<iq id='qxmpp13' type='result'>"
"<client-join xmlns='urn:xmpp:mix:pam:2'>"
"<join xmlns='urn:xmpp:mix:core:1' id='mix2BareId'>"
"<subscribe node='urn:xmpp:mix:nodes:messages'/>"
"<subscribe node='urn:xmpp:mix:nodes:presence'/>"
"<nick>Joe @ Mix 2 Gamer</nick>"
"</join>"
"</client-join>"
"</iq>"_s);

client->expect(u"<iq id='qxmpp4' to='[email protected]' type='set'>"
"<vCard xmlns='vcard-temp'>"
"<NICKNAME>It is me Bookri</NICKNAME>"
"<N><GIVEN>Nox</GIVEN><FAMILY>Bookri</FAMILY></N>"
"<TITLE/>"
"<ROLE/>"
"</vCard>"
"</iq>"_s);
client->inject(packetToXml(newClientVCard(client.get(), 1, "qxmpp4", QXmppIq::Result)));

client->expect(u"<iq id='qxmpp14' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='[email protected]' name='3 Gamer'>"
"<group>gamers</group>"
"</item>"
"</query>"
"</iq>"_s);
client->inject(packetToXml(newRoster(client.get(), 1, "qxmpp14", QXmppIq::Result, 0)));
id = client->expectPacketRandomOrder(
u"<iq to='[email protected]' type='set'>"
"<client-join xmlns='urn:xmpp:mix:pam:2' channel='[email protected]'>"
"<join xmlns='urn:xmpp:mix:core:1'>"
"<subscribe node='urn:xmpp:mix:nodes:allowed'/>"
"<subscribe node='urn:xmpp:avatar:data'/>"
"<subscribe node='urn:xmpp:avatar:metadata'/>"
"<subscribe node='urn:xmpp:mix:nodes:banned'/>"
"<subscribe node='urn:xmpp:mix:nodes:config'/>"
"<subscribe node='urn:xmpp:mix:nodes:info'/>"
"<subscribe node='urn:xmpp:mix:nodes:jidmap'/>"
"<subscribe node='urn:xmpp:mix:nodes:messages'/>"
"<subscribe node='urn:xmpp:mix:nodes:participants'/>"
"<subscribe node='urn:xmpp:mix:nodes:presence'/>"
"<nick>Joe @ Mix 2 Gamer</nick>"
"</join>"
"</client-join>"
"</iq>"_s);
client->inject(
u"<iq id='%1' type='result'>"
"<client-join xmlns='urn:xmpp:mix:pam:2'>"
"<join xmlns='urn:xmpp:mix:core:1' id='mix2BareId'>"
"<subscribe node='urn:xmpp:mix:nodes:messages'/>"
"<subscribe node='urn:xmpp:mix:nodes:presence'/>"
"<nick>Joe @ Mix 2 Gamer</nick>"
"</join>"
"</client-join>"
"</iq>"_s.arg(id));

id = client->expectPacketRandomOrder(
u"<iq to='[email protected]' type='set'>"
"<vCard xmlns='vcard-temp'>"
"<NICKNAME>It is me Bookri</NICKNAME>"
"<N><GIVEN>Nox</GIVEN><FAMILY>Bookri</FAMILY></N>"
"<TITLE/>"
"<ROLE/>"
"</vCard>"
"</iq>"_s);
client->inject(packetToXml(newClientVCard(client.get(), 1, id, QXmppIq::Result)));

id = client->expectPacketRandomOrder(
u"<iq type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='[email protected]' name='3 Gamer'>"
"<group>gamers</group>"
"</item>"
"</query>"
"</iq>"_s);
client->inject(packetToXml(newRoster(client.get(), 1, id, QXmppIq::Result, 0)));

client->expectNoPacket();

Expand Down

0 comments on commit bff137f

Please sign in to comment.