Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 767f35c | 2016-07-23 01:54:42 +0000 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, Regents of the University of California. |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 4 | * |
| 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
| 6 | * See AUTHORS.md for complete list of NDNS authors and contributors. |
| 7 | * |
| 8 | * NDNS is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 20 | #include "mgmt/management-tool.hpp" |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 21 | |
| 22 | #include "ndns-enum.hpp" |
| 23 | #include "ndns-label.hpp" |
| 24 | #include "ndns-tlv.hpp" |
| 25 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 26 | #include <boost/algorithm/string/replace.hpp> |
| 27 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 28 | #include <ndn-cxx/util/io.hpp> |
| 29 | #include <ndn-cxx/util/regex.hpp> |
| 30 | |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 31 | #include "test-common.hpp" |
| 32 | |
| 33 | using boost::test_tools::output_test_stream; |
| 34 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 35 | namespace ndn { |
| 36 | namespace ndns { |
| 37 | namespace tests { |
| 38 | |
| 39 | BOOST_AUTO_TEST_SUITE(ManagementTool) |
| 40 | |
| 41 | static const boost::filesystem::path TEST_DATABASE = TEST_CONFIG_PATH "/management_tool.db"; |
| 42 | static const boost::filesystem::path TEST_CERTDIR = TEST_CONFIG_PATH "/management_tool_certs"; |
| 43 | static const Name FAKE_ROOT("/fake-root/123456789"); |
| 44 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 45 | /** |
| 46 | * @brief Recursive copy a directory using Boost Filesystem |
| 47 | * |
| 48 | * Based on from http://stackoverflow.com/q/8593608/2150331 |
| 49 | */ |
| 50 | void |
| 51 | copyDir(const boost::filesystem::path& source, const boost::filesystem::path& destination) |
| 52 | { |
| 53 | namespace fs = boost::filesystem; |
| 54 | |
| 55 | fs::create_directory(destination); |
| 56 | for (fs::directory_iterator file(source); file != fs::directory_iterator(); ++file) { |
| 57 | fs::path current(file->path()); |
| 58 | if (is_directory(current)) { |
| 59 | copyDir(current, destination / current.filename()); |
| 60 | } |
| 61 | else { |
| 62 | // cannot use fs::copy_file, see https://svn.boost.org/trac/boost/ticket/10038 |
| 63 | // fs::copy works, as it doesn't use problematic private API |
| 64 | copy(current, destination / current.filename()); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | class TestHome : boost::noncopyable |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 70 | { |
| 71 | public: |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 72 | TestHome() |
| 73 | { |
| 74 | if (std::getenv("HOME")) |
| 75 | m_origHome = std::getenv("HOME"); |
| 76 | |
| 77 | setenv("HOME", TEST_CONFIG_PATH "/tests/unit/mgmt/", 1); |
| 78 | boost::filesystem::remove_all(TEST_CONFIG_PATH "/tests/unit/mgmt/"); |
| 79 | boost::filesystem::create_directories(TEST_CONFIG_PATH "/tests/unit/mgmt"); |
| 80 | copyDir("tests/unit/mgmt/.ndn", TEST_CONFIG_PATH "/tests/unit/mgmt/.ndn"); |
| 81 | } |
| 82 | |
| 83 | ~TestHome() |
| 84 | { |
| 85 | if (!m_origHome.empty()) |
| 86 | setenv("HOME", m_origHome.c_str(), 1); |
| 87 | else |
| 88 | unsetenv("HOME"); |
| 89 | } |
| 90 | |
| 91 | protected: |
| 92 | std::string m_origHome; |
| 93 | }; |
| 94 | |
| 95 | |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 96 | class ManagementToolFixture : public TestHome, public IdentityManagementFixture |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 97 | { |
| 98 | public: |
| 99 | class Error : public std::runtime_error |
| 100 | { |
| 101 | public: |
| 102 | explicit |
| 103 | Error(const std::string& what) |
| 104 | : std::runtime_error(what) |
| 105 | { |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | class PreviousStateCleaner |
| 110 | { |
| 111 | public: |
| 112 | PreviousStateCleaner() |
| 113 | { |
| 114 | boost::filesystem::remove(TEST_DATABASE); |
| 115 | boost::filesystem::remove_all(TEST_CERTDIR); |
| 116 | } |
| 117 | }; |
| 118 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 119 | ManagementToolFixture() |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 120 | : m_tool(TEST_DATABASE.string().c_str(), m_keyChain) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 121 | , m_dbMgr(TEST_DATABASE.string().c_str()) |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 122 | |
| 123 | , rootKsk("/KEY/ksk-1416974006376/ID-CERT/%FD%00%00%01I%EA%3Bx%BD") |
| 124 | , rootDsk("/KEY/dsk-1416974006466/ID-CERT/%FD%00%00%01I%EA%3By%28") |
| 125 | |
| 126 | , otherKsk("/ndns-test/KEY/ksk-1416974006577/ID-CERT/%FD%00%00%01I%EA%3By%7F") |
| 127 | , otherDsk("/ndns-test/KEY/dsk-1416974006659/ID-CERT/%FD%00%00%01I%EA%3Bz%0E") |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 128 | { |
| 129 | boost::filesystem::create_directory(TEST_CERTDIR); |
| 130 | } |
| 131 | |
| 132 | ~ManagementToolFixture() |
| 133 | { |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 136 | std::vector<Name> |
| 137 | getKeys(const Name& identity) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 138 | { |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 139 | std::vector<Name> keys; |
| 140 | m_keyChain.getAllKeyNamesOfIdentity(identity, keys, false); |
| 141 | m_keyChain.getAllKeyNamesOfIdentity(identity, keys, true); |
| 142 | return keys; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 143 | } |
| 144 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 145 | std::vector<Name> |
| 146 | getCerts(const Name& identity) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 147 | { |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 148 | std::vector<Name> certs; |
| 149 | for (auto&& name : getKeys(identity)) { |
| 150 | m_keyChain.getAllCertificateNamesOfKey(name, certs, false); |
| 151 | m_keyChain.getAllCertificateNamesOfKey(name, certs, true); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 152 | } |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 153 | return certs; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 156 | Rrset |
| 157 | findRrSet(Zone& zone, const Name& label, const name::Component& type) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 158 | { |
| 159 | Rrset rrset(&zone); |
| 160 | rrset.setLabel(label); |
| 161 | rrset.setType(type); |
| 162 | |
| 163 | if (!m_dbMgr.find(rrset)) |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 164 | throw Error("Record not found"); |
| 165 | else |
| 166 | return rrset; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 167 | } |
| 168 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 169 | Name |
| 170 | getLabel(const Zone& zone, const Name& fullName) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 171 | { |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 172 | size_t zoneNameSize = zone.getName().size(); |
| 173 | return fullName.getSubName(zoneNameSize + 1, fullName.size() - zoneNameSize - 3); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 174 | } |
| 175 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 176 | IdentityCertificate |
| 177 | findIdCert(Zone& zone, const Name& fullName) |
| 178 | { |
| 179 | Rrset rrset = findRrSet(zone, getLabel(zone, fullName), label::CERT_RR_TYPE); |
| 180 | IdentityCertificate cert; |
| 181 | cert.wireDecode(rrset.getData()); |
| 182 | return cert; |
| 183 | } |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 184 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 185 | Response |
| 186 | findResponse(Zone& zone, const Name& label, const name::Component& type) |
| 187 | { |
| 188 | Rrset rrset = findRrSet(zone, label, type); |
| 189 | Data data(rrset.getData()); |
| 190 | Response resp; |
| 191 | resp.fromData("", zone.getName(), data); |
| 192 | return resp; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | public: |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 196 | PreviousStateCleaner cleaner; // must be first variable |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 197 | ndns::ManagementTool m_tool; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 198 | ndns::DbMgr m_dbMgr; |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 199 | |
| 200 | // Names of pre-created certificates |
| 201 | // Uncomment and run InitPreconfiguredKeys test case and then update names in the |
| 202 | // constructor. |
| 203 | Name rootKsk; |
| 204 | Name rootDsk; |
| 205 | Name otherKsk; |
| 206 | Name otherDsk; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 207 | }; |
| 208 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 209 | // BOOST_FIXTURE_TEST_CASE(InitPreconfiguredKeys, ManagementToolFixture) |
| 210 | // { |
| 211 | // using time::seconds; |
| 212 | |
| 213 | // auto generateCerts = [this] (const Name& zone, const Name& parentCert = Name()) -> Name { |
| 214 | // // to re-generate certificates, uncomment and then update rootKsk/rootDsk names |
| 215 | // Name kskName = m_keyChain.generateRsaKeyPair(zone, true); |
| 216 | // auto kskCert = m_keyChain |
| 217 | // .prepareUnsignedIdentityCertificate(kskName, zone, time::fromUnixTimestamp(seconds(0)), |
| 218 | // time::fromUnixTimestamp(seconds(2147483648)), {}); |
| 219 | // if (parentCert.empty()) { |
| 220 | // m_keyChain.selfSign(*kskCert); |
| 221 | // } |
| 222 | // else { |
| 223 | // m_keyChain.sign(*kskCert, parentCert); |
| 224 | // } |
| 225 | // m_keyChain.addCertificate(*kskCert); |
| 226 | |
| 227 | // Name dskName = m_keyChain.generateRsaKeyPair(zone, false); |
| 228 | // auto dskCert = m_keyChain |
| 229 | // .prepareUnsignedIdentityCertificate(dskName, zone, time::fromUnixTimestamp(seconds(0)), |
| 230 | // time::fromUnixTimestamp(seconds(2147483648)), {}); |
| 231 | // m_keyChain.sign(*dskCert, kskCert->getName()); |
| 232 | // m_keyChain.addCertificate(*dskCert); |
| 233 | |
| 234 | // return dskCert->getName(); |
| 235 | // }; |
| 236 | |
| 237 | // Name rootDsk = generateCerts(ROOT_ZONE); |
| 238 | // generateCerts("/ndns-test", rootDsk); |
| 239 | |
| 240 | // copyDir(TEST_CONFIG_PATH "/tests/unit/mgmt/.ndn", "/tmp/.ndn"); |
| 241 | // std::cout << "Manually copy contents of /tmp/.ndn into tests/unit/mgmt/.ndn" << std::endl; |
| 242 | // } |
| 243 | |
| 244 | BOOST_FIXTURE_TEST_CASE(CreateDeleteRootZone, ManagementToolFixture) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 245 | { |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 246 | m_tool.createZone(ROOT_ZONE, ROOT_ZONE, time::seconds(4600), time::seconds(4600), |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 247 | rootKsk, rootDsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 248 | |
| 249 | Zone zone(ROOT_ZONE); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 250 | BOOST_REQUIRE_EQUAL(m_dbMgr.find(zone), true); |
| 251 | BOOST_REQUIRE_NO_THROW(findIdCert(zone, rootDsk)); |
| 252 | BOOST_CHECK_EQUAL(findIdCert(zone, rootDsk).getName(), rootDsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 253 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 254 | BOOST_CHECK_NO_THROW(m_tool.deleteZone(ROOT_ZONE)); |
| 255 | BOOST_CHECK_EQUAL(m_dbMgr.find(zone), false); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 256 | } |
| 257 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 258 | BOOST_FIXTURE_TEST_CASE(CreateDeleteChildZone, ManagementToolFixture) |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 259 | { |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 260 | Name parentZoneName("/ndns-test"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 261 | Name zoneName = Name(parentZoneName).append("child-zone"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 262 | |
| 263 | BOOST_CHECK_EQUAL(m_keyChain.doesIdentityExist(zoneName), false); |
| 264 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 265 | // will generate keys automatically |
| 266 | m_tool.createZone(zoneName, parentZoneName); |
| 267 | BOOST_CHECK_EQUAL(m_keyChain.doesIdentityExist(zoneName), true); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 268 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 269 | std::vector<Name>&& certs = getCerts(zoneName); |
| 270 | BOOST_REQUIRE_EQUAL(certs.size(), 2); |
| 271 | std::sort(certs.begin(), certs.end()); |
| 272 | |
| 273 | // Name& ksk = certs[0]; |
| 274 | Name& dsk = certs[1]; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 275 | |
| 276 | Zone zone(zoneName); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 277 | BOOST_REQUIRE_EQUAL(m_dbMgr.find(zone), true); |
| 278 | BOOST_REQUIRE_NO_THROW(findIdCert(zone, dsk)); |
| 279 | BOOST_CHECK_EQUAL(findIdCert(zone, dsk).getName(), dsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 280 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 281 | BOOST_CHECK_NO_THROW(m_tool.deleteZone(zoneName)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 282 | |
| 283 | BOOST_CHECK_THROW(m_tool.deleteZone(zoneName), ndns::ManagementTool::Error); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 284 | BOOST_CHECK_THROW(m_tool.deleteZone("/non/existing/zone"), ndns::ManagementTool::Error); |
| 285 | } |
| 286 | |
| 287 | BOOST_FIXTURE_TEST_CASE(CreateZoneWithTtl, ManagementToolFixture) |
| 288 | { |
| 289 | Name parentZoneName("/ndns-test"); |
| 290 | Name zoneName = Name(parentZoneName).append("child-zone"); |
| 291 | |
| 292 | m_tool.createZone(zoneName, parentZoneName, time::seconds(4200), time::days(30)); |
| 293 | BOOST_CHECK_EQUAL(m_keyChain.doesIdentityExist(zoneName), true); |
| 294 | |
| 295 | std::vector<Name>&& certs = getCerts(zoneName); |
| 296 | BOOST_REQUIRE_EQUAL(certs.size(), 2); |
| 297 | std::sort(certs.begin(), certs.end()); |
| 298 | |
| 299 | // Name& ksk = certs[0]; |
| 300 | Name& dsk = certs[1]; |
| 301 | |
| 302 | // Check zone ttl |
| 303 | Zone zone(zoneName); |
| 304 | BOOST_REQUIRE_EQUAL(m_dbMgr.find(zone), true); |
| 305 | BOOST_CHECK_EQUAL(zone.getTtl(), time::seconds(4200)); |
| 306 | |
| 307 | // Check dsk rrset ttl |
| 308 | Rrset rrset; |
| 309 | BOOST_REQUIRE_NO_THROW(rrset = findRrSet(zone, getLabel(zone, dsk), label::CERT_RR_TYPE)); |
| 310 | BOOST_CHECK_EQUAL(rrset.getTtl(), time::seconds(4200)); |
| 311 | |
| 312 | // Check certificate freshnessPeriod and validity |
| 313 | IdentityCertificate cert; |
| 314 | BOOST_REQUIRE_NO_THROW(cert = findIdCert(zone, dsk)); |
| 315 | BOOST_CHECK_EQUAL(cert.getMetaInfo().getFreshnessPeriod(), time::seconds(4200)); |
| 316 | BOOST_CHECK_EQUAL(cert.getNotAfter() - cert.getNotBefore(), time::days(30)); |
| 317 | |
| 318 | m_tool.deleteZone(zoneName); |
| 319 | } |
| 320 | |
| 321 | BOOST_FIXTURE_TEST_CASE(ZoneCreatePreconditions, ManagementToolFixture) |
| 322 | { |
| 323 | BOOST_CHECK_NO_THROW(m_tool.createZone("/net/ndnsim", "/net")); |
| 324 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/net"), ndns::ManagementTool::Error); |
| 325 | |
| 326 | std::vector<Name>&& certs = getCerts("/net/ndnsim"); |
| 327 | BOOST_REQUIRE_EQUAL(certs.size(), 2); |
| 328 | std::sort(certs.begin(), certs.end()); |
| 329 | |
| 330 | Name& ksk = certs[0]; |
| 331 | Name& dsk = certs[1]; |
| 332 | |
| 333 | m_tool.deleteZone("/net/ndnsim"); |
| 334 | // identity will still exist after the zone is deleted |
| 335 | |
| 336 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/net/ndnsim"), ndns::ManagementTool::Error); |
| 337 | |
| 338 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/com"), ndns::ManagementTool::Error); |
| 339 | |
| 340 | BOOST_CHECK_NO_THROW(m_tool.createZone("/net/ndnsim", "/", |
| 341 | time::seconds(1), time::days(1), ksk, dsk)); |
| 342 | BOOST_CHECK_EQUAL(getCerts("/net/ndnsim").size(), 2); |
| 343 | m_tool.deleteZone("/net/ndnsim"); |
| 344 | |
Jiewen Tan | 01693fd | 2015-03-25 20:34:45 -0700 | [diff] [blame] | 345 | // no ksk and dsk will be generated |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 346 | BOOST_CHECK_NO_THROW(m_tool.createZone("/net/ndnsim", "/", |
| 347 | time::seconds(1), time::days(1), Name(), dsk)); |
Jiewen Tan | 01693fd | 2015-03-25 20:34:45 -0700 | [diff] [blame] | 348 | BOOST_CHECK_EQUAL(getCerts("/net/ndnsim").size(), 2); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 349 | m_tool.deleteZone("/net/ndnsim"); |
| 350 | |
| 351 | BOOST_CHECK_NO_THROW(m_tool.createZone("/net/ndnsim", "/", |
| 352 | time::seconds(1), time::days(1), ksk, Name())); |
Jiewen Tan | 01693fd | 2015-03-25 20:34:45 -0700 | [diff] [blame] | 353 | BOOST_CHECK_EQUAL(getCerts("/net/ndnsim").size(), 3); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 354 | m_tool.deleteZone("/net/ndnsim"); |
| 355 | |
| 356 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/net", |
| 357 | time::seconds(1), time::days(1), "/com/ndnsim"), |
| 358 | ndns::ManagementTool::Error); |
| 359 | |
| 360 | m_keyChain.deleteIdentity("/net/ndnsim"); |
| 361 | Name cert = m_keyChain.createIdentity("/net/ndnsim"); |
| 362 | BOOST_CHECK_NO_THROW(m_tool.createZone("/net/ndnsim", "/net", |
| 363 | time::seconds(1), time::days(1), cert)); |
| 364 | |
| 365 | cert = m_keyChain.createIdentity("/com/ndnsim"); |
| 366 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/net", |
| 367 | time::seconds(1), time::days(1), cert), |
| 368 | ndns::ManagementTool::Error); |
| 369 | |
| 370 | cert = m_keyChain.createIdentity("/net/ndnsim/www"); |
| 371 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/net", |
| 372 | time::seconds(1), time::days(1), cert), |
| 373 | ndns::ManagementTool::Error); |
| 374 | |
| 375 | cert = m_keyChain.createIdentity("/net/ndnsim"); |
| 376 | m_keyChain.deleteKeyPairInTpm(m_keyChain.getCertificate(cert)->getPublicKeyName()); |
| 377 | BOOST_CHECK_THROW(m_tool.createZone("/net/ndnsim", "/net", |
| 378 | time::seconds(1), time::days(1), cert), |
| 379 | ndns::ManagementTool::Error); |
| 380 | |
| 381 | // for root zone special case (requires a valid KSK to be specified) |
| 382 | BOOST_CHECK_THROW(m_tool.createZone("/", "/"), ndns::ManagementTool::Error); |
| 383 | |
| 384 | BOOST_CHECK_NO_THROW(m_tool.createZone("/", "/", time::seconds(1), time::days(1), |
| 385 | rootKsk)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | class OutputTester |
| 389 | { |
| 390 | public: |
| 391 | OutputTester() |
| 392 | : savedBuf(std::clog.rdbuf()) |
| 393 | { |
| 394 | std::cout.rdbuf(buffer.rdbuf()); |
| 395 | } |
| 396 | |
| 397 | ~OutputTester() |
| 398 | { |
| 399 | std::cout.rdbuf(savedBuf); |
| 400 | } |
| 401 | |
| 402 | public: |
| 403 | std::stringstream buffer; |
| 404 | std::streambuf* savedBuf; |
| 405 | }; |
| 406 | |
| 407 | BOOST_FIXTURE_TEST_CASE(ExportCertificate, ManagementToolFixture) |
| 408 | { |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 409 | std::string outputFile = TEST_CERTDIR.string() + "/ss.cert"; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 410 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 411 | BOOST_REQUIRE_THROW(m_tool.exportCertificate("/random/name", outputFile), |
| 412 | ndns::ManagementTool::Error); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 413 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 414 | BOOST_REQUIRE_EQUAL(boost::filesystem::exists(outputFile), false); |
| 415 | // doesn't check the zone, export from KeyChain directly |
| 416 | BOOST_CHECK_NO_THROW(m_tool.exportCertificate(otherDsk, outputFile)); |
| 417 | BOOST_REQUIRE_EQUAL(boost::filesystem::exists(outputFile), true); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 418 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 419 | std::string dskValue = |
| 420 | "Bv0C3Ac3CAluZG5zLXRlc3QIA0tFWQgRZHNrLTE0MTY5NzQwMDY2NTkIB0lELUNF\n" |
| 421 | "UlQICf0AAAFJ6jt6DhQDGAECFf0BYTCCAV0wIhgPMTk3MDAxMDEwMDAwMDBaGA8y\n" |
| 422 | "MDM4MDExOTAzMTQwOFowEzARBgNVBCkTCi9uZG5zLXRlc3QwggEgMA0GCSqGSIb3\n" |
| 423 | "DQEBAQUAA4IBDQAwggEIAoIBAQDIFUL7Fz8mmxxIT8l3FtWm+CuH9+iQ0Uj/a30P\n" |
| 424 | "mKe4gWvtxzhb4vIngYbXGv2iUzHswdqYlTVeDdW6eOFKMvyY5p5eVtLqDFZ7EEK0\n" |
| 425 | "0rpTh648HjCSz+Awgp2nbiYAAVvhP6YF+NxGBH412uPI7kLY6ozypsNmYP+K4SYT\n" |
| 426 | "oY9ee4xLSjqzXfLMyP1h8OHcN/aNmccRJlyYblCmCDbZPnzu3ttHHwdrYQLeFvb0\n" |
| 427 | "B5grCAQoPHwkfxkEnzQBA/fbUdvKNdayEkuibPLlIlmj2cBtk5iVk8JCSibP3Zlz\n" |
| 428 | "36Sks1DAO+1EvCRnjoH5vYmkpMUBFue+6A40IQG4brM2CiIRAgERFjMbAQEcLgcs\n" |
| 429 | "CAluZG5zLXRlc3QIA0tFWQgRa3NrLTE0MTY5NzQwMDY1NzcIB0lELUNFUlQX/QEA\n" |
| 430 | "GP2bQqp/7rfb8tShwDbXihWrPojwEFqlfwLibK9aM1RxwpHVqbtRsPYmuWc87LaU\n" |
| 431 | "OztPOZinHGL80ypFC+wYadVGnE8MPdTkUYUik7mbHDEsYWADoyGMVhoZv+OTJ/5m\n" |
| 432 | "MUh/kR1FMiqtZcIQtLB3cdCeGlZBl9wm2SvhMKVUym3RsQO46RpnmsEQcCfWMBZg\n" |
| 433 | "u5U6mhYIpiQPZ/sYyZ9zXstwsIfaF1p0V+1dW5y99PZJXIegVKhkGGU0ibjYoJy7\n" |
| 434 | "6uUjqBBDX8KMdt6n/Zy1/pGG1eOchMyV0JZ8+MJxWuiTEh5PJeYMFHTV/BVp8aPy\n" |
| 435 | "8UNqhMpjAZwW6pdvOZADVg==\n"; |
| 436 | |
| 437 | { |
| 438 | std::ifstream ifs(outputFile.c_str()); |
| 439 | std::string actualValue((std::istreambuf_iterator<char>(ifs)), |
| 440 | std::istreambuf_iterator<char>()); |
| 441 | BOOST_CHECK_EQUAL(actualValue, dskValue); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 442 | } |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 443 | boost::filesystem::remove(outputFile); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 444 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 445 | // doesn't check the zone, export from KeyChain directly |
| 446 | BOOST_CHECK_NO_THROW(m_tool.exportCertificate(otherKsk, outputFile)); |
| 447 | boost::filesystem::remove(outputFile); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 448 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 449 | Name zoneName("/ndns-test"); |
| 450 | m_tool.createZone(zoneName, ROOT_ZONE, time::seconds(4200), time::days(30), |
| 451 | otherKsk, otherDsk); |
| 452 | |
| 453 | m_keyChain.deleteCertificate(otherKsk); |
| 454 | m_keyChain.deleteCertificate(otherDsk); |
| 455 | |
| 456 | // retrieve cert from the zone |
| 457 | BOOST_CHECK_NO_THROW(m_tool.exportCertificate(otherDsk, outputFile)); |
| 458 | { |
| 459 | std::ifstream ifs(outputFile.c_str()); |
| 460 | std::string actualValue((std::istreambuf_iterator<char>(ifs)), |
| 461 | std::istreambuf_iterator<char>()); |
| 462 | BOOST_CHECK_EQUAL(actualValue, dskValue); |
| 463 | } |
| 464 | boost::filesystem::remove(outputFile); |
| 465 | |
| 466 | BOOST_REQUIRE_THROW(m_tool.exportCertificate(otherKsk, outputFile), |
| 467 | ndns::ManagementTool::Error); |
| 468 | |
| 469 | // output to std::cout |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 470 | std::string acutalOutput; |
| 471 | { |
| 472 | OutputTester tester; |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 473 | m_tool.exportCertificate(otherDsk, "-"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 474 | acutalOutput = tester.buffer.str(); |
| 475 | } |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 476 | BOOST_CHECK_EQUAL(acutalOutput, dskValue); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | BOOST_FIXTURE_TEST_CASE(AddRrSet1, ManagementToolFixture) |
| 480 | { |
| 481 | // check pre-condition |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 482 | BOOST_CHECK_THROW(m_tool.addRrSet(ROOT_ZONE, "/test", label::NS_RR_TYPE, NDNS_RESP), |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 483 | ndns::ManagementTool::Error); |
| 484 | |
| 485 | Name zoneName("/ndns-test"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 486 | Zone zone(zoneName); |
| 487 | m_dbMgr.insert(zone); |
| 488 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 489 | BOOST_CHECK_THROW(m_tool.addRrSet(ROOT_ZONE, "/test", label::NS_RR_TYPE, NDNS_UNKNOWN), |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 490 | ndns::ManagementTool::Error); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 491 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, "/test", label::CERT_RR_TYPE, NDNS_RAW), |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 492 | ndns::ManagementTool::Error); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 493 | BOOST_CHECK_THROW(m_tool.addRrSet(ROOT_ZONE, "/test", label::NS_RR_TYPE, NDNS_RAW), |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 494 | ndns::ManagementTool::Error); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 495 | BOOST_CHECK_THROW(m_tool.addRrSet(ROOT_ZONE, "/test", label::TXT_RR_TYPE, NDNS_RAW), |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 496 | ndns::ManagementTool::Error); |
| 497 | |
| 498 | m_dbMgr.remove(zone); |
| 499 | } |
| 500 | |
| 501 | BOOST_FIXTURE_TEST_CASE(AddRrSet2, ManagementToolFixture) |
| 502 | { |
| 503 | Name zoneName("/ndns-test"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 504 | Zone zone(zoneName); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 505 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 506 | uint64_t version = 1234; |
| 507 | time::seconds ttl1(4200); |
| 508 | time::seconds ttl2(4500); |
| 509 | m_tool.createZone(zoneName, ROOT_ZONE, ttl1); |
| 510 | |
| 511 | //add NS NDNS_AUTH and check user-defined ttl |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 512 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(zoneName, "/l1", label::NS_RR_TYPE, NDNS_AUTH, 7654, |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 513 | {}, DEFAULT_CERT, ttl2)); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 514 | Response response; |
| 515 | BOOST_CHECK_NO_THROW(response = findResponse(zone, "/l1", label::NS_RR_TYPE)); |
| 516 | BOOST_CHECK_EQUAL(response.getNdnsType(), NDNS_AUTH); |
| 517 | BOOST_CHECK_EQUAL(response.getVersion(), name::Component::fromVersion(7654)); |
| 518 | BOOST_CHECK_EQUAL(response.getFreshnessPeriod(), ttl2); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 519 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 520 | // add NS NDNS_RESP and check default ttl |
| 521 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(zoneName, "/l2", label::NS_RR_TYPE, NDNS_RESP, 15)); |
| 522 | BOOST_CHECK_NO_THROW(response = findResponse(zone, "/l2", label::NS_RR_TYPE)); |
| 523 | BOOST_CHECK_EQUAL(response.getNdnsType(), NDNS_RESP); |
| 524 | BOOST_CHECK_EQUAL(response.getVersion(), name::Component::fromVersion(15)); |
| 525 | BOOST_CHECK_EQUAL(response.getFreshnessPeriod(), ttl1); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 526 | |
| 527 | //add TXT NDNS_RESP and check rr |
| 528 | std::string test = "oops"; |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 529 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(zoneName, "/l2", label::TXT_RR_TYPE, NDNS_RESP, version, |
| 530 | {"oops", "again"})); |
| 531 | BOOST_CHECK_NO_THROW(response = findResponse(zone, "/l2", label::TXT_RR_TYPE)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 532 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 533 | BOOST_REQUIRE_EQUAL(response.getRrs().size(), 2); |
| 534 | { |
| 535 | const Block& block = response.getRrs()[0]; |
| 536 | std::string someString(reinterpret_cast<const char*>(block.value()), block.value_size()); |
| 537 | BOOST_CHECK_EQUAL("oops", someString); |
| 538 | } |
| 539 | |
| 540 | { |
| 541 | const Block& block = response.getRrs()[1]; |
| 542 | std::string someString(reinterpret_cast<const char*>(block.value()), block.value_size()); |
| 543 | BOOST_CHECK_EQUAL("again", someString); |
| 544 | } |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 545 | |
| 546 | //add user defined type |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 547 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, "/l2", name::Component("USER-DEFINED"), NDNS_RAW, |
| 548 | 1112223, {"10.10.0.1", "SECOND_INVALID_DATA"}), |
| 549 | ndns::ManagementTool::Error); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 550 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 551 | m_tool.addRrSet(zoneName, "/l2", name::Component("USER-DEFINED"), NDNS_RAW, 1112223, |
| 552 | {"10.10.0.1"}); |
| 553 | BOOST_CHECK_NO_THROW(response = findResponse(zone, "/l2", name::Component("USER-DEFINED"))); |
| 554 | BOOST_CHECK_EQUAL(response.getVersion(), name::Component::fromVersion(1112223)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 555 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 556 | std::string actualValue(reinterpret_cast<const char*>(response.getAppContent().value()), |
| 557 | response.getAppContent().value_size()); |
| 558 | BOOST_CHECK_EQUAL(actualValue, "10.10.0.1"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | BOOST_FIXTURE_TEST_CASE(AddRrSet3, ManagementToolFixture) |
| 562 | { |
| 563 | // check pre-condition |
| 564 | Name zoneName("/ndns-test"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 565 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 566 | std::string certPath = TEST_CERTDIR.string(); |
| 567 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, certPath), ndns::ManagementTool::Error); |
| 568 | |
| 569 | m_tool.createZone(zoneName, ROOT_ZONE); |
| 570 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, certPath), ndns::ManagementTool::Error); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | BOOST_FIXTURE_TEST_CASE(AddRrSet4, ManagementToolFixture) |
| 574 | { |
| 575 | Name parentZoneName("/ndns-test"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 576 | Name zoneName = Name(parentZoneName).append("/child-zone"); |
| 577 | |
| 578 | Zone parentZone(parentZoneName); |
| 579 | |
| 580 | m_tool.createZone(parentZoneName, ROOT_ZONE, time::seconds(1), time::days(1), otherKsk, otherDsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 581 | m_tool.createZone(zoneName, parentZoneName); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 582 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 583 | std::vector<Name>&& certs = getCerts(zoneName); |
| 584 | BOOST_REQUIRE_EQUAL(certs.size(), 2); |
| 585 | std::sort(certs.begin(), certs.end()); |
| 586 | |
| 587 | Name& ksk = certs[0]; |
| 588 | // Name& dsk = certs[1]; |
| 589 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 590 | std::string output = TEST_CERTDIR.string() + "/ss.cert"; |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 591 | m_tool.exportCertificate(ksk, output); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 592 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 593 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(parentZoneName, output)); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 594 | BOOST_CHECK_NO_THROW(findIdCert(parentZone, ksk)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 595 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 596 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(parentZoneName, "/child-zone", |
| 597 | label::NS_RR_TYPE, NDNS_RESP)); |
| 598 | BOOST_CHECK_NO_THROW(findRrSet(parentZone, "/child-zone", label::NS_RR_TYPE)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 599 | |
| 600 | //add KSK ID-CERT with illegal name and convert it |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 601 | Name iZoneName = Name(parentZoneName).append("illegal"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 602 | Name illegalCertName = m_keyChain.createIdentity(iZoneName); |
| 603 | m_tool.exportCertificate(illegalCertName, output); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 604 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(parentZoneName, output)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 605 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 606 | Name legalCertName = |
| 607 | Name(parentZoneName) |
| 608 | .append("KEY") |
| 609 | .append("illegal") |
| 610 | .append(illegalCertName.getSubName(3)); |
| 611 | BOOST_CHECK_NO_THROW(findIdCert(parentZone, legalCertName)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | BOOST_FIXTURE_TEST_CASE(AddRrSet5, ManagementToolFixture) |
| 615 | { |
| 616 | //check using user provided certificate |
| 617 | Name parentZoneName("/ndns-test"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 618 | Name zoneName = Name(parentZoneName).append("child-zone"); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 619 | |
| 620 | Name dskName = m_keyChain.generateRsaKeyPair(parentZoneName, false); |
| 621 | shared_ptr<IdentityCertificate> dskCert = m_keyChain.selfSign(dskName); |
| 622 | m_keyChain.addCertificateAsKeyDefault(*dskCert); |
| 623 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 624 | // check addRrSet1 |
| 625 | m_tool.createZone(parentZoneName, ROOT_ZONE, time::seconds(1), time::days(1), otherKsk, otherDsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 626 | m_tool.createZone(zoneName, parentZoneName); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 627 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 628 | std::vector<Name>&& certs = getCerts(zoneName); |
| 629 | BOOST_REQUIRE_EQUAL(certs.size(), 2); |
| 630 | std::sort(certs.begin(), certs.end()); |
| 631 | |
| 632 | Name& ksk = certs[0]; |
| 633 | // Name& dsk = certs[1]; |
| 634 | |
| 635 | std::string output = TEST_CERTDIR.string() + "/ss.cert"; |
| 636 | m_tool.exportCertificate(ksk, output); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 637 | |
| 638 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(parentZoneName, output, time::seconds(4600), |
| 639 | dskCert->getName())); |
| 640 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 641 | // check addRrSet2 |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 642 | Name label1("/net/ndnsim1"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 643 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(parentZoneName, "/l1", label::NS_RR_TYPE, NDNS_AUTH, -1, {}, |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 644 | dskCert->getName())); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 645 | } |
| 646 | |
Jiewen Tan | d2d2182 | 2015-03-19 15:37:03 -0700 | [diff] [blame] | 647 | BOOST_FIXTURE_TEST_CASE(AddRrSet6, ManagementToolFixture) |
| 648 | { |
Jiewen Tan | 8cd35ea | 2015-03-20 00:44:23 -0700 | [diff] [blame] | 649 | //check invalid output |
Jiewen Tan | d2d2182 | 2015-03-19 15:37:03 -0700 | [diff] [blame] | 650 | Name parentZoneName("/ndns-test"); |
| 651 | Name zoneName = Name(parentZoneName).append("child-zone"); |
| 652 | m_tool.createZone(zoneName, parentZoneName); |
| 653 | |
Jiewen Tan | d2d2182 | 2015-03-19 15:37:03 -0700 | [diff] [blame] | 654 | Name content = "invalid data packet"; |
| 655 | std::string output = TEST_CERTDIR.string() + "/ss.cert"; |
| 656 | ndn::io::save(content, output); |
| 657 | |
| 658 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, output), ndns::ManagementTool::Error); |
| 659 | } |
| 660 | |
Jiewen Tan | 8cd35ea | 2015-03-20 00:44:23 -0700 | [diff] [blame] | 661 | BOOST_FIXTURE_TEST_CASE(AddRrSet7, ManagementToolFixture) |
| 662 | { |
| 663 | //check version control |
| 664 | Name parentZoneName("/ndns-test"); |
| 665 | Name zoneName = Name(parentZoneName).append("child-zone"); |
| 666 | m_tool.createZone(zoneName, parentZoneName); |
| 667 | |
| 668 | Name label("/label"); |
| 669 | uint64_t version = 110; |
| 670 | |
| 671 | m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version); |
| 672 | // throw error when adding duplicated rrset with the same version |
| 673 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version), |
| 674 | ndns::ManagementTool::Error); |
| 675 | version--; |
| 676 | // throw error when adding duplicated rrset with older version |
| 677 | BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version), |
| 678 | ndns::ManagementTool::Error); |
| 679 | |
| 680 | version++; |
| 681 | version++; |
| 682 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version)); |
| 683 | |
| 684 | Zone zone(zoneName); |
| 685 | m_dbMgr.find(zone); |
| 686 | Rrset rrset; |
| 687 | rrset.setZone(&zone); |
| 688 | rrset.setLabel(label); |
| 689 | rrset.setType(label::NS_RR_TYPE); |
| 690 | m_dbMgr.find(rrset); |
| 691 | |
| 692 | BOOST_CHECK_EQUAL(rrset.getVersion(), name::Component::fromVersion(version)); |
| 693 | } |
| 694 | |
Jiewen Tan | 74d745c | 2015-03-20 01:40:41 -0700 | [diff] [blame] | 695 | BOOST_FIXTURE_TEST_CASE(AddRrSet8, ManagementToolFixture) |
| 696 | { |
| 697 | //check input with different formats |
| 698 | Name parentZoneName("/ndns-test"); |
| 699 | Name zoneName = Name(parentZoneName).append("child-zone"); |
| 700 | m_tool.createZone(zoneName, parentZoneName); |
| 701 | |
| 702 | std::string output = TEST_CERTDIR.string() + "/a.cert"; |
| 703 | |
| 704 | // base64 |
| 705 | Name dskName = m_keyChain.generateRsaKeyPair(zoneName, false); |
| 706 | shared_ptr<IdentityCertificate> dskCert = m_keyChain.selfSign(dskName); |
| 707 | |
Junxiao Shi | dc2df7c | 2016-08-31 12:53:14 +0000 | [diff] [blame] | 708 | ndn::io::save(*dskCert, output, ndn::io::BASE64); |
Jiewen Tan | 74d745c | 2015-03-20 01:40:41 -0700 | [diff] [blame] | 709 | BOOST_CHECK_NO_THROW( |
Junxiao Shi | dc2df7c | 2016-08-31 12:53:14 +0000 | [diff] [blame] | 710 | m_tool.addRrSet(zoneName, output, DEFAULT_CACHE_TTL, DEFAULT_CERT, ndn::io::BASE64)); |
Jiewen Tan | 74d745c | 2015-03-20 01:40:41 -0700 | [diff] [blame] | 711 | |
| 712 | // raw |
| 713 | dskName = m_keyChain.generateRsaKeyPair(zoneName, false); |
| 714 | dskCert = m_keyChain.selfSign(dskName); |
| 715 | |
| 716 | ndn::io::save(*dskCert, output, ndn::io::NO_ENCODING); |
| 717 | BOOST_CHECK_NO_THROW( |
| 718 | m_tool.addRrSet(zoneName, output, DEFAULT_CACHE_TTL, DEFAULT_CERT, ndn::io::NO_ENCODING)); |
| 719 | |
| 720 | // hex |
| 721 | dskName = m_keyChain.generateRsaKeyPair(zoneName, false); |
| 722 | dskCert = m_keyChain.selfSign(dskName); |
| 723 | |
| 724 | ndn::io::save(*dskCert, output, ndn::io::HEX); |
| 725 | BOOST_CHECK_NO_THROW( |
| 726 | m_tool.addRrSet(zoneName, output, DEFAULT_CACHE_TTL, DEFAULT_CERT, ndn::io::HEX)); |
| 727 | |
| 728 | // incorrect encoding input |
| 729 | dskName = m_keyChain.generateRsaKeyPair(zoneName, false); |
| 730 | dskCert = m_keyChain.selfSign(dskName); |
| 731 | |
| 732 | ndn::io::save(*dskCert, output, ndn::io::HEX); |
| 733 | BOOST_CHECK_THROW( |
| 734 | m_tool.addRrSet(zoneName, output, DEFAULT_CACHE_TTL, DEFAULT_CERT, |
| 735 | static_cast<ndn::io::IoEncoding>(127)), |
| 736 | ndns::ManagementTool::Error); |
| 737 | } |
| 738 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 739 | BOOST_FIXTURE_TEST_CASE(ListAllZones, ManagementToolFixture) |
| 740 | { |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 741 | m_tool.createZone(ROOT_ZONE, ROOT_ZONE, time::seconds(1), time::days(1), rootKsk, rootDsk); |
| 742 | m_tool.createZone("/ndns-test", ROOT_ZONE, time::seconds(10), time::days(1), otherKsk, otherDsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 743 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 744 | std::string expectedValue = |
| 745 | "/ ; default-ttl=1 default-key=/dsk-1416974006466 " |
| 746 | "default-certificate=/KEY/dsk-1416974006466/ID-CERT/%FD%00%00%01I%EA%3By%28\n" |
| 747 | "/ndns-test ; default-ttl=10 default-key=/ndns-test/dsk-1416974006659 " |
| 748 | "default-certificate=/ndns-test/KEY/dsk-1416974006659/ID-CERT/%FD%00%00%01I%EA%3Bz%0E\n"; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 749 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 750 | output_test_stream testOutput; |
| 751 | m_tool.listAllZones(testOutput); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 752 | BOOST_CHECK(testOutput.is_equal(expectedValue)); |
| 753 | } |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 754 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 755 | BOOST_FIXTURE_TEST_CASE(ListZone, ManagementToolFixture) |
| 756 | { |
| 757 | m_tool.createZone("/ndns-test", ROOT_ZONE, time::seconds(10), time::days(1), otherKsk, otherDsk); |
| 758 | |
| 759 | // Add NS with NDNS_RESP |
| 760 | m_tool.addRrSet("/ndns-test", "/label1", label::NS_RR_TYPE, NDNS_RESP, 100); |
| 761 | |
| 762 | // Add NS with NDNS_AUTH |
| 763 | m_tool.addRrSet("/ndns-test", "/label2", label::NS_RR_TYPE, NDNS_AUTH, 100000); |
| 764 | |
| 765 | // Add TXT from file |
| 766 | std::string output = TEST_CERTDIR.string() + "/a.rrset"; |
| 767 | Response re1; |
| 768 | re1.setZone("/ndns-test"); |
| 769 | re1.setQueryType(label::NDNS_ITERATIVE_QUERY); |
| 770 | re1.setRrLabel("/label2"); |
| 771 | re1.setRrType(label::TXT_RR_TYPE); |
| 772 | re1.setNdnsType(NDNS_RESP); |
| 773 | re1.setVersion(name::Component::fromVersion(654321)); |
| 774 | re1.addRr("First RR"); |
| 775 | re1.addRr("Second RR"); |
| 776 | re1.addRr("Last RR"); |
| 777 | shared_ptr<Data> data1 = re1.toData(); |
| 778 | m_keyChain.sign(*data1, otherDsk); |
| 779 | ndn::io::save(*data1, output); |
| 780 | m_tool.addRrSet("/ndns-test", output); |
| 781 | |
| 782 | // Add TXT in normal way |
| 783 | m_tool.addRrSet("/ndns-test", "/label3", label::TXT_RR_TYPE, NDNS_RESP, 3333, |
| 784 | {"Hello", "World"}, otherDsk); |
| 785 | |
| 786 | // Add User-Defined |
| 787 | Response re2; |
| 788 | re2.setZone("/ndns-test"); |
| 789 | re2.setQueryType(label::NDNS_ITERATIVE_QUERY); |
| 790 | re2.setRrLabel("/label4"); |
| 791 | re2.setRrType(name::Component("USER-DEFINED")); |
| 792 | re2.setNdnsType(NDNS_RAW); |
| 793 | re2.setVersion(name::Component::fromVersion(1234567)); |
Junxiao Shi | 767f35c | 2016-07-23 01:54:42 +0000 | [diff] [blame] | 794 | re2.setAppContent(makeBinaryBlock(ndn::tlv::Content, "Hello", sizeof("Hello"))); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 795 | shared_ptr<Data> data2 = re2.toData(); |
| 796 | m_keyChain.sign(*data2, otherDsk); |
| 797 | ndn::io::save(*data2, output); |
| 798 | m_tool.addRrSet("/ndns-test", output); |
| 799 | |
| 800 | output_test_stream testOutput; |
| 801 | m_tool.listZone("/ndns-test", testOutput, true); |
| 802 | |
| 803 | std::string expectedValue = |
| 804 | "; Zone /ndns-test\n" |
| 805 | "\n" |
| 806 | "; rrset=/label1 type=NS version=%FDd signed-by=/ndns-test/KEY/dsk-1416974006659/ID-CERT\n" |
| 807 | "/label1 10 NS \n" |
| 808 | "\n" |
| 809 | "/label2 10 NS ; content-type=NDNS-Auth version=%FD%00%01%86%A0 " |
| 810 | "signed-by=/ndns-test/KEY/dsk-1416974006659/ID-CERT\n" |
| 811 | "\n" |
| 812 | "; rrset=/label2 type=TXT version=%FD%00%09%FB%F1 " |
| 813 | "signed-by=/ndns-test/KEY/dsk-1416974006659/ID-CERT\n" |
| 814 | "/label2 10 TXT First RR\n" |
| 815 | "/label2 10 TXT Second RR\n" |
| 816 | "/label2 10 TXT Last RR\n" |
| 817 | "\n" |
| 818 | "; rrset=/label3 type=TXT version=%FD%0D%05 " |
| 819 | "signed-by=/ndns-test/KEY/dsk-1416974006659/ID-CERT\n" |
| 820 | "/label3 10 TXT Hello\n" |
| 821 | "/label3 10 TXT World\n" |
| 822 | "\n" |
| 823 | "/label4 10 USER-DEFINED ; content-type=NDNS-Raw version=%FD%00%12%D6%87 " |
| 824 | "signed-by=/ndns-test/KEY/dsk-1416974006659/ID-CERT\n" |
| 825 | "; FQZIZWxsbwA=\n" |
| 826 | "\n" |
| 827 | "/dsk-1416974006659 10 ID-CERT ; content-type=NDNS-Raw version=%FD%00%00%01I%EA%3Bz%0E " |
| 828 | "signed-by=/ndns-test/KEY/ksk-1416974006577/ID-CERT\n" |
Jiewen Tan | d1dd86d | 2015-03-20 10:26:28 -0700 | [diff] [blame] | 829 | "; Certificate name:\n" |
| 830 | "; /ndns-test/KEY/dsk-1416974006659/ID-CERT/%FD%00%00%01I%EA%3Bz%0E\n" |
| 831 | "; Validity:\n" |
| 832 | "; NotBefore: 19700101T000000\n" |
| 833 | "; NotAfter: 20380119T031408\n" |
| 834 | "; Subject Description:\n" |
| 835 | "; 2.5.4.41: /ndns-test\n" |
| 836 | "; Public key bits: (RSA)\n" |
| 837 | "; MIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEAyBVC+xc/JpscSE/JdxbV\n" |
| 838 | "; pvgrh/fokNFI/2t9D5inuIFr7cc4W+LyJ4GG1xr9olMx7MHamJU1Xg3VunjhSjL8\n" |
| 839 | "; mOaeXlbS6gxWexBCtNK6U4euPB4wks/gMIKdp24mAAFb4T+mBfjcRgR+NdrjyO5C\n" |
| 840 | "; 2OqM8qbDZmD/iuEmE6GPXnuMS0o6s13yzMj9YfDh3Df2jZnHESZcmG5Qpgg22T58\n" |
| 841 | "; 7t7bRx8Ha2EC3hb29AeYKwgEKDx8JH8ZBJ80AQP321HbyjXWshJLomzy5SJZo9nA\n" |
| 842 | "; bZOYlZPCQkomz92Zc9+kpLNQwDvtRLwkZ46B+b2JpKTFARbnvugONCEBuG6zNgoi\n" |
| 843 | "; EQIB\n" |
| 844 | "; Signature Information:\n" |
| 845 | "; Signature Type: Unknown Signature Type\n" |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 846 | "\n"; |
| 847 | |
| 848 | BOOST_CHECK(testOutput.is_equal(expectedValue)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | BOOST_FIXTURE_TEST_CASE(GetRrSet, ManagementToolFixture) |
| 852 | { |
| 853 | Name zoneName("/ndns-test"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 854 | m_tool.createZone(zoneName, ROOT_ZONE, time::seconds(1), time::days(1), otherKsk, otherDsk); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 855 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 856 | m_tool.addRrSet(zoneName, "/label", name::Component("TXT"), NDNS_RESP, 100, |
| 857 | {"Value1", "Value2"}); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 858 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 859 | std::string expectedValue = |
| 860 | "Bv0BdwchCAluZG5zLXRlc3QIBE5ETlMIBWxhYmVsCANUWFQIAv1kFAcZAgPotAEB\n" |
| 861 | "FRC/BlZhbHVlMb8GVmFsdWUyFjMbAQEcLgcsCAluZG5zLXRlc3QIA0tFWQgRZHNr\n" |
| 862 | "LTE0MTY5NzQwMDY2NTkIB0lELUNFUlQX/QEAqhzoQmGGeFcUlZ9pEp0ohVoTEw18\n" |
| 863 | "qfB1DN6sssOpjCu3V41SHmoybPPkdW84i/h5n6TmuuePWva+fk6l9Xppd3F4lCX0\n" |
| 864 | "Tb1lyxjnLaQjBKTYxNReM3h55XY7sCvb2RpFCSDZ/PFfzuCwdWAIqcau10H9IjNm\n" |
| 865 | "2NO+m+jW43tnou9TLrNzN80bYFQc4FEwUCJUA4jPf+1NwDUMp9LWN5IILwU+Ttx6\n" |
| 866 | "45u2rK6KXfgcHR3zifwi2IZ9mEjr5bhXxvL8zP+tgaPb0t6O9gujry0an2h+hUH5\n" |
| 867 | "Aldt49RIyipHXO7R2736ZqkUZ553DSIUhaYPuXRlByNbiW6Za+LMPgJaPg==\n"; |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 868 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 869 | output_test_stream testOutput; |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 870 | m_tool.getRrSet(zoneName, "/label", name::Component("TXT"), testOutput); |
| 871 | BOOST_CHECK(testOutput.is_equal(expectedValue)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | BOOST_FIXTURE_TEST_CASE(RemoveRrSet, ManagementToolFixture) |
| 875 | { |
| 876 | Name zoneName("/ndns-test"); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 877 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 878 | m_tool.createZone(zoneName, ROOT_ZONE); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 879 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 880 | BOOST_CHECK_NO_THROW(m_tool.addRrSet(zoneName, "/label", label::NS_RR_TYPE, NDNS_RESP)); |
| 881 | |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 882 | Zone zone(zoneName); |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 883 | BOOST_CHECK_NO_THROW(findRrSet(zone, "/label", label::NS_RR_TYPE)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 884 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 885 | BOOST_CHECK_NO_THROW(m_tool.removeRrSet(zoneName, "/label", label::NS_RR_TYPE)); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 886 | |
Alexander Afanasyev | d6b3bda | 2014-11-25 17:33:58 -0800 | [diff] [blame] | 887 | BOOST_CHECK_THROW(findRrSet(zone, "/label", label::NS_RR_TYPE), Error); |
Jiewen Tan | 870b29b | 2014-11-17 19:09:49 -0800 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | BOOST_AUTO_TEST_SUITE_END() |
| 891 | |
| 892 | } // namespace tests |
| 893 | } // namespace ndns |
| 894 | } // namespace ndn |