blob: 985a34bff76bd0fe801550a30266e458cd7bdffb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Copyright (c) 2017 Tarun Gupta
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <gtest/gtest.h>
#include <Swiften/Elements/MIXUpdateSubscription.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
using namespace Swift;
TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
"<update-subscription xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"</update-subscription>"
));
auto payload = parser.getPayload<MIXUpdateSubscription>();
ASSERT_TRUE(payload);
ASSERT_FALSE(payload->getJID());
auto items = payload->getSubscriptions();
ASSERT_EQ(static_cast<size_t>(1), items.size());
ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
}
TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28_WithJID) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
"<update-subscription xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"</update-subscription>"
));
auto payload = parser.getPayload<MIXUpdateSubscription>();
ASSERT_TRUE(payload);
ASSERT_TRUE(payload->getJID());
ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID());
auto items = payload->getSubscriptions();
ASSERT_EQ(static_cast<size_t>(1), items.size());
ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
}
|