Skip to content

Commit

Permalink
tests: use typed name components
Browse files Browse the repository at this point in the history
refs #5044

Change-Id: I9ca85767056a7caeb81fcf1a833dfe450b61c5d2
  • Loading branch information
eric135 committed Mar 26, 2021
1 parent c196a16 commit b8adcdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ndns.conf.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ zones
{
; name / ; name of the zone
; KeyChain must have a identity with this name appended by <NDNS> at tail
; cert /KEY/dsk-123/CERT/%FD00 ; certificate to sign data
; cert /KEY/dsk-123/CERT/v=0 ; certificate to sign data
; omit cert to select the default certificate of above identity
}

; zone
; {
; name /ndn ; name of the zone, zone should not have the same name
; KeyChain must have a identity with this name appended by <NDNS> at tail
; cert /ndn/KEY/dsk-234/CERT/%FD00 ; certificate to sign data
; cert /ndn/KEY/dsk-234/CERT/v=0 ; certificate to sign data
; omit cert to select the default certificate of above identity
; }
}
15 changes: 6 additions & 9 deletions tests/unit/daemon/rrset-factory.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, Regents of the University of California.
* Copyright (c) 2014-2021, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
Expand Down Expand Up @@ -123,19 +123,18 @@ BOOST_AUTO_TEST_CASE(GenerateNsRrset)
BOOST_CHECK_EQUAL(*rrset.getZone(), zone);
BOOST_CHECK_EQUAL(rrset.getLabel(), label);
BOOST_CHECK_EQUAL(rrset.getType(), type);
BOOST_CHECK_EQUAL(rrset.getVersion().toVersion(), version);
BOOST_CHECK_EQUAL(rrset.getVersion(), Name::Component::fromVersion(version));
BOOST_CHECK_EQUAL(rrset.getTtl(), ttl);

const Name linkName("/rrest/factory/NDNS/nstest/NS/%FD%04%D2");
const auto linkName = Name("/rrest/factory/NDNS/nstest/NS").appendVersion(version);
Link link;
BOOST_CHECK_NO_THROW(link.wireDecode(rrset.getData()));

BOOST_CHECK_EQUAL(link.getName(), linkName);
BOOST_CHECK_EQUAL(link.getContentType(), NDNS_LINK);
BOOST_CHECK(link.getDelegationList() == delegations);

// BOOST_CHECK_EQUAL(Validator::verifySignature(link, m_cert.getPublicKeyInfo()), true);
security::verifySignature(link, m_cert);
BOOST_CHECK(security::verifySignature(link, m_cert));
}

BOOST_AUTO_TEST_CASE(GenerateTxtRrset)
Expand Down Expand Up @@ -167,7 +166,7 @@ BOOST_AUTO_TEST_CASE(GenerateTxtRrset)
BOOST_CHECK_EQUAL(*rrset.getZone(), zone);
BOOST_CHECK_EQUAL(rrset.getLabel(), label);
BOOST_CHECK_EQUAL(rrset.getType(), type);
BOOST_CHECK_EQUAL(rrset.getVersion().toVersion(), version);
BOOST_CHECK_EQUAL(rrset.getVersion(), Name::Component::fromVersion(version));
BOOST_CHECK_EQUAL(rrset.getTtl(), ttl);

Name dataName = m_zoneName.append(label::NDNS_ITERATIVE_QUERY)
Expand All @@ -183,9 +182,7 @@ BOOST_AUTO_TEST_CASE(GenerateTxtRrset)

BOOST_CHECK(txts == RrsetFactory::wireDecodeTxt(data.getContent()));

// shared_ptr<IdentityCertificate> cert = m_keyChain.getCertificate(m_certName);
// BOOST_CHECK(Validator::verifySignature(data, cert->getPublicKeyInfo()));
security::verifySignature(data, m_cert);
BOOST_CHECK(security::verifySignature(data, m_cert));
}

BOOST_AUTO_TEST_SUITE_END()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/daemon/rrset.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, Regents of the University of California.
* Copyright (c) 2014-2021, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
Expand Down Expand Up @@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE(Ostream)
boost::test_tools::output_test_stream os;
os << rrset;
BOOST_CHECK(os.is_equal("Rrset: Id=1 Zone=(Zone: Id=0 Name=/test)"
" Label=/www/1 Type=NS Version=%FD%01"));
" Label=/www/1 Type=NS Version=v=1"));
}

BOOST_AUTO_TEST_SUITE_END()
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/ndns-label.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, Regents of the University of California.
* Copyright (c) 2014-2021, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
Expand Down Expand Up @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(MatchInterest)
Name zone("/net/ndnsim");

Interest interest1("/net/ndnsim/NDNS/www/dsk-111/NS");
Interest interest2("/net/ndnsim/NDNS/www/dsk-111/NS/%FD%00");
Interest interest2(Name("/net/ndnsim/NDNS/www/dsk-111/NS").appendVersion(0));

MatchResult re;
BOOST_CHECK_EQUAL(matchName(interest1, zone, re), true);
Expand All @@ -46,15 +46,15 @@ BOOST_AUTO_TEST_CASE(MatchInterest)
BOOST_CHECK_EQUAL(matchName(interest2, zone, re), true);
BOOST_CHECK_EQUAL(re.rrLabel, Name("/www/dsk-111"));
BOOST_CHECK_EQUAL(re.rrType, name::Component("NS"));
BOOST_CHECK_EQUAL(re.version, name::Component::fromEscapedString("%FD%00"));
BOOST_CHECK_EQUAL(re.version, name::Component::fromVersion(0));
}

BOOST_AUTO_TEST_CASE(MatchData)
{
using namespace label;
Name zone("/net/ndnsim");

Data data1("/net/ndnsim/NDNS/www/dsk-111/NS/%FD%00");
Data data1(Name("/net/ndnsim/NDNS/www/dsk-111/NS").appendVersion(0));

MatchResult re;
BOOST_CHECK_EQUAL(matchName(data1, zone, re), true);
Expand Down

0 comments on commit b8adcdf

Please sign in to comment.