Use PartialName for return from name assignment function
- to allow multi-component suffix
Change-Id: I6f02c6c7964f42cfdc2c5cc3b96391ca56196e10
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 4d055e3..322bbb5 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -186,7 +186,7 @@
// process PROBE requests: collect probe parameters
auto parameters = PROBE::decodeApplicationParameters(request.getApplicationParameters());
- std::vector<std::string> availableComponents;
+ std::vector<PartialName> availableComponents;
if (m_config.m_nameAssignmentFunc) {
try {
availableComponents = m_config.m_nameAssignmentFunc(parameters);
diff --git a/src/configuration.hpp b/src/configuration.hpp
index acd1b99..3d9ef9a 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -87,7 +87,7 @@
* @p vector, input, a list of parameter key-value pair used for name assignment.
* @return a vector containing the possible namespaces derived from the parameters.
*/
-using NameAssignmentFunc = function<std::vector<std::string>(const std::vector<std::tuple<std::string, std::string>>)>;
+using NameAssignmentFunc = function<std::vector<PartialName>(const std::vector<std::tuple<std::string, std::string>>)>;
/**
* @brief The function would be invoked whenever the certificate request status is updated.
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 062b502..7abb727 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -82,9 +82,9 @@
util::DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
- ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<std::string> {
- std::vector<std::string> result;
- result.push_back("example");
+ ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<PartialName> {
+ std::vector<PartialName> result;
+ result.push_back(Name("/example"));
return result;
});
advanceClocks(time::milliseconds(20), 60);
@@ -163,9 +163,9 @@
util::DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-5", "ca-storage-memory");
- ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<std::string> {
- std::vector<std::string> result;
- result.push_back("example");
+ ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<PartialName> {
+ std::vector<PartialName> result;
+ result.push_back(Name("/example"));
return result;
});
advanceClocks(time::milliseconds(20), 60);