blob: 9dc95238c0b60d11b52dc2a9e959f3222399bc04 (
plain) (
blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Copyright (C) 2008-2020 The QXmpp developers
*
* Authors:
* Jeremy Lainé
* Manjeet Dahiya
*
* Source:
* https://github.com/qxmpp-project/qxmpp
*
* This file is a part of QXmpp library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#include "QXmppDiscoveryIq.h"
#include "util.h"
#include <QObject>
class tst_QXmppDiscoveryIq : public QObject
{
Q_OBJECT
private slots:
void testDiscovery();
void testDiscoveryWithForm();
};
void tst_QXmppDiscoveryIq::testDiscovery()
{
const QByteArray xml(
"<iq id=\"disco1\" from=\"benvolio@capulet.lit/230193\" type=\"result\">"
"<query xmlns=\"http://jabber.org/protocol/disco#info\">"
"<identity category=\"client\" name=\"Exodus 0.9.1\" type=\"pc\"/>"
"<feature var=\"http://jabber.org/protocol/caps\"/>"
"<feature var=\"http://jabber.org/protocol/disco#info\"/>"
"<feature var=\"http://jabber.org/protocol/disco#items\"/>"
"<feature var=\"http://jabber.org/protocol/muc\"/>"
"</query>"
"</iq>");
QXmppDiscoveryIq disco;
parsePacket(disco, xml);
QCOMPARE(disco.verificationString(), QByteArray::fromBase64("QgayPKawpkPSDYmwT/WM94uAlu0="));
serializePacket(disco, xml);
}
void tst_QXmppDiscoveryIq::testDiscoveryWithForm()
{
const QByteArray xml(
"<iq id=\"disco1\" to=\"juliet@capulet.lit/chamber\" from=\"benvolio@capulet.lit/230193\" type=\"result\">"
"<query xmlns=\"http://jabber.org/protocol/disco#info\" node=\"http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w=\">"
"<identity xml:lang=\"en\" category=\"client\" name=\"Psi 0.11\" type=\"pc\"/>"
"<identity xml:lang=\"el\" category=\"client\" name=\"Ψ 0.11\" type=\"pc\"/>"
"<feature var=\"http://jabber.org/protocol/caps\"/>"
"<feature var=\"http://jabber.org/protocol/disco#info\"/>"
"<feature var=\"http://jabber.org/protocol/disco#items\"/>"
"<feature var=\"http://jabber.org/protocol/muc\"/>"
"<x xmlns=\"jabber:x:data\" type=\"result\">"
"<field type=\"hidden\" var=\"FORM_TYPE\">"
"<value>urn:xmpp:dataforms:softwareinfo</value>"
"</field>"
"<field type=\"text-multi\" var=\"ip_version\">"
"<value>ipv4</value>"
"<value>ipv6</value>"
"</field>"
"<field type=\"text-single\" var=\"os\">"
"<value>Mac</value>"
"</field>"
"<field type=\"text-single\" var=\"os_version\">"
"<value>10.5.1</value>"
"</field>"
"<field type=\"text-single\" var=\"software\">"
"<value>Psi</value>"
"</field>"
"<field type=\"text-single\" var=\"software_version\">"
"<value>0.11</value>"
"</field>"
"</x>"
"</query>"
"</iq>");
QXmppDiscoveryIq disco;
parsePacket(disco, xml);
QCOMPARE(disco.verificationString(), QByteArray::fromBase64("q07IKJEyjvHSyhy//CH0CxmKi8w="));
serializePacket(disco, xml);
}
QTEST_MAIN(tst_QXmppDiscoveryIq)
#include "tst_qxmppdiscoveryiq.moc"
|