blob: 24b8536d9d835e119063126cdc985815e6460733 [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
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080021#include "ca-config.hpp"
Zhiyi Zhangad6cf932017-10-26 16:19:15 -070022
23#include "identity-management-fixture.hpp"
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080024#include <ndn-cxx/security/transform/base64-encode.hpp>
25#include <ndn-cxx/security/transform/buffer-source.hpp>
26#include <ndn-cxx/security/transform/stream-sink.hpp>
27
28namespace ndn {
29namespace ndncert {
30namespace tests {
31
32BOOST_FIXTURE_TEST_SUITE(TestCaConfig, IdentityManagementV2Fixture)
33
34BOOST_AUTO_TEST_CASE(ReadConfigFileWithFileAnchor)
35{
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080036 CaConfig config;
37 config.load("tests/unit-tests/ca.conf.test");
Zhiyi Zhang06d6ae92017-03-08 14:59:45 -080038
Zhiyi Zhangad6cf932017-10-26 16:19:15 -070039 int count = 0;
40 for (auto item : config.m_caItems) {
41 if (item.m_caName.toUri() == "/ndn") {
42 BOOST_CHECK_EQUAL(item.m_freshnessPeriod, time::seconds(720));
43 BOOST_CHECK_EQUAL(item.m_validityPeriod, time::days(360));
44 BOOST_CHECK_EQUAL(item.m_probe, "input email address");
45 BOOST_CHECK_EQUAL(item.m_caInfo, "ndn testbed ca");
46 BOOST_CHECK_EQUAL(item.m_targetedList,
47 "Use your email address (edu preferred) as input");
48 BOOST_CHECK_EQUAL(item.m_relatedCaList.size(), 2);
49
50 // check related ca
51 auto relatedCaA = item.m_relatedCaList.front();
52 BOOST_CHECK_EQUAL(relatedCaA.m_caName.toUri(), "/ndn/edu/arizona");
53 auto relatedCaB = item.m_relatedCaList.back();
54 BOOST_CHECK_EQUAL(relatedCaB.m_caName.toUri(), "/ndn/edu/memphis");
55
56 BOOST_CHECK_EQUAL(count, 0);
57 count++;
58 }
59 else if (item.m_caName.toUri() == "/ndn/edu/ucla/cs/zhiyi") {
60 BOOST_CHECK_EQUAL(item.m_probe, "");
61 BOOST_CHECK_EQUAL(item.m_freshnessPeriod, time::seconds(720));
62 BOOST_CHECK_EQUAL(item.m_validityPeriod, time::days(360));
63 BOOST_CHECK_EQUAL(item.m_supportedChallenges.size(), 1);
64
65 BOOST_CHECK_EQUAL(count, 1);
66 count++;
67 }
68 else if (item.m_caName.toUri() == "/ndn/site1") {
69 BOOST_CHECK(item.m_probe != "");
70 BOOST_CHECK_EQUAL(item.m_freshnessPeriod, time::seconds(720));
71 BOOST_CHECK_EQUAL(item.m_validityPeriod, time::days(360));
72 BOOST_CHECK_EQUAL(item.m_supportedChallenges.size(), 1);
73
74 BOOST_CHECK_EQUAL(count, 2);
75 }
76 }
Zhiyi Zhangdaf2fd72017-01-19 11:31:35 -080077}
78
79BOOST_AUTO_TEST_SUITE_END() // TestCaConfig
80
81} // namespace tests
82} // namespace ndncert
83} // namespace ndn