diff --git a/configure.ac b/configure.ac index 95f1b6f189..f8a8d02def 100644 --- a/configure.ac +++ b/configure.ac @@ -1359,6 +1359,7 @@ AC_OUTPUT([doc/version.ent src/bin/auth/auth.spec.pre src/bin/auth/spec_config.h.pre src/bin/auth/tests/testdata/example.zone + src/bin/auth/tests/testdata/example-base.zone src/bin/auth/tests/testdata/example-nsec3.zone src/bin/dhcp4/spec_config.h.pre src/bin/dhcp6/spec_config.h.pre diff --git a/src/bin/auth/tests/Makefile.am b/src/bin/auth/tests/Makefile.am index 4d98bfdfa0..36a3c6826d 100644 --- a/src/bin/auth/tests/Makefile.am +++ b/src/bin/auth/tests/Makefile.am @@ -91,20 +91,26 @@ EXTRA_DIST = gen-query-testdata.py CLEANFILES += example_base_inc.cc example_nsec3_inc.cc -example_base_inc.cc: $(srcdir)/testdata/example-base.zone +example_base_inc.cc: $(srcdir)/testdata/example-base-inc.zone $(PYTHON) $(srcdir)/gen-query-testdata.py \ - $(srcdir)/testdata/example-base.zone example_base_inc.cc + $(srcdir)/testdata/example-base-inc.zone example_base_inc.cc example_nsec3_inc.cc: $(srcdir)/testdata/example-nsec3-inc.zone $(PYTHON) $(srcdir)/gen-query-testdata.py \ $(srcdir)/testdata/example-nsec3-inc.zone example_nsec3_inc.cc testdata/example-base.sqlite3: testdata/example-base.zone + $(top_srcdir)/install-sh -c \ + $(srcdir)/testdata/example-common-inc-template.zone \ + testdata/example-common-inc.zone $(SHELL) $(top_builddir)/src/bin/loadzone/run_loadzone.sh \ -c "{\"database_file\": \"$(builddir)/testdata/example-base.sqlite3\"}" \ example.com testdata/example-base.zone testdata/example-nsec3.sqlite3: testdata/example-nsec3.zone + $(top_srcdir)/install-sh -c \ + $(srcdir)/testdata/example-common-inc-template.zone \ + testdata/example-common-inc.zone $(SHELL) $(top_builddir)/src/bin/loadzone/run_loadzone.sh \ -c "{\"database_file\": \"$(builddir)/testdata/example-nsec3.sqlite3\"}" \ example.com testdata/example-nsec3.zone diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc index 3b26fe2162..ed61611ad2 100644 --- a/src/bin/auth/tests/query_unittest.cc +++ b/src/bin/auth/tests/query_unittest.cc @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -831,7 +832,10 @@ protected: "glue.delegation.example.com. 3600 IN RRSIG " + getCommonRRSIGText("AAAA") + "\n" + "noglue.example.com. 3600 IN RRSIG " + - getCommonRRSIGText("A")) + getCommonRRSIGText("A")), + base_zone_file(TEST_OWN_DATA_BUILDDIR "/example-base.zone"), + nsec3_zone_file(TEST_OWN_DATA_BUILDDIR "/example-nsec3.zone"), + common_zone_file(TEST_OWN_DATA_BUILDDIR "/example-common-inc.zone") { // Set up the faked hash calculator. setNSEC3HashCreator(&nsec3hash_creator_); @@ -844,10 +848,16 @@ protected: } virtual void SetUp() { - // Configure data source clients after setting NSEC3 hash in case + // clear the commonly included zone file. + ASSERT_EQ(0, std::system(INSTALL_PROG " -c " TEST_OWN_DATA_DIR + "/example-common-inc-template.zone " + TEST_OWN_DATA_BUILDDIR + "/example-common-inc.zone")); + + // We create data source clients here, not in the constructor, so this + // doesn't happen for derived test class. This also ensures the + // data source clients are configured after setting NSEC3 hash in case // there's dependency. - // We do this here, not in the constructor, so this doesn't happen - // for derived test class. list_ = createDataSrcClientList(GetParam(), memory_client); } @@ -861,19 +871,10 @@ protected: switch (GetParam()) { case MOCK: mock_finder->setNSEC3Flag(true); - addRRsets(*list_, rrsets_to_add); + addRRsets(rrsets_to_add, *list_, ""); break; case INMEMORY: - addRRsets(*list_, rrsets_to_add); - new_list.reset(new ConfigurableClientList(RRClass::IN())); - new_list->configure(isc::data::Element::fromJSON( - "[{\"type\": \"MasterFiles\"," - " \"cache-enable\": true, " - " \"params\": {\"example.com\": \"" + - string(TEST_OWN_DATA_BUILDDIR - "/example-nsec3.zone") + - "\"}}]"), true); - list_ = new_list; + addRRsets(rrsets_to_add, *list_, nsec3_zone_file); break; case SQLITE3: ASSERT_EQ(0, std::system(INSTALL_PROG " -c " TEST_OWN_DATA_BUILDDIR @@ -889,15 +890,21 @@ protected: string(TEST_OWN_DATA_BUILDDIR "/example-nsec3.sqlite3.copied") + "\"}}]"), true); - addRRsets(*new_list, rrsets_to_add); + addRRsets(rrsets_to_add, *new_list, ""); list_ = new_list; break; } } // A helper to add some RRsets to the test zone in the middle of a test - // case. - void addRRsets(ClientList& list, const vector& rrsets_to_add) { + // case. The detailed behavior is quite different depending on the + // data source type, and not all parameters are used in all cases. + void addRRsets(const vector& rrsets_to_add, ClientList& list, + const string& zone_file) + { + boost::shared_ptr new_list; + ofstream ofs; + switch (GetParam()) { case MOCK: // directly add them to the mock data source; ignore the passed @@ -909,8 +916,25 @@ protected: } break; case INMEMORY: - // dynamic addition is not yet supported for in-memory - ASSERT_TRUE(rrsets_to_add.empty()); + // dump the RRsets to be added to the placeholder of commonly + // included zone file (removing any existing contents) and do + // full reconfiguration. + ofs.open(common_zone_file.c_str(), ios_base::trunc); + for (vector::const_iterator it = rrsets_to_add.begin(); + it != rrsets_to_add.end(); + ++it) { + ofs << *it << "\n"; + ofs << createRRSIG(textToRRset(*it))->toText() << "\n"; + } + ofs.close(); + + new_list.reset(new ConfigurableClientList(RRClass::IN())); + new_list->configure(isc::data::Element::fromJSON( + "[{\"type\": \"MasterFiles\"," + " \"cache-enable\": true, " + " \"params\": {\"example.com\": \"" + + zone_file + "\"}}]"), true); + list_ = new_list; break; case SQLITE3: const Name origin("example.com"); @@ -960,7 +984,10 @@ protected: Query query; TestNSEC3Hash nsec3_hash_; vector rrsets_to_add_; + const string base_zone_file; private: + const string nsec3_zone_file; + const string common_zone_file; const TestNSEC3HashCreator nsec3hash_creator_; }; @@ -1228,12 +1255,6 @@ TEST_P(QueryTest, secureUnsignedDelegation) { } TEST_P(QueryTest, secureUnsignedDelegationWithNSEC3) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - // Similar to the previous case, but the zone is signed with NSEC3, // and this delegation is NOT an optout. rrsets_to_add_.push_back(unsigned_delegation_nsec3_txt); @@ -1550,12 +1571,6 @@ TEST_P(QueryTest, CNAMEwildNSEC) { } TEST_P(QueryTest, wildcardNSEC3) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - // Similar to wildcardNSEC, but the zone is signed with NSEC3. // The next closer is y.wild.example.com, the covering NSEC3 for it // is (in our setup) the NSEC3 for the apex. @@ -1584,12 +1599,6 @@ TEST_P(QueryTest, wildcardNSEC3) { } TEST_P(QueryTest, CNAMEwildNSEC3) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - // Similar to CNAMEwildNSEC, but with NSEC3. // The next closer is qname itself, the covering NSEC3 for it // is (in our setup) the NSEC3 for the www.example.com. @@ -1711,12 +1720,6 @@ TEST_P(QueryTest, wildcardNxrrsetWithNSEC) { } TEST_P(QueryTest, wildcardNxrrsetWithNSEC3) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - // Similar to the previous case, but providing NSEC3 proofs according to // RFC5155 Section 7.2.5. @@ -2312,14 +2315,8 @@ TEST_P(QueryTest, dsBelowDelegation) { // exists in the child zone. The Query module should still return SOA. // In our implementation NSEC/NSEC3 isn't attached in this case. TEST_P(QueryTest, dsBelowDelegationWithDS) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - rrsets_to_add_.push_back(zone_ds_txt); - addRRsets(*list_, rrsets_to_add_); + addRRsets(rrsets_to_add_, *list_, base_zone_file); EXPECT_NO_THROW(query.process(*list_, Name("example.com"), RRType::DS(), response, true)); @@ -2452,12 +2449,6 @@ TEST_F(QueryTestForMockOnly, nxrrsetMissingNSEC3) { } TEST_P(QueryTest, nxrrsetWithNSEC3_ds_exact) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - rrsets_to_add_.push_back(unsigned_delegation_nsec3_txt); enableNSEC3(rrsets_to_add_); @@ -2477,12 +2468,6 @@ TEST_P(QueryTest, nxrrsetWithNSEC3_ds_exact) { } TEST_P(QueryTest, nxrrsetWithNSEC3_ds_no_exact) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - rrsets_to_add_.push_back(unsigned_delegation_nsec3_txt); enableNSEC3(rrsets_to_add_); @@ -2509,12 +2494,6 @@ TEST_P(QueryTest, nxrrsetWithNSEC3_ds_no_exact) { } TEST_P(QueryTest, nxdomainWithNSEC3Proof) { - // This test requires incremental update to the zone; unavailable for - // in-memory. - if (GetParam() == INMEMORY) { - return; - } - // Name Error (NXDOMAIN) case with NSEC3 proof per RFC5155 Section 7.2.2. // This will be the covering NSEC3 for the next closer diff --git a/src/bin/auth/tests/testdata/Makefile.am b/src/bin/auth/tests/testdata/Makefile.am index 124a530820..fa4ffdf2b6 100644 --- a/src/bin/auth/tests/testdata/Makefile.am +++ b/src/bin/auth/tests/testdata/Makefile.am @@ -1,5 +1,6 @@ CLEANFILES = *.wire *.copied CLEANFILES += example-base.sqlite3 example-nsec3.sqlite3 +CLEANFILES += example-common-inc.zone BUILT_SOURCES = badExampleQuery_fromWire.wire examplequery_fromWire.wire BUILT_SOURCES += iqueryresponse_fromWire.wire multiquestion_fromWire.wire @@ -25,7 +26,7 @@ EXTRA_DIST += example.com EXTRA_DIST += example.zone EXTRA_DIST += example.sqlite3 -EXTRA_DIST += example-base.zone example-nsec3-inc.zone +EXTRA_DIST += example-base-inc.zone example-nsec3-inc.zone .spec.wire: $(PYTHON) $(top_builddir)/src/lib/util/python/gen_wiredata.py -o $@ $< diff --git a/src/bin/auth/tests/testdata/example-base.zone b/src/bin/auth/tests/testdata/example-base-inc.zone similarity index 100% rename from src/bin/auth/tests/testdata/example-base.zone rename to src/bin/auth/tests/testdata/example-base-inc.zone diff --git a/src/bin/auth/tests/testdata/example-base.zone.in b/src/bin/auth/tests/testdata/example-base.zone.in new file mode 100644 index 0000000000..63d2af0665 --- /dev/null +++ b/src/bin/auth/tests/testdata/example-base.zone.in @@ -0,0 +1,7 @@ +;; +;; This is a complete (but crafted and somewhat broken) zone file used +;; in query tests. +;; + +$INCLUDE @abs_srcdir@/example-base-inc.zone +$INCLUDE @abs_builddir@/example-common-inc.zone diff --git a/src/bin/auth/tests/testdata/example-common-inc-template.zone b/src/bin/auth/tests/testdata/example-common-inc-template.zone new file mode 100644 index 0000000000..d7259bf0cc --- /dev/null +++ b/src/bin/auth/tests/testdata/example-common-inc-template.zone @@ -0,0 +1,5 @@ +;; +;; This is an initial template of part of test zone file used in query test +;; and expected to be included from other zone files. This is +;; intentionally kept empty. +;; diff --git a/src/bin/auth/tests/testdata/example-nsec3.zone.in b/src/bin/auth/tests/testdata/example-nsec3.zone.in index 616c2d6209..aaf3d6a091 100644 --- a/src/bin/auth/tests/testdata/example-nsec3.zone.in +++ b/src/bin/auth/tests/testdata/example-nsec3.zone.in @@ -3,5 +3,6 @@ ;; in query tests including NSEC3 records, making the zone is "NSEC3 signed". ;; -$INCLUDE @abs_builddir@/example-base.zone -$INCLUDE @abs_builddir@/example-nsec3-inc.zone +$INCLUDE @abs_srcdir@/example-base-inc.zone +$INCLUDE @abs_srcdir@/example-nsec3-inc.zone +$INCLUDE @abs_builddir@/example-common-inc.zone