Zhiyi Zhang | daf2fd7 | 2017-01-19 11:31:35 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2017, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ndncert, a certificate management system based on NDN. |
| 6 | * |
| 7 | * ndncert is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ndncert authors and contributors. |
| 19 | */ |
| 20 | |
| 21 | #include "identity-management-fixture.hpp" |
| 22 | #include "ca-config.hpp" |
| 23 | #include <ndn-cxx/security/transform/base64-encode.hpp> |
| 24 | #include <ndn-cxx/security/transform/buffer-source.hpp> |
| 25 | #include <ndn-cxx/security/transform/stream-sink.hpp> |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace ndncert { |
| 29 | namespace tests { |
| 30 | |
| 31 | BOOST_FIXTURE_TEST_SUITE(TestCaConfig, IdentityManagementV2Fixture) |
| 32 | |
| 33 | BOOST_AUTO_TEST_CASE(ReadConfigFileWithFileAnchor) |
| 34 | { |
Zhiyi Zhang | 06d6ae9 | 2017-03-08 14:59:45 -0800 | [diff] [blame] | 35 | CaConfig config; |
| 36 | config.load("tests/unit-tests/ca.conf.test"); |
| 37 | auto itemA = config.m_caItems.front(); |
| 38 | BOOST_CHECK_EQUAL(itemA.m_caName.toUri(), "/ndn/edu/ucla/cs/zhiyi"); |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame^] | 39 | BOOST_CHECK(!itemA.m_probe); |
Zhiyi Zhang | 06d6ae9 | 2017-03-08 14:59:45 -0800 | [diff] [blame] | 40 | BOOST_CHECK_EQUAL(itemA.m_freshnessPeriod, time::seconds(720)); |
| 41 | BOOST_CHECK_EQUAL(itemA.m_validityPeriod, time::days(360)); |
| 42 | BOOST_CHECK_EQUAL(itemA.m_anchor.toUri(), |
| 43 | "/ndn/edu/ucla/cs/zhiyi/KEY/%9A%E0%C6%C6%09%7C%92i/self/%FD%00%00%01Z%B0%2AJ%B4"); |
| 44 | BOOST_CHECK_EQUAL(itemA.m_supportedChallenges.size(), 1); |
| 45 | |
| 46 | auto itemB = config.m_caItems.back(); |
| 47 | BOOST_CHECK_EQUAL(itemB.m_caName.toUri(), "/ndn/site1"); |
Zhiyi Zhang | 5ebeb69 | 2017-03-10 14:13:01 -0800 | [diff] [blame^] | 48 | BOOST_CHECK(itemB.m_probe); |
Zhiyi Zhang | 06d6ae9 | 2017-03-08 14:59:45 -0800 | [diff] [blame] | 49 | BOOST_CHECK_EQUAL(itemB.m_freshnessPeriod, time::seconds(720)); |
| 50 | BOOST_CHECK_EQUAL(itemB.m_validityPeriod, time::days(360)); |
| 51 | BOOST_CHECK_EQUAL(itemB.m_anchor.toUri(), |
Zhiyi Zhang | daf2fd7 | 2017-01-19 11:31:35 -0800 | [diff] [blame] | 52 | "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5"); |
Zhiyi Zhang | 06d6ae9 | 2017-03-08 14:59:45 -0800 | [diff] [blame] | 53 | BOOST_CHECK_EQUAL(itemB.m_supportedChallenges.size(), 1); |
Zhiyi Zhang | daf2fd7 | 2017-01-19 11:31:35 -0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | BOOST_AUTO_TEST_SUITE_END() // TestCaConfig |
| 57 | |
| 58 | } // namespace tests |
| 59 | } // namespace ndncert |
| 60 | } // namespace ndn |