Browse Source

[1176] Test it asks for DNSSEC data

While backends are allowed to pass DNSSEC data when not asked to, they
don't have to, so we need to ask for it. Test backend therefore doesn't
return the DNSSEC data when not asked to, to check it really asks.
Michal 'vorner' Vaner 13 years ago
parent
commit
38c8e9a9cc
1 changed files with 19 additions and 2 deletions
  1. 19 2
      src/bin/auth/tests/query_unittest.cc

+ 19 - 2
src/bin/auth/tests/query_unittest.cc

@@ -215,8 +215,25 @@ MockZoneFinder::find(const Name& name, const RRType& type,
         RRsetStore::const_iterator found_rrset =
             found_domain->second.find(type);
         if (found_rrset != found_domain->second.end()) {
-            // TODO: Drop whatever rrsig is there if options doesn't have the dnssec
-            return (FindResult(SUCCESS, found_rrset->second));
+            ConstRRsetPtr rrset;
+            // Strip whatever signature there is in case DNSSEC is not required
+            // Just to make sure the Query asks for it when it is needed
+            if (options & ZoneFinder::FIND_DNSSEC ||
+                !found_rrset->second->getRRsig()) {
+                rrset = found_rrset->second;
+            } else {
+                RRsetPtr noconst(new RRset(found_rrset->second->getName(),
+                                           found_rrset->second->getClass(),
+                                           found_rrset->second->getType(),
+                                           found_rrset->second->getTTL()));
+                for (RdataIteratorPtr
+                     i(found_rrset->second->getRdataIterator());
+                     !i->isLast(); i->next()) {
+                    noconst->addRdata(i->getCurrent());
+                }
+                rrset = noconst;
+            }
+            return (FindResult(SUCCESS, rrset));
         }
 
         // If not found but we have a target, fill it with all RRsets here