blob: 570aab153dc66b4a99b4f7878fd1f314c6bbbe5e [file] [log] [blame]
Zhiyi Zhang65ba9322017-01-19 14:15:03 -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 "boost-test.hpp"
22#include "challenge-module.hpp"
23
24namespace ndn {
25namespace ndncert {
26namespace tests {
27
28BOOST_AUTO_TEST_SUITE(TestChallengeModule)
29
30BOOST_AUTO_TEST_CASE(GetJsonFromNameComponent)
31{
32 JsonSection json;
33 json.put("test", "123");
34 std::stringstream ss;
35 boost::property_tree::write_json(ss, json);
36 std::string jsonString = ss.str();
37 Block jsonContent = makeStringBlock(ndn::tlv::NameComponent, ss.str());
38
39 Name name("ndn");
40 name.append(jsonContent);
41 BOOST_CHECK(ChallengeModule::getJsonFromNameComponent(name, 1) == json);
42}
43
44BOOST_AUTO_TEST_CASE(GenDownloadName)
45{
46 Name interestName = ChallengeModule::genDownloadName(Name("ca"), "123");
47 BOOST_CHECK_EQUAL(interestName.getSubName(0, 1), Name("ca"));
48 BOOST_CHECK_EQUAL(interestName.getSubName(1, 1), Name("_DOWNLOAD"));
49
50 JsonSection json;
51 json.put(JSON_REQUEST_ID, "123");
52 BOOST_CHECK(ChallengeModule::getJsonFromNameComponent(interestName, 2) == json);
53}
54
55BOOST_AUTO_TEST_SUITE_END()
56
57} // namespace tests
58} // namespace ndncert
59} // namespace ndn