|
@@ -12,6 +12,8 @@
|
|
|
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
+#include "faked_nsec3.h"
|
|
|
+
|
|
|
#include <sstream>
|
|
|
#include <vector>
|
|
|
|
|
@@ -43,6 +45,7 @@ using namespace isc::dns;
|
|
|
using namespace isc::dns::rdata;
|
|
|
using namespace isc::datasrc;
|
|
|
using namespace isc::testutils;
|
|
|
+using namespace isc::datasrc::test;
|
|
|
|
|
|
namespace {
|
|
|
// Commonly used result codes (Who should write the prefix all the time)
|
|
@@ -296,72 +299,6 @@ textToRRset(const string& text_rrset, const RRClass& rrclass = RRClass::IN()) {
|
|
|
return (rrset);
|
|
|
}
|
|
|
|
|
|
-// Some faked NSEC3 hash values commonly used in tests and the faked NSEC3Hash
|
|
|
-// object.
|
|
|
-//
|
|
|
-// For apex (example.org)
|
|
|
-const char* const apex_hash = "0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM";
|
|
|
-const char* const apex_hash_lower = "0p9mhaveqvm6t7vbl5lop2u3t2rp3tom";
|
|
|
-// For ns1.example.org
|
|
|
-const char* const ns1_hash = "2T7B4G4VSA5SMI47K61MV5BV1A22BOJR";
|
|
|
-// For w.example.org
|
|
|
-const char* const w_hash = "01UDEMVP1J2F7EG6JEBPS17VP3N8I58H";
|
|
|
-// For x.y.w.example.org (lower-cased)
|
|
|
-const char* const xyw_hash = "2vptu5timamqttgl4luu9kg21e0aor3s";
|
|
|
-// For zzz.example.org.
|
|
|
-const char* const zzz_hash = "R53BQ7CC2UVMUBFU5OCMM6PERS9TK9EN";
|
|
|
-
|
|
|
-// A simple faked NSEC3 hash calculator with a dedicated creator for it.
|
|
|
-//
|
|
|
-// This is used in some NSEC3-related tests below.
|
|
|
-class TestNSEC3HashCreator : public NSEC3HashCreator {
|
|
|
- class TestNSEC3Hash : public NSEC3Hash {
|
|
|
- private:
|
|
|
- typedef map<Name, string> NSEC3HashMap;
|
|
|
- typedef NSEC3HashMap::value_type NSEC3HashPair;
|
|
|
- NSEC3HashMap map_;
|
|
|
- public:
|
|
|
- TestNSEC3Hash() {
|
|
|
- // Build pre-defined hash
|
|
|
- map_[Name("example.org")] = apex_hash;
|
|
|
- map_[Name("www.example.org")] = "2S9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM";
|
|
|
- map_[Name("xxx.example.org")] = "Q09MHAVEQVM6T7VBL5LOP2U3T2RP3TOM";
|
|
|
- map_[Name("yyy.example.org")] = "0A9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM";
|
|
|
- map_[Name("x.y.w.example.org")] =
|
|
|
- "2VPTU5TIMAMQTTGL4LUU9KG21E0AOR3S";
|
|
|
- map_[Name("y.w.example.org")] = "K8UDEMVP1J2F7EG6JEBPS17VP3N8I58H";
|
|
|
- map_[Name("w.example.org")] = w_hash;
|
|
|
- map_[Name("zzz.example.org")] = zzz_hash;
|
|
|
- map_[Name("smallest.example.org")] =
|
|
|
- "00000000000000000000000000000000";
|
|
|
- map_[Name("largest.example.org")] =
|
|
|
- "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU";
|
|
|
- }
|
|
|
- virtual string calculate(const Name& name) const {
|
|
|
- const NSEC3HashMap::const_iterator found = map_.find(name);
|
|
|
- if (found != map_.end()) {
|
|
|
- return (found->second);
|
|
|
- }
|
|
|
- isc_throw(isc::Unexpected, "unexpected name for NSEC3 test: "
|
|
|
- << name);
|
|
|
- }
|
|
|
- virtual bool match(const generic::NSEC3PARAM&) const {
|
|
|
- return (true);
|
|
|
- }
|
|
|
- virtual bool match(const generic::NSEC3&) const {
|
|
|
- return (true);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-public:
|
|
|
- virtual NSEC3Hash* create(const generic::NSEC3PARAM&) const {
|
|
|
- return (new TestNSEC3Hash);
|
|
|
- }
|
|
|
- virtual NSEC3Hash* create(const generic::NSEC3&) const {
|
|
|
- return (new TestNSEC3Hash);
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
/// \brief Test fixture for the InMemoryZoneFinder class
|
|
|
class InMemoryZoneFinderTest : public ::testing::Test {
|
|
|
// A straightforward pair of textual RR(set) and a RRsetPtr variable
|