blob: 532aeebc8cccb1f3960ddf898762430596a5fdca [file] [log] [blame]
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -08001/* -*- 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
27namespace ndn {
28namespace ndncert {
29namespace tests {
30
31BOOST_FIXTURE_TEST_SUITE(TestCaConfig, IdentityManagementV2Fixture)
32
33BOOST_AUTO_TEST_CASE(ReadConfigFileWithFileAnchor)
34{
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080035 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 Zhang5ebeb692017-03-10 14:13:01 -080039 BOOST_CHECK(!itemA.m_probe);
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080040 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 Zhang5ebeb692017-03-10 14:13:01 -080048 BOOST_CHECK(itemB.m_probe);
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080049 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 Zhangdaf2fd72017-01-19 11:31:35 -080052 "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080053 BOOST_CHECK_EQUAL(itemB.m_supportedChallenges.size(), 1);
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080054}
55
56BOOST_AUTO_TEST_SUITE_END() // TestCaConfig
57
58} // namespace tests
59} // namespace ndncert
60} // namespace ndn