summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2018-11-13 10:54:58 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2018-11-14 13:40:05 (GMT)
commit5d7fc97148125584a44a39a4beee1e71d9518385 (patch)
tree9f630e8a9f69bdbd701c1b3c082bacf2b769938d /Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
parentc0615a472f8d23ce449fd59bbb1cdf7071082a43 (diff)
downloadswift-5d7fc97148125584a44a39a4beee1e71d9518385.zip
swift-5d7fc97148125584a44a39a4beee1e71d9518385.tar.bz2
Address LinkLocal issues
Generation of TXT records might fail if any of the fields is too long, so the result is now an optional (pending Expected). Callsites have been updated to deal with this. Three potentially uncaught exceptions in the Bonjour implementation have been addressed. Test-Information: Unit tests pass on macOS 10.14 and Debian 9 Change-Id: Iec02c4606a18eee855362fd3c3d15614a9e72547
Diffstat (limited to 'Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp')
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
index 0a94a98..35cb1b4 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -29,7 +29,9 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture {
info.setLastName("Tron\xc3\xe7on");
info.setStatus(LinkLocalServiceInfo::Away);
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord());
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), *txtRecord);
}
void testCreateFromTXTRecord() {
@@ -57,7 +59,9 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture {
info.setStatus(LinkLocalServiceInfo::DND);
info.setPort(1234);
- LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(info.toTXTRecord());
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(*txtRecord);
CPPUNIT_ASSERT_EQUAL(info.getFirstName(), info2.getFirstName());
CPPUNIT_ASSERT_EQUAL(info.getLastName(), info2.getLastName());
CPPUNIT_ASSERT_EQUAL(info.getEMail(), info2.getEMail());
@@ -67,6 +71,13 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(info.getStatus() == info2.getStatus());
CPPUNIT_ASSERT(info.getPort() == info2.getPort());
}
+
+ void testToTXTRecordWithInvalidParameter() {
+ LinkLocalServiceInfo info;
+ info.setFirstName(std::string(256, 'x'));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(!txtRecord);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(LinkLocalServiceInfoTest);