security: support new signed Interest format in Validator

refs #4804

Change-Id: I0391709dc1486c8156c03cf8e9d94e6cfbe30303
diff --git a/tests/unit/security/validator-config/rule.t.cpp b/tests/unit/security/validator-config/rule.t.cpp
index dbc81bf..75eb6dc 100644
--- a/tests/unit/security/validator-config/rule.t.cpp
+++ b/tests/unit/security/validator-config/rule.t.cpp
@@ -39,87 +39,80 @@
 BOOST_AUTO_TEST_SUITE(Security)
 BOOST_AUTO_TEST_SUITE(ValidatorConfig)
 
-template<uint32_t PktType>
+template<class Packet>
 class RuleFixture : public IdentityManagementFixture
 {
 public:
   RuleFixture()
-    : rule(ruleId, PktType)
-    , pktName("/foo/bar")
+    : rule(ruleId, Packet::getType())
+    , pktName(Packet::makeName("/foo/bar", m_keyChain))
+    , state(Packet::makeState())
   {
-    if (PktType == tlv::Interest) {
-      pktName = Name("/foo/bar/SigInfo/SigValue");
-    }
   }
 
 public:
   const std::string ruleId = "rule-id";
   Rule rule;
   Name pktName;
+  shared_ptr<ValidationState> state;
 };
 
-using PktTypes = boost::mpl::vector_c<uint32_t, tlv::Data, tlv::Interest>;
+using PktTypes = boost::mpl::vector<DataPkt, InterestV02Pkt, InterestV03Pkt>;
 
 BOOST_AUTO_TEST_SUITE(TestRule)
 
-BOOST_FIXTURE_TEST_CASE(Errors, RuleFixture<tlv::Data>)
+BOOST_FIXTURE_TEST_CASE(Errors, RuleFixture<DataPkt>)
 {
-  BOOST_CHECK_THROW(rule.match(tlv::Interest, this->pktName), Error);
-
-  auto state = make_shared<DummyValidationState>();
+  BOOST_CHECK_THROW(rule.match(tlv::Interest, this->pktName, state), Error);
   BOOST_CHECK_THROW(rule.check(tlv::Interest, this->pktName, "/foo/bar", state), Error);
 }
 
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Constructor, PktType, PktTypes, RuleFixture<PktType::value>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(Constructor, PktType, PktTypes, RuleFixture<PktType>)
 {
   BOOST_CHECK_EQUAL(this->rule.getId(), this->ruleId);
-  BOOST_CHECK_EQUAL(this->rule.getPktType(), PktType::value);
+  BOOST_CHECK_EQUAL(this->rule.getPktType(), PktType::getType());
 }
 
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(EmptyRule, PktType, PktTypes, RuleFixture<PktType::value>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(EmptyRule, PktType, PktTypes, RuleFixture<PktType>)
 {
-  BOOST_CHECK_EQUAL(this->rule.match(PktType::value, this->pktName), true);
-
-  auto state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(this->rule.check(PktType::value, this->pktName, "/foo/bar", state), false);
+  BOOST_CHECK_EQUAL(this->rule.match(PktType::getType(), this->pktName, this->state), true);
+  BOOST_CHECK_EQUAL(this->rule.check(PktType::getType(), this->pktName, "/foo/bar", this->state), false);
 }
 
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Filters, PktType, PktTypes, RuleFixture<PktType::value>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(Filters, PktType, PktTypes, RuleFixture<PktType>)
 {
   this->rule.addFilter(make_unique<RegexNameFilter>(Regex("^<foo><bar>$")));
 
-  BOOST_CHECK_EQUAL(this->rule.match(PktType::value, this->pktName), true);
-  BOOST_CHECK_EQUAL(this->rule.match(PktType::value, "/not" + this->pktName.toUri()), false);
+  BOOST_CHECK_EQUAL(this->rule.match(PktType::getType(), this->pktName, this->state), true);
+  BOOST_CHECK_EQUAL(this->rule.match(PktType::getType(), "/not" + this->pktName.toUri(), this->state), false);
 
   this->rule.addFilter(make_unique<RegexNameFilter>(Regex("^<not><foo><bar>$")));
 
-  BOOST_CHECK_EQUAL(this->rule.match(PktType::value, this->pktName), true);
-  BOOST_CHECK_EQUAL(this->rule.match(PktType::value, "/not" + this->pktName.toUri()), true);
+  BOOST_CHECK_EQUAL(this->rule.match(PktType::getType(), this->pktName, this->state), true);
+  BOOST_CHECK_EQUAL(this->rule.match(PktType::getType(), "/not" + this->pktName.toUri(), this->state), true);
 
-  auto state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(this->rule.check(PktType::value, this->pktName, "/foo/bar", state), false);
+  BOOST_CHECK_EQUAL(this->rule.check(PktType::getType(), this->pktName, "/foo/bar", this->state), false);
 }
 
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Checkers, PktType, PktTypes, RuleFixture<PktType::value>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(Checkers, PktType, PktTypes, RuleFixture<PktType>)
 {
   this->rule.addChecker(make_unique<HyperRelationChecker>("^(<>+)$", "\\1",
                                                         "^<not>?(<>+)$", "\\1",
                                                         NameRelation::EQUAL));
 
-  auto state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(this->rule.check(PktType::value, this->pktName, "/foo/bar", state), true);
+  BOOST_CHECK_EQUAL(this->rule.check(PktType::getType(), this->pktName, "/foo/bar", this->state), true);
 
-  state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(this->rule.check(PktType::value, this->pktName, "/not/foo/bar", state), true);
+  this->state = PktType::makeState(); // reset state
+  BOOST_CHECK_EQUAL(this->rule.check(PktType::getType(), this->pktName, "/not/foo/bar", this->state), true);
 
   this->rule.addChecker(make_unique<HyperRelationChecker>("^(<>+)$", "\\1",
                                                         "^(<>+)$", "\\1",
                                                         NameRelation::EQUAL));
-  state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(this->rule.check(PktType::value, this->pktName, "/foo/bar", state), true);
+  this->state = PktType::makeState(); // reset state
+  BOOST_CHECK_EQUAL(this->rule.check(PktType::getType(), this->pktName, "/foo/bar", this->state), true);
 
-  state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(this->rule.check(PktType::value, this->pktName, "/not/foo/bar", state), false);
+  this->state = PktType::makeState(); // reset state
+  BOOST_CHECK_EQUAL(this->rule.check(PktType::getType(), this->pktName, "/not/foo/bar", this->state), false);
 }
 
 BOOST_AUTO_TEST_SUITE(Create)
@@ -153,11 +146,11 @@
   BOOST_CHECK_THROW(Rule::create(makeSection(config), "test-config"), Error);
 }
 
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(FilterAndChecker, PktType, PktTypes, RuleFixture<PktType::value>)
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(FilterAndChecker, PktType, PktTypes, RuleFixture<PktType>)
 {
   std::string config = R"CONF(
       id rule-id
-      for )CONF" + (PktType::value == tlv::Data ? "data"s : "interest"s) + R"CONF(
+      for )CONF" + (PktType::getType() == tlv::Data ? "data"s : "interest"s) + R"CONF(
       filter
       {
         type name
@@ -183,14 +176,13 @@
     )CONF";
   auto rule = Rule::create(makeSection(config), "test-config");
 
-  BOOST_CHECK_EQUAL(rule->match(PktType::value, this->pktName), true);
-  BOOST_CHECK_EQUAL(rule->match(PktType::value, "/not" + this->pktName.toUri()), false);
+  BOOST_CHECK_EQUAL(rule->match(PktType::getType(), this->pktName, this->state), true);
+  BOOST_CHECK_EQUAL(rule->match(PktType::getType(), "/not" + this->pktName.toUri(), this->state), false);
 
-  auto state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(rule->check(PktType::value, this->pktName, "/foo/bar", state), true);
+  BOOST_CHECK_EQUAL(rule->check(PktType::getType(), this->pktName, "/foo/bar", this->state), true);
 
-  state = make_shared<DummyValidationState>();
-  BOOST_CHECK_EQUAL(rule->check(PktType::value, this->pktName, "/not/foo/bar", state), false);
+  this->state = PktType::makeState(); // reset state
+  BOOST_CHECK_EQUAL(rule->check(PktType::getType(), this->pktName, "/not/foo/bar", this->state), false);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // Create