validator-config: use cert file name for groupId
refs #5136
Change-Id: I0a737593e11eddcd372c3c6d3cb742dd2a0a9cab
diff --git a/ndn-cxx/security/validation-policy-config.cpp b/ndn-cxx/security/validation-policy-config.cpp
index ba7d3b8..2df7f69 100644
--- a/ndn-cxx/security/validation-policy-config.cpp
+++ b/ndn-cxx/security/validation-policy-config.cpp
@@ -135,7 +135,7 @@
if (propertyIt != configSection.end())
NDN_THROW(Error("Expecting end of <trust-anchor>"));
- m_validator->loadAnchor(filename, absolute(file, path(filename).parent_path()).string(),
+ m_validator->loadAnchor(file, absolute(file, path(filename).parent_path()).string(),
refresh, false);
}
else if (boost::iequals(type, "base64")) {
diff --git a/tests/unit/security/validation-policy-config.t.cpp b/tests/unit/security/validation-policy-config.t.cpp
index 38c5986..0ee5172 100644
--- a/tests/unit/security/validation-policy-config.t.cpp
+++ b/tests/unit/security/validation-policy-config.t.cpp
@@ -178,6 +178,40 @@
};
template<typename PacketType>
+class LoadFileWithMultipleFileAnchors : public ValidationPolicyConfigFixture<PacketType>
+{
+public:
+ LoadFileWithMultipleFileAnchors()
+ {
+ std::string configFile = (this->path / "config.conf").string();
+ {
+ std::ofstream config(configFile);
+ config << this->baseConfig << R"CONF(
+ trust-anchor
+ {
+ type file
+ file-name "identity.ndncert"
+ }
+ trust-anchor
+ {
+ type file
+ file-name "trust-anchor.ndncert"
+ }
+ )CONF";
+ }
+
+ this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
+
+ BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
+
+ this->policy.load(configFile);
+
+ BOOST_CHECK_EQUAL(this->policy.m_isConfigured, true);
+ BOOST_CHECK_EQUAL(this->policy.m_shouldBypass, false);
+ }
+};
+
+template<typename PacketType>
class LoadSectionWithFileAnchor : public ValidationPolicyConfigFixture<PacketType>
{
public:
@@ -315,6 +349,7 @@
using DataPolicies = boost::mpl::vector<LoadStringWithFileAnchor<Data>,
LoadFileWithFileAnchor<Data>,
+ LoadFileWithMultipleFileAnchors<Data>,
LoadSectionWithFileAnchor<Data>,
LoadStringWithBase64Anchor<Data>,
LoadStringWithDirAnchor<Data>,
@@ -325,6 +360,7 @@
using InterestPolicies = boost::mpl::vector<LoadStringWithFileAnchor<Interest>,
LoadFileWithFileAnchor<Interest>,
+ LoadFileWithMultipleFileAnchors<Interest>,
LoadSectionWithFileAnchor<Interest>,
LoadStringWithBase64Anchor<Interest>,
LoadStringWithDirAnchor<Interest>,