Parcourir la 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 il y a 13 ans
Parent
commit
38c8e9a9cc
1 fichiers modifiés avec 19 ajouts et 2 suppressions
  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