security: rename NO_SIGNATURE error code to MALFORMED_SIGNATURE
And move the documentation for all validation error codes to doxygen
Change-Id: Ibf4b507e3a544f2978192fbfad20cd7dc486818f
diff --git a/tests/unit/security/validation-error.t.cpp b/tests/unit/security/validation-error.t.cpp
index 6c1b5f7..c4a1a08 100644
--- a/tests/unit/security/validation-error.t.cpp
+++ b/tests/unit/security/validation-error.t.cpp
@@ -22,6 +22,7 @@
#include "ndn-cxx/security/validation-error.hpp"
#include "tests/boost-test.hpp"
+
#include <boost/lexical_cast.hpp>
namespace ndn {
@@ -37,17 +38,22 @@
ValidationError e1{ValidationError::INVALID_SIGNATURE};
BOOST_CHECK_EQUAL(e1.getCode(), 1);
BOOST_CHECK_EQUAL(e1.getInfo(), "");
- BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(e1), "Invalid signature");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(e1), "Signature verification failed");
- ValidationError e2{ValidationError::NO_SIGNATURE, "message"};
+ ValidationError e2{ValidationError::MALFORMED_SIGNATURE, "message"};
BOOST_CHECK_EQUAL(e2.getCode(), 2);
BOOST_CHECK_EQUAL(e2.getInfo(), "message");
- BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(e2), "Missing signature (message)");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(e2), "Missing or malformed signature (message)");
ValidationError e3{65535, "other message"};
BOOST_CHECK_EQUAL(e3.getCode(), 65535);
BOOST_CHECK_EQUAL(e3.getInfo(), "other message");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(e3), "Custom error code 65535 (other message)");
+
+ ValidationError e4{200};
+ BOOST_CHECK_EQUAL(e4.getCode(), 200);
+ BOOST_CHECK_EQUAL(e4.getInfo(), "");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(e4), "Unknown error code 200");
}
BOOST_AUTO_TEST_SUITE_END() // TestValidationError
diff --git a/tests/unit/security/validation-policy-command-interest.t.cpp b/tests/unit/security/validation-policy-command-interest.t.cpp
index d6fd74f..604c60d 100644
--- a/tests/unit/security/validation-policy-command-interest.t.cpp
+++ b/tests/unit/security/validation-policy-command-interest.t.cpp
@@ -165,7 +165,7 @@
auto i1 = Interest("/short");
BOOST_TEST_REQUIRE(i1.getName().size() < signed_interest::MIN_SIZE);
VALIDATE_FAILURE(i1, "Should fail (not signed / name too short)");
- BOOST_TEST(lastError.getCode() == ValidationError::NO_SIGNATURE);
+ BOOST_TEST(lastError.getCode() == ValidationError::MALFORMED_SIGNATURE);
}
BOOST_AUTO_TEST_CASE(BadSigInfo)
@@ -174,7 +174,7 @@
setNameComponent(i1, command_interest::POS_SIG_INFO, "not-SignatureInfo");
BOOST_TEST_REQUIRE(i1.getName().size() >= command_interest::MIN_SIZE);
VALIDATE_FAILURE(i1, "Should fail (signature info is missing)");
- BOOST_TEST(lastError.getCode() == ValidationError::NO_SIGNATURE);
+ BOOST_TEST(lastError.getCode() == ValidationError::MALFORMED_SIGNATURE);
}
BOOST_AUTO_TEST_CASE(BadTimestampV02)
diff --git a/tests/unit/security/validation-policy-simple-hierarchy.t.cpp b/tests/unit/security/validation-policy-simple-hierarchy.t.cpp
index 38ab30c..788a7c9 100644
--- a/tests/unit/security/validation-policy-simple-hierarchy.t.cpp
+++ b/tests/unit/security/validation-policy-simple-hierarchy.t.cpp
@@ -43,7 +43,7 @@
auto packet = Packet::makePacket(name);
VALIDATE_FAILURE(packet, "Unsigned");
- BOOST_TEST((lastError.getCode() == ValidationError::NO_SIGNATURE || // Interest
+ BOOST_TEST((lastError.getCode() == ValidationError::MALFORMED_SIGNATURE || // Interest
lastError.getCode() == ValidationError::INVALID_KEY_LOCATOR)); // Data
packet = Packet::makePacket(name);
diff --git a/tests/unit/security/validator.t.cpp b/tests/unit/security/validator.t.cpp
index 842f2f5..d1b746b 100644
--- a/tests/unit/security/validator.t.cpp
+++ b/tests/unit/security/validator.t.cpp
@@ -64,7 +64,7 @@
BOOST_REQUIRE_NO_THROW(interest.getSignatureValue());
VALIDATE_FAILURE(interest, "InterestSignatureInfo decoding should fail");
- BOOST_TEST(lastError.getCode() == ValidationError::NO_SIGNATURE);
+ BOOST_TEST(lastError.getCode() == ValidationError::MALFORMED_SIGNATURE);
BOOST_TEST(face.sentInterests.size() == 0);
}
@@ -259,7 +259,7 @@
Data data("/Security/ValidatorFixture/Sub1/Sub2/Data");
VALIDATE_FAILURE(interest, "Unsigned");
- BOOST_TEST(lastError.getCode() == ValidationError::NO_SIGNATURE);
+ BOOST_TEST(lastError.getCode() == ValidationError::MALFORMED_SIGNATURE);
VALIDATE_SUCCESS(data, "Policy bypasses validation for all data");
BOOST_TEST(face.sentInterests.size() == 0);
face.sentInterests.clear();