aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2022-10-02 21:46:52 +0200
committerLinus Jahn <lnj@kaidan.im>2022-10-02 21:48:01 +0200
commit9ea4dc9cb762f8108b47124250e0c9e76a5b2cde (patch)
tree4908525119aa115e1e1b66af84563829b9342d45 /tests
parent9f9d672e350ef4ce65983d2cac590aa23d74ac96 (diff)
downloadqxmpp-9ea4dc9cb762f8108b47124250e0c9e76a5b2cde.tar.gz
Implement XEP-0167: Jingle RTP Sessions error conditions (#485)
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmppjingleiq/tst_qxmppjingleiq.cpp98
1 files changed, 97 insertions, 1 deletions
diff --git a/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp b/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp
index 0a7b499a..b2d74c83 100644
--- a/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp
+++ b/tests/qxmppjingleiq/tst_qxmppjingleiq.cpp
@@ -45,6 +45,8 @@ private slots:
void testAudioPayloadType();
void testVideoPayloadType();
void testPayloadTypeRtpFeedbackNegotiation();
+ void testRtpErrorCondition_data();
+ void testRtpErrorCondition();
};
void tst_QXmppJingleIq::testIsSdpParameter_data()
@@ -790,7 +792,6 @@ void tst_QXmppJingleIq::testContentRtpHeaderExtensionsNegotiation()
rtpHeaderExtensionProperty2.setId(uint32_t(2));
rtpHeaderExtensionProperty2.setUri(QStringLiteral("urn:ietf:params:rtp-hdrext:ntp-64"));
-
QXmppJinglePayloadType payloadType;
payloadType.setId(96);
payloadType.setName(QStringLiteral("speex"));
@@ -1099,5 +1100,100 @@ void tst_QXmppJingleIq::testPayloadTypeRtpFeedbackNegotiation()
serializePacket(payload2, xml);
}
+void tst_QXmppJingleIq::testRtpErrorCondition_data()
+{
+ QTest::addColumn<QByteArray>("xml");
+ QTest::addColumn<QXmppJingleIq::Reason::RtpErrorCondition>("condition");
+
+ QTest::newRow("NoErrorCondition")
+ << QByteArrayLiteral("<iq type=\"set\">"
+ "<jingle xmlns=\"urn:xmpp:jingle:1\" action=\"session-terminate\">"
+ "<reason>"
+ "<security-error/>"
+ "</reason>"
+ "</jingle>"
+ "</iq>")
+ << QXmppJingleIq::Reason::NoErrorCondition;
+ QTest::newRow("InvalidCrypto")
+ << QByteArrayLiteral("<iq type=\"set\">"
+ "<jingle xmlns=\"urn:xmpp:jingle:1\" action=\"session-terminate\">"
+ "<reason>"
+ "<security-error/>"
+ "<invalid-crypto xmlns=\"urn:xmpp:jingle:apps:rtp:errors:1\"/>"
+ "</reason>"
+ "</jingle>"
+ "</iq>")
+ << QXmppJingleIq::Reason::InvalidCrypto;
+ QTest::newRow("CryptoRequired")
+ << QByteArrayLiteral("<iq type=\"set\">"
+ "<jingle xmlns=\"urn:xmpp:jingle:1\" action=\"session-terminate\">"
+ "<reason>"
+ "<security-error/>"
+ "<crypto-required xmlns=\"urn:xmpp:jingle:apps:rtp:errors:1\"/>"
+ "</reason>"
+ "</jingle>"
+ "</iq>")
+ << QXmppJingleIq::Reason::CryptoRequired;
+}
+
+void tst_QXmppJingleIq::testRtpErrorCondition()
+{
+ QFETCH(QByteArray, xml);
+ QFETCH(QXmppJingleIq::Reason::RtpErrorCondition, condition);
+
+ QXmppJingleIq iq1;
+ QCOMPARE(iq1.reason().rtpErrorCondition(), QXmppJingleIq::Reason::NoErrorCondition);
+ parsePacket(iq1, xml);
+
+ const auto rtpErrorCondition1 = iq1.reason().rtpErrorCondition();
+ switch (condition) {
+ case QXmppJingleIq::Reason::NoErrorCondition:
+ QVERIFY(rtpErrorCondition1 == QXmppJingleIq::Reason::NoErrorCondition);
+ break;
+ case QXmppJingleIq::Reason::InvalidCrypto:
+ QVERIFY(rtpErrorCondition1 == QXmppJingleIq::Reason::InvalidCrypto);
+ break;
+ case QXmppJingleIq::Reason::CryptoRequired:
+ QVERIFY(rtpErrorCondition1 == QXmppJingleIq::Reason::CryptoRequired);
+ break;
+ }
+
+ serializePacket(iq1, xml);
+
+ QXmppJingleIq iq2;
+ iq2.setType(QXmppIq::Set);
+ iq2.setId({});
+ iq2.setAction(QXmppJingleIq::SessionTerminate);
+
+ switch (condition) {
+ case QXmppJingleIq::Reason::NoErrorCondition:
+ iq2.reason().setRtpErrorCondition(QXmppJingleIq::Reason::NoErrorCondition);
+ break;
+ case QXmppJingleIq::Reason::InvalidCrypto:
+ iq2.reason().setRtpErrorCondition(QXmppJingleIq::Reason::InvalidCrypto);
+ break;
+ case QXmppJingleIq::Reason::CryptoRequired:
+ iq2.reason().setRtpErrorCondition(QXmppJingleIq::Reason::CryptoRequired);
+ break;
+ }
+
+ iq2.reason().setType(QXmppJingleIq::Reason::SecurityError);
+
+ const auto rtpErrorCondition2 = iq2.reason().rtpErrorCondition();
+ switch (condition) {
+ case QXmppJingleIq::Reason::NoErrorCondition:
+ QVERIFY(rtpErrorCondition2 == QXmppJingleIq::Reason::NoErrorCondition);
+ break;
+ case QXmppJingleIq::Reason::InvalidCrypto:
+ QVERIFY(rtpErrorCondition2 == QXmppJingleIq::Reason::InvalidCrypto);
+ break;
+ case QXmppJingleIq::Reason::CryptoRequired:
+ QVERIFY(rtpErrorCondition2 == QXmppJingleIq::Reason::CryptoRequired);
+ break;
+ }
+
+ serializePacket(iq2, xml);
+}
+
QTEST_MAIN(tst_QXmppJingleIq)
#include "tst_qxmppjingleiq.moc"