Prepare for testbed deployment: name assignment and redirection policy
Change-Id: I7f4da10b763f3891d33820e9c6f4c7cb0eea60ce
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index d4a733d..2a9640b 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -211,8 +211,8 @@
}
}
BOOST_CHECK_EQUAL(redirectionItems.size(), 2);
- BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[0].getPrefix(-1)), "/ndn/site1");
- BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[1].getPrefix(-1)), "/ndn/site1");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[0].getPrefix(-1)), "/ndn/edu/ucla");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[1].getPrefix(-1)), "/ndn/edu/ucla/cs/irl");
});
face.receive(interest);
advanceClocks(time::milliseconds(20), 60);
diff --git a/tests/unit-tests/challenge-email.t.cpp b/tests/unit-tests/challenge-email.t.cpp
index 92fb45b..1044660 100644
--- a/tests/unit-tests/challenge-email.t.cpp
+++ b/tests/unit-tests/challenge-email.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -93,30 +93,6 @@
std::remove("tmp.txt");
}
-BOOST_AUTO_TEST_CASE(OnChallengeRequestWithInvalidEmail)
-{
- auto identity = addIdentity(Name("/ndn/site1"));
- auto key = identity.getDefaultKey();
- auto cert = key.getDefaultCertificate();
- RequestId requestId = {{101}};
- ca::RequestState request;
- request.caPrefix = Name("/ndn/site1");
- request.requestId = requestId;
- request.requestType = RequestType::NEW;
- request.cert = cert;
-
- Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
- paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi@cs"));
-
- ChallengeEmail challenge;
- challenge.handleChallengeRequest(paramTLV, request);
-
- BOOST_CHECK_EQUAL(request.challengeType, "email");
- BOOST_CHECK_EQUAL(request.challengeState->challengeStatus, ChallengeEmail::INVALID_EMAIL);
- BOOST_CHECK_EQUAL(request.challengeState->remainingTries, 2);
-}
-
BOOST_AUTO_TEST_CASE(OnChallengeRequestWithCode)
{
auto identity = addIdentity(Name("/ndn/site1"));
diff --git a/tests/unit-tests/config-files/config-ca-5 b/tests/unit-tests/config-files/config-ca-5
index f867534..5d306aa 100644
--- a/tests/unit-tests/config-files/config-ca-5
+++ b/tests/unit-tests/config-files/config-ca-5
@@ -15,11 +15,15 @@
[
{
"ca-prefix": "/ndn/edu/ucla",
- "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
+ "certificate": "Bv0BNQcvCANuZG4IA2VkdQgEdWNsYQgDS0VZCAhtCJjCeE5aEwgEc2VsZjYIAAABf1ePw8kUCRgBAhkEADbugBVbMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwrhu4gD0eba7jbVqg1qfwuRj2JSqOfnwdiOlholvhCGpdXHpqg5o68ajADQPL9S555uvfabbFnPhv86X/Diy5hZQGwEDHCEHHwgDbmRuCANlZHUIBHVjbGEIA0tFWQgIbQiYwnhOWhP9AP0m/QD+DzE5NzAwMTAxVDAwMDAwMP0A/w8yMDQyMDIyOFQwMDUxNTMXSDBGAiEA11i8sGwf83hd+IQ2vve+Ax1O7zZeV8cG6FAXvXFQ0kACIQDAvqq0CRAYYJ/RFLW21wNGJf1Rf3OgFyGEKpLjnRkxaw==",
+ "policy-type": "param",
+ "policy-param": ""
},
{
- "ca-prefix": "/ndn/edu/irl",
- "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
+ "ca-prefix": "/ndn/edu/ucla/cs/irl",
+ "certificate": "Bv0BRQc4CANuZG4IA2VkdQgEdWNsYQgCY3MIA2lybAgDS0VZCAgWVGa5Tzd9WggEc2VsZjYIAAABf1eQ1LoUCRgBAhkEADbugBVbMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7hBKT9GapKRII3LT9q0kY5RXEE9Cu9B2Pg/E4Mndbqr3nbnMmm+SUAeIcrnTQa4c9ri8oCLkTesXsW0Tr8oTuhZZGwEDHCoHKAgDbmRuCANlZHUIBHVjbGEIAmNzCANpcmwIA0tFWQgIFlRmuU83fVr9AP0m/QD+DzE5NzAwMTAxVDAwMDAwMP0A/w8yMDQyMDIyOFQwMDUzMDMXRjBEAiA9Q/FjffFLasMfr7MIQY/KBBQScNKYyrEyphz4wOcQjAIgLf14XL8LaqqUyfBkwQXeCv3pipsnZw5BFhv8c5UCLVE=",
+ "policy-type": "param",
+ "policy-param": ""
}
],
"name-assignment":
diff --git a/tests/unit-tests/config-files/config-client-1 b/tests/unit-tests/config-files/config-client-1
index 20daad1..79d9519 100644
--- a/tests/unit-tests/config-files/config-client-1
+++ b/tests/unit-tests/config-files/config-client-1
@@ -10,11 +10,11 @@
[
{ "probe-parameter-key": "email" }
],
- "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
+ "certificate": "Bv0BKwcrCANuZG4IBXNpdGUxCANLRVkICEKyYEYHiBwyCARzZWxmNggAAAF/V5V9QhQJGAECGQQANu6AFVswWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARRaZbFLRSnL1fmj8X3hInCCPy4qe17QujMMYq8qe+CKqV+OjexhrUvpwRDImRZOgXLCjOTyYnW3wxlxskTz8Y3FkwbAQMcHQcbCANuZG4IBXNpdGUxCANLRVkICEKyYEYHiBwy/QD9Jv0A/g8xOTcwMDEwMVQwMDAwMDD9AP8PMjA0MjAyMjhUMDA1ODA5F0YwRAIgFtFP0WocLQCtbwMTnqNtnCDmu62EJyC4uuCZ4Q/Wb8UCIGHb3e4St78378py81GjEZd/2L/aGbE3vbYQIiNxIYPN"
},
{
"ca-prefix": "/ndn/edu/ucla/zhiyi",
- "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
+ "certificate": "Bv0BKwcrCANuZG4IBXNpdGUxCANLRVkICEKyYEYHiBwyCARzZWxmNggAAAF/V5V9QhQJGAECGQQANu6AFVswWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARRaZbFLRSnL1fmj8X3hInCCPy4qe17QujMMYq8qe+CKqV+OjexhrUvpwRDImRZOgXLCjOTyYnW3wxlxskTz8Y3FkwbAQMcHQcbCANuZG4IBXNpdGUxCANLRVkICEKyYEYHiBwy/QD9Jv0A/g8xOTcwMDEwMVQwMDAwMDD9AP8PMjA0MjAyMjhUMDA1ODA5F0YwRAIgFtFP0WocLQCtbwMTnqNtnCDmu62EJyC4uuCZ4Q/Wb8UCIGHb3e4St78378py81GjEZd/2L/aGbE3vbYQIiNxIYPN"
}
]
}
\ No newline at end of file
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index f7a8bc5..bb380f9 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -51,8 +51,8 @@
BOOST_CHECK_EQUAL(config.caProfile.supportedChallenges.front(), "pin");
config.load("tests/unit-tests/config-files/config-ca-5");
- BOOST_CHECK_EQUAL(config.redirection[0]->getName(),
- "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
+ BOOST_CHECK_EQUAL(config.redirection[0].first->getName(),
+ "/ndn/edu/ucla/KEY/m%08%98%C2xNZ%13/self/v=1646441513929");
BOOST_CHECK_EQUAL(config.nameAssignmentFuncs.size(), 3);
BOOST_CHECK_EQUAL(config.nameAssignmentFuncs[0]->m_nameFormat[0], "group");
BOOST_CHECK_EQUAL(config.nameAssignmentFuncs[0]->m_nameFormat[1], "email");
@@ -99,7 +99,7 @@
BOOST_CHECK_EQUAL(profile1.probeParameterKeys.size(), 1);
BOOST_CHECK_EQUAL(profile1.probeParameterKeys.front(), "email");
BOOST_CHECK_EQUAL(profile1.cert->getName(),
- "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
+ "/ndn/site1/KEY/B%B2%60F%07%88%1C2/self/v=1646441889090");
auto& profile2 = profileStorage.getKnownProfiles().back();
BOOST_CHECK_EQUAL(profile2.caPrefix, "/ndn/edu/ucla/zhiyi");
@@ -108,7 +108,7 @@
BOOST_CHECK(!profile2.maxSuffixLength);
BOOST_CHECK_EQUAL(profile2.probeParameterKeys.size(), 0);
BOOST_CHECK_EQUAL(profile2.cert->getName(),
- "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
+ "/ndn/site1/KEY/B%B2%60F%07%88%1C2/self/v=1646441889090");
}
BOOST_AUTO_TEST_CASE(ProfileStorageWithErrors)
diff --git a/tests/unit-tests/name-assignment.t.cpp b/tests/unit-tests/name-assignment.t.cpp
index 94b7fef..cecbc59 100644
--- a/tests/unit-tests/name-assignment.t.cpp
+++ b/tests/unit-tests/name-assignment.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -18,6 +18,7 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
+#include "name-assignment/assignment-email.hpp"
#include "name-assignment/assignment-random.hpp"
#include "name-assignment/assignment-param.hpp"
#include "name-assignment/assignment-hash.hpp"
@@ -49,6 +50,14 @@
BOOST_CHECK_EQUAL(*assignment.assignName(params).begin(), Name("/123/789"));
params.find("xyz")->second = "";
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 0);
+
+ AssignmentParam assignment2("/\"guest\"/email");
+ params.emplace("email", "1@1.com");
+ BOOST_CHECK_EQUAL(assignment2.assignName(params).size(), 1);
+ BOOST_CHECK_EQUAL(assignment2.assignName(params).begin()->toUri(), Name("/guest/1@1.com").toUri());
+
+ AssignmentParam assignment3("/\"/email");
+ BOOST_CHECK_EQUAL(assignment3.assignName(params).size(), 0);
}
BOOST_AUTO_TEST_CASE(NameAssignmentHash)
@@ -68,6 +77,20 @@
BOOST_CHECK_EQUAL(assignment.assignName(params).begin()->size(), 2);
}
+BOOST_AUTO_TEST_CASE(NameAssignmentEmail)
+{
+ AssignmentEmail assignment("/edu/ucla");
+ std::multimap<std::string, std::string> params;
+ BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 0);
+ params.emplace("email", "das@math.ucla.edu");
+ BOOST_CHECK_EQUAL(*assignment.assignName(params).begin(), Name("/math/das"));
+
+ params.clear();
+ params.emplace("email", "d/~.^as@6666=.9!");
+ BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 1);
+ BOOST_CHECK_EQUAL(*assignment.assignName(params).begin(), Name("/9!/6666%3D/d%2F~.%5Eas"));
+}
+
BOOST_AUTO_TEST_SUITE_END() // TestNameAssignment
} // namespace tests
diff --git a/tests/unit-tests/protocol-encoders.t.cpp b/tests/unit-tests/protocol-encoders.t.cpp
index bc1daa0..720c10e 100644
--- a/tests/unit-tests/protocol-encoders.t.cpp
+++ b/tests/unit-tests/protocol-encoders.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -79,7 +79,9 @@
std::vector<Name> names;
names.emplace_back("/ndn/1");
names.emplace_back("/ndn/2");
- auto b = probetlv::encodeDataContent(names, 2, config.redirection);
+ std::vector<Name> redirectionNames;
+ for (const auto& i : config.redirection) redirectionNames.push_back(i.first->getFullName());
+ auto b = probetlv::encodeDataContent(names, 2, redirectionNames);
std::vector<std::pair<Name, int>> retNames;
std::vector<Name> redirection;
probetlv::decodeDataContent(b, retNames, redirection);
@@ -94,7 +96,7 @@
auto it3 = redirection.begin();
auto it4 = config.redirection.begin();
for (; it3 != redirection.end() && it4 != config.redirection.end(); it3++, it4++) {
- BOOST_CHECK_EQUAL(*it3, (*it4)->getFullName());
+ BOOST_CHECK_EQUAL(*it3, it4->first->getFullName());
}
}
diff --git a/tests/unit-tests/redirection-policy.t.cpp b/tests/unit-tests/redirection-policy.t.cpp
new file mode 100644
index 0000000..d8d5203
--- /dev/null
+++ b/tests/unit-tests/redirection-policy.t.cpp
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2017-2022, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#include "redirection/redirection-policy.hpp"
+#include "redirection/redirection-param.hpp"
+#include "redirection/redirection-email.hpp"
+#include "test-common.hpp"
+
+namespace ndncert {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(TestRedirectionPolicy)
+
+BOOST_AUTO_TEST_CASE(RedirectionPolicyParam)
+{
+ RedirectionParam assignment("");
+ std::multimap<std::string, std::string> params;
+ BOOST_CHECK(assignment.isRedirecting(params));
+ params.emplace("abc", "123");
+ BOOST_CHECK(assignment.isRedirecting(params));
+
+ RedirectionParam assignment1("abc=123");
+ params.clear();
+ BOOST_CHECK(!assignment1.isRedirecting(params));
+ params.emplace("abc", "124");
+ BOOST_CHECK(!assignment1.isRedirecting(params));
+ params.emplace("abc", "123");
+ BOOST_CHECK(assignment1.isRedirecting(params));
+
+ RedirectionParam assignment2("abc=123&xyz=789");
+ params.clear();
+ BOOST_CHECK(!assignment2.isRedirecting(params));
+ params.emplace("abc", "123");
+ BOOST_CHECK(!assignment2.isRedirecting(params));
+ params.emplace("xyz", "788");
+ BOOST_CHECK(!assignment2.isRedirecting(params));
+ params.emplace("xyz", "789");
+ BOOST_CHECK(assignment2.isRedirecting(params));
+ params.emplace("abz", "789");
+ BOOST_CHECK(assignment2.isRedirecting(params));
+}
+
+BOOST_AUTO_TEST_CASE(RedirectionPolicyEmail)
+{
+ RedirectionEmail assignment("cs.ucla.edu");
+ std::multimap<std::string, std::string> params;
+ BOOST_CHECK(!assignment.isRedirecting(params));
+ params.emplace("email", "das@math.ucla.edu");
+ BOOST_CHECK(!assignment.isRedirecting(params));
+
+ params.clear();
+ params.emplace("email", "das@cs.ucla.edu");
+ BOOST_CHECK(assignment.isRedirecting(params));
+
+ params.clear();
+ params.emplace("email", "das@ucla.edu");
+ BOOST_CHECK(!assignment.isRedirecting(params));
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestNameAssignment
+
+} // namespace tests
+} // namespace ndncert
diff --git a/tests/unit-tests/requester.t.cpp b/tests/unit-tests/requester.t.cpp
index d2833c4..73da390 100644
--- a/tests/unit-tests/requester.t.cpp
+++ b/tests/unit-tests/requester.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -70,8 +70,8 @@
ca_profile.cert = std::make_shared<Certificate>(cert);
std::vector<Name> availableNames;
- availableNames.push_back(Name("/site1"));
- availableNames.push_back(Name("/site2"));
+ availableNames.emplace_back("/site1");
+ availableNames.emplace_back("/site2");
ndn::util::DummyClientFace face(io, m_keyChain, {true, true});
ca::CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-5", "ca-storage-memory");
@@ -79,7 +79,11 @@
Data reply;
reply.setName(Name("/site/CA/PROBE"));
reply.setFreshnessPeriod(time::seconds(100));
- reply.setContent(probetlv::encodeDataContent(availableNames, 3, ca.m_config.redirection));
+ {
+ std::vector<Name> redirectionNames;
+ for (const auto &i : ca.m_config.redirection) redirectionNames.push_back(i.first->getFullName());
+ reply.setContent(probetlv::encodeDataContent(availableNames, 3, redirectionNames));
+ }
m_keyChain.sign(reply, ndn::signingByIdentity(identity));
std::vector<std::pair<Name, int>> names;
@@ -94,8 +98,8 @@
BOOST_CHECK_EQUAL(names[1].second, 3);
BOOST_CHECK_EQUAL(redirects.size(), 2);
- BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirects[0].getPrefix(-1)), "/ndn/site1");
- BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirects[1].getPrefix(-1)), "/ndn/site1");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirects[0].getPrefix(-1)), "/ndn/edu/ucla");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirects[1].getPrefix(-1)), "/ndn/edu/ucla/cs/irl");
}
BOOST_AUTO_TEST_CASE(ErrorHandling)