sqlite3_unittest.cc 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. // $Id$
  15. #include <stdint.h>
  16. #include <algorithm>
  17. #include <string>
  18. #include <vector>
  19. #include <sqlite3.h>
  20. #include <gtest/gtest.h>
  21. #include <dns/name.h>
  22. #include <dns/message.h>
  23. #include <dns/rdata.h>
  24. #include <dns/rrclass.h>
  25. #include <dns/rrtype.h>
  26. #include <dns/rdataclass.h>
  27. #include <dns/rrsetlist.h>
  28. #include <cc/data.h>
  29. #include <datasrc/query.h>
  30. #include <datasrc/data_source.h>
  31. #include <datasrc/sqlite3_datasrc.h>
  32. using namespace std;
  33. using namespace isc::dns;
  34. using namespace isc::dns::rdata;
  35. using namespace isc::datasrc;
  36. using namespace isc::data;
  37. namespace {
  38. ElementPtr SQLITE_DBFILE_EXAMPLE = Element::createFromString(
  39. "{ \"database_file\": \"" TEST_DATA_DIR "/test.sqlite3\"}");
  40. ElementPtr SQLITE_DBFILE_EXAMPLE2 = Element::createFromString(
  41. "{ \"database_file\": \"" TEST_DATA_DIR "/example2.com.sqlite3\"}");
  42. ElementPtr SQLITE_DBFILE_EXAMPLE_ROOT = Element::createFromString(
  43. "{ \"database_file\": \"" TEST_DATA_DIR "/test-root.sqlite3\"}");
  44. ElementPtr SQLITE_DBFILE_BROKENDB = Element::createFromString(
  45. "{ \"database_file\": \"" TEST_DATA_DIR "/brokendb.sqlite3\"}");
  46. ElementPtr SQLITE_DBFILE_MEMORY = Element::createFromString(
  47. "{ \"database_file\": \":memory:\"}");
  48. // The following file must be non existent and must be non"creatable";
  49. // the sqlite3 library will try to create a new DB file if it doesn't exist,
  50. // so to test a failure case the create operation should also fail.
  51. // The "nodir", a non existent directory, is inserted for this purpose.
  52. ElementPtr SQLITE_DBFILE_NOTEXIST = Element::createFromString(
  53. "{ \"database_file\": \"" TEST_DATA_DIR "/nodir/notexist\"}");
  54. const string sigdata_common(" 20100322084538 20100220084538 "
  55. "33495 example.com. FAKEFAKEFAKEFAKE");
  56. const string dnskey1_data(" AwEAAcOUBllYc1hf7ND9uDy+Yz1BF3sI0m4q"
  57. "NGV7WcTD0WEiuV7IjXgHE36fCmS9QsUxSSOV"
  58. "o1I/FMxI2PJVqTYHkXFBS7AzLGsQYMU7UjBZ"
  59. "SotBJ6Imt5pXMu+lEDNy8TOUzG3xm7g0qcbW"
  60. "YF6qCEfvZoBtAqi5Rk7Mlrqs8agxYyMx");
  61. const string dnskey2_data(" AwEAAe5WFbxdCPq2jZrZhlMj7oJdff3W7syJ"
  62. "tbvzg62tRx0gkoCDoBI9DPjlOQG0UAbj+xUV"
  63. "4HQZJStJaZ+fHU5AwVNT+bBZdtV+NujSikhd"
  64. "THb4FYLg2b3Cx9NyJvAVukHp/91HnWuG4T36"
  65. "CzAFrfPwsHIrBz9BsaIQ21VRkcmj7DswfI/i"
  66. "DGd8j6bqiODyNZYQ+ZrLmF0KIJ2yPN3iO6Zq"
  67. "23TaOrVTjB7d1a/h31ODfiHAxFHrkY3t3D5J"
  68. "R9Nsl/7fdRmSznwtcSDgLXBoFEYmw6p86Acv"
  69. "RyoYNcL1SXjaKVLG5jyU3UR+LcGZT5t/0xGf"
  70. "oIK/aKwENrsjcKZZj660b1M=");
  71. const string nsec3_signature("gNIVj4T8t51fEU6kOPpvK7HOGBFZGbalN5ZK"
  72. "mInyrww6UWZsUNdw07ge6/U6HfG+/s61RZ/L"
  73. "is2M6yUWHyXbNbj/QqwqgadG5dhxTArfuR02"
  74. "xP600x0fWX8LXzW4yLMdKVxGbzYT+vvGz71o"
  75. "8gHSY5vYTtothcZQa4BMKhmGQEk=");
  76. const Name zone_name("example.com");
  77. const Name nomatch_name("example.org");
  78. const Name child_name("sql1.example.com");
  79. const Name www_name("www.example.com");
  80. const Name www_upper_name("WWW.EXAMPLE.COM");
  81. typedef enum {
  82. NORMAL,
  83. EXACT,
  84. ADDRESS,
  85. REFERRAL
  86. } FindMode;
  87. class Sqlite3DataSourceTest : public ::testing::Test {
  88. protected:
  89. Sqlite3DataSourceTest() : rrclass(RRClass::IN()),
  90. rrclass_notmatch(RRClass::CH()),
  91. rrtype(RRType::A()), rrttl(RRTTL(3600)),
  92. find_flags(0), rrset_matched(0), rrset_count(0)
  93. {
  94. data_source.init(SQLITE_DBFILE_EXAMPLE);
  95. common_a_data.push_back("192.0.2.1");
  96. common_sig_data.push_back("A 5 3 3600" + sigdata_common);
  97. common_aaaa_data.push_back("2001:db8::1234");
  98. common_aaaa_sig_data.push_back("AAAA 5 3 3600" + sigdata_common);
  99. www_nsec_data.push_back("example.com. A RRSIG NSEC");
  100. www_nsec_sig_data.push_back("NSEC 5 3 7200" + sigdata_common);
  101. mix_a_data.push_back("192.0.2.1");
  102. mix_a_data.push_back("192.0.2.2");
  103. mix_aaaa_data.push_back("2001:db8::1");
  104. mix_aaaa_data.push_back("2001:db8::2");
  105. apex_soa_data.push_back("master.example.com. admin.example.com. "
  106. "1234 3600 1800 2419200 7200");
  107. apex_soa_sig_data.push_back("SOA 5 2 3600" + sigdata_common);
  108. apex_ns_data.push_back("dns01.example.com.");
  109. apex_ns_data.push_back("dns02.example.com.");
  110. apex_ns_data.push_back("dns03.example.com.");
  111. apex_ns_sig_data.push_back("NS 5 2 3600" + sigdata_common);
  112. apex_mx_data.push_back("10 mail.example.com.");
  113. apex_mx_data.push_back("20 mail.subzone.example.com.");
  114. apex_mx_sig_data.push_back("MX 5 2 3600" + sigdata_common);
  115. apex_nsec_data.push_back("cname-ext.example.com. "
  116. "NS SOA MX RRSIG NSEC DNSKEY");
  117. apex_nsec_sig_data.push_back("NSEC 5 2 7200" + sigdata_common);
  118. apex_dnskey_data.push_back("256 3 5" + dnskey1_data);
  119. apex_dnskey_data.push_back("257 3 5" + dnskey2_data);
  120. // this one is special (using different key):
  121. apex_dnskey_sig_data.push_back("DNSKEY 5 2 3600 20100322084538 "
  122. "20100220084538 4456 example.com. "
  123. "FAKEFAKEFAKEFAKE");
  124. apex_dnskey_sig_data.push_back("DNSKEY 5 2 3600" + sigdata_common);
  125. wild_a_data.push_back("192.0.2.255");
  126. dname_data.push_back("sql1.example.com.");
  127. dname_sig_data.push_back("DNAME 5 3 3600" + sigdata_common);
  128. cname_data.push_back("cnametest.example.org.");
  129. cname_sig_data.push_back("CNAME 5 3 3600" + sigdata_common);
  130. cname_nsec_data.push_back("mail.example.com. CNAME RRSIG NSEC");
  131. cname_nsec_sig_data.push_back("NSEC 5 3 7200" + sigdata_common);
  132. delegation_ns_data.push_back("ns1.subzone.example.com.");
  133. delegation_ns_data.push_back("ns2.subzone.example.com.");
  134. delegation_ds_data.push_back("40633 5 1 "
  135. "3E56C0EA92CF529E005A4B62979533350492 "
  136. "F105");
  137. delegation_ds_data.push_back("40633 5 2 "
  138. "AA8D4BD330C68BFB4D785894DDCF6B689CE9"
  139. "873C4A3801F57A5AA3FE17925B8C");
  140. delegation_ds_sig_data.push_back("DS 5 3 3600" + sigdata_common);
  141. child_ds_data.push_back("33313 5 1 "
  142. "FDD7A2C11AA7F55D50FBF9B7EDDA2322C541A8DE");
  143. child_ds_data.push_back("33313 5 2 "
  144. "0B99B7006F496D135B01AB17EDB469B4BE9E"
  145. "1973884DEA757BC4E3015A8C3AB3");
  146. child_ds_sig_data.push_back("DS 5 3 3600" + sigdata_common);
  147. delegation_nsec_data.push_back("*.wild.example.com. NS DS RRSIG NSEC");
  148. delegation_nsec_sig_data.push_back("NSEC 5 3 7200" + sigdata_common);
  149. child_a_data.push_back("192.0.2.100");
  150. child_sig_data.push_back("A 5 4 3600 20100322084536 "
  151. "20100220084536 12447 sql1.example.com. "
  152. "FAKEFAKEFAKEFAKE");
  153. nsec3_data.push_back("1 0 10 FEEDABEE 4KLSVDE8KH8G95VU68R7AHBE1CPQN38J");
  154. nsec3_sig_data.push_back("NSEC3 5 4 7200 20100410172647 "
  155. "20100311172647 63192 sql2.example.com. "
  156. + nsec3_signature);
  157. }
  158. Sqlite3DataSrc data_source;
  159. // we allow these to be modified in the test
  160. RRClass rrclass;
  161. RRClass rrclass_notmatch;
  162. RRType rrtype;
  163. RRTTL rrttl;
  164. RRsetList result_sets;
  165. uint32_t find_flags;
  166. unsigned rrset_matched;
  167. unsigned rrset_count;
  168. vector<RRType> types;
  169. vector<RRTTL> ttls;
  170. vector<const vector<string>* > answers;
  171. vector<const vector<string>* > signatures;
  172. vector<RRType> expected_types;
  173. vector<string> common_a_data;
  174. vector<string> common_sig_data;
  175. vector<string> common_aaaa_data;
  176. vector<string> common_aaaa_sig_data;
  177. vector<string> www_nsec_data;
  178. vector<string> www_nsec_sig_data;
  179. vector<string> mix_a_data;
  180. vector<string> mix_aaaa_data;
  181. vector<string> apex_soa_data;
  182. vector<string> apex_soa_sig_data;
  183. vector<string> apex_ns_data;
  184. vector<string> apex_ns_sig_data;
  185. vector<string> apex_mx_data;
  186. vector<string> apex_mx_sig_data;
  187. vector<string> apex_nsec_data;
  188. vector<string> apex_nsec_sig_data;
  189. vector<string> apex_dnskey_data;
  190. vector<string> apex_dnskey_sig_data;
  191. vector<string> wild_a_data;
  192. vector<string> dname_data;
  193. vector<string> dname_sig_data;
  194. vector<string> cname_data;
  195. vector<string> cname_sig_data;
  196. vector<string> cname_nsec_data;
  197. vector<string> cname_nsec_sig_data;
  198. vector<string> delegation_ns_data;
  199. vector<string> delegation_ns_sig_data;
  200. vector<string> delegation_ds_data;
  201. vector<string> delegation_ds_sig_data;
  202. vector<string> child_ds_data;
  203. vector<string> child_ds_sig_data;
  204. vector<string> delegation_nsec_data;
  205. vector<string> delegation_nsec_sig_data;
  206. vector<string> child_a_data;
  207. vector<string> child_sig_data;
  208. vector<string> nsec3_data;
  209. vector<string> nsec3_sig_data;
  210. void findReferralRRsetCommon(const Name& qname, const RRClass& qclass);
  211. void findAddressRRsetCommon(const RRClass& qclass);
  212. };
  213. void
  214. checkRRset(RRsetPtr rrset, const Name& expected_name,
  215. const RRClass& expected_class, const RRType& expected_type,
  216. const RRTTL& expected_rrttl, const vector<string>& expected_data,
  217. const vector<string>* expected_sig_data)
  218. {
  219. EXPECT_EQ(expected_name, rrset->getName());
  220. EXPECT_EQ(expected_class, rrset->getClass());
  221. EXPECT_EQ(expected_type, rrset->getType());
  222. EXPECT_EQ(expected_rrttl, rrset->getTTL());
  223. RdataIteratorPtr rdata_iterator = rrset->getRdataIterator();
  224. rdata_iterator->first();
  225. vector<string>::const_iterator data_it = expected_data.begin();
  226. for (; data_it != expected_data.end(); ++data_it) {
  227. EXPECT_FALSE(rdata_iterator->isLast());
  228. if (rdata_iterator->isLast()) {
  229. // buggy case, should stop here
  230. break;
  231. }
  232. // We use text-based comparison so that we can easily identify which
  233. // data causes the error. RDATA::compare() is the most strict
  234. // comparison method, but in this case text-based comparison should
  235. // be okay because we generate the text data from Rdata objects
  236. // rather than hand-write the expected text.
  237. EXPECT_EQ(createRdata(expected_type, expected_class,
  238. *data_it)->toText(),
  239. rdata_iterator->getCurrent().toText());
  240. rdata_iterator->next();
  241. }
  242. if (expected_sig_data != NULL) {
  243. RRsetPtr sig_rrset = rrset->getRRsig();
  244. EXPECT_FALSE(sig_rrset == NULL);
  245. if (sig_rrset != NULL) { // check this to avoid possible bug.
  246. // Note: we assume the TTL for RRSIG is the same as that of the
  247. // RRSIG target.
  248. checkRRset(sig_rrset, expected_name, expected_class,
  249. RRType::RRSIG(), expected_rrttl, *expected_sig_data,
  250. NULL);
  251. }
  252. } else {
  253. EXPECT_TRUE(NULL == rrset->getRRsig());
  254. }
  255. EXPECT_TRUE(rdata_iterator->isLast());
  256. }
  257. void
  258. checkFind(FindMode mode, const Sqlite3DataSrc& data_source,
  259. const Name& expected_name, const Name* zone_name,
  260. const RRClass& qclass, const RRClass& expected_class,
  261. const RRType& expected_type, const vector<RRTTL>& expected_ttls,
  262. const uint32_t expected_flags, const vector<RRType>& expected_types,
  263. const vector<const vector<string>* >& expected_answers,
  264. const vector<const vector<string>* >& expected_signatures)
  265. {
  266. RRsetList result_sets;
  267. uint32_t find_flags;
  268. unsigned int rrset_matched = 0;
  269. unsigned int rrset_count = 0;
  270. switch (mode) {
  271. case NORMAL:
  272. EXPECT_EQ(DataSrc::SUCCESS,
  273. data_source.findRRset(expected_name, qclass,
  274. expected_type, result_sets, find_flags,
  275. zone_name));
  276. break;
  277. case EXACT:
  278. EXPECT_EQ(DataSrc::SUCCESS,
  279. data_source.findExactRRset(expected_name, qclass,
  280. expected_type, result_sets,
  281. find_flags, zone_name));
  282. break;
  283. case ADDRESS:
  284. EXPECT_EQ(DataSrc::SUCCESS,
  285. data_source.findAddrs(expected_name, qclass, result_sets,
  286. find_flags, zone_name));
  287. break;
  288. case REFERRAL:
  289. EXPECT_EQ(DataSrc::SUCCESS,
  290. data_source.findReferral(expected_name, qclass, result_sets,
  291. find_flags, zone_name));
  292. break;
  293. }
  294. EXPECT_EQ(expected_flags, find_flags);
  295. RRsetList::iterator it = result_sets.begin();
  296. for (; it != result_sets.end(); ++it) {
  297. vector<RRType>::const_iterator found_type =
  298. find(expected_types.begin(), expected_types.end(),
  299. (*it)->getType());
  300. // there should be a match
  301. EXPECT_TRUE(found_type != expected_types.end());
  302. if (found_type != expected_types.end()) {
  303. unsigned int index = distance(expected_types.begin(), found_type);
  304. checkRRset(*it, expected_name, expected_class, (*it)->getType(),
  305. expected_ttls[index], *expected_answers[index],
  306. expected_signatures[index]);
  307. ++rrset_matched;
  308. }
  309. ++rrset_count;
  310. }
  311. EXPECT_EQ(expected_types.size(), rrset_count);
  312. EXPECT_EQ(expected_types.size(), rrset_matched);
  313. }
  314. void
  315. checkFind(FindMode mode, const Sqlite3DataSrc& data_source,
  316. const Name& expected_name, const Name* zone_name,
  317. const RRClass& qclass, const RRClass& expected_class,
  318. const RRType& expected_type, const RRTTL& expected_rrttl,
  319. const uint32_t expected_flags,
  320. const vector<string>& expected_data,
  321. const vector<string>* expected_sig_data)
  322. {
  323. vector<RRType> types;
  324. vector<RRTTL> ttls;
  325. vector<const vector<string>* > answers;
  326. vector<const vector<string>* > signatures;
  327. types.push_back(expected_type);
  328. ttls.push_back(expected_rrttl);
  329. answers.push_back(&expected_data);
  330. signatures.push_back(expected_sig_data);
  331. checkFind(mode, data_source, expected_name, zone_name, qclass,
  332. expected_class, expected_type, ttls, expected_flags, types,
  333. answers, signatures);
  334. }
  335. TEST_F(Sqlite3DataSourceTest, close) {
  336. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  337. }
  338. TEST_F(Sqlite3DataSourceTest, reOpen) {
  339. // Replace the data with a totally different zone. This should succeed,
  340. // and shouldn't match any names in the previously managed domains.
  341. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  342. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE2));
  343. NameMatch name_match(www_name);
  344. data_source.findClosestEnclosure(name_match, rrclass);
  345. EXPECT_EQ(static_cast<void*>(NULL), name_match.closestName());
  346. EXPECT_EQ(static_cast<void*>(NULL), name_match.bestDataSrc());
  347. }
  348. TEST_F(Sqlite3DataSourceTest, openFail) {
  349. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  350. EXPECT_THROW(data_source.init(SQLITE_DBFILE_NOTEXIST), Sqlite3Error);
  351. }
  352. TEST_F(Sqlite3DataSourceTest, doubleOpen) {
  353. // An attempt of duplicate open should trigger an exception.
  354. EXPECT_THROW(data_source.init(SQLITE_DBFILE_EXAMPLE), DataSourceError);
  355. }
  356. TEST_F(Sqlite3DataSourceTest, doubleClose) {
  357. // An attempt of duplicate close should trigger an exception.
  358. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  359. EXPECT_THROW(data_source.close(), DataSourceError);
  360. }
  361. TEST_F(Sqlite3DataSourceTest, openBrokenDB) {
  362. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  363. // The database exists but is broken. An exception will be thrown
  364. // in the middle of the initialization.
  365. EXPECT_THROW(data_source.init(SQLITE_DBFILE_BROKENDB), Sqlite3Error);
  366. // Confirming the strong exception guarantee: the data source must be
  367. // in the closed state.
  368. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE));
  369. }
  370. // This test only confirms that on-the-fly schema creation works.
  371. TEST_F(Sqlite3DataSourceTest, memoryDB) {
  372. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  373. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_MEMORY));
  374. }
  375. TEST_F(Sqlite3DataSourceTest, findClosestEnclosure) {
  376. NameMatch name_match(www_name);
  377. data_source.findClosestEnclosure(name_match, rrclass);
  378. EXPECT_EQ(zone_name, *name_match.closestName());
  379. EXPECT_EQ(&data_source, name_match.bestDataSrc());
  380. }
  381. TEST_F(Sqlite3DataSourceTest, findClosestEnclosureMatchRoot) {
  382. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  383. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE_ROOT));
  384. NameMatch name_match(Name("org."));
  385. data_source.findClosestEnclosure(name_match, rrclass);
  386. EXPECT_EQ(Name("."), *name_match.closestName());
  387. EXPECT_EQ(&data_source, name_match.bestDataSrc());
  388. }
  389. TEST_F(Sqlite3DataSourceTest, findClosestEnclosureAtDelegation) {
  390. // The search name exists both in the parent and child zones, but
  391. // child has a better match.
  392. NameMatch name_match(child_name);
  393. data_source.findClosestEnclosure(name_match, rrclass);
  394. EXPECT_EQ(child_name, *name_match.closestName());
  395. EXPECT_EQ(&data_source, name_match.bestDataSrc());
  396. }
  397. TEST_F(Sqlite3DataSourceTest, findClosestEnclosureNoMatch) {
  398. NameMatch name_match(nomatch_name);
  399. data_source.findClosestEnclosure(name_match, rrclass);
  400. EXPECT_EQ(static_cast<void*>(NULL), name_match.closestName());
  401. EXPECT_EQ(static_cast<void*>(NULL), name_match.bestDataSrc());
  402. }
  403. TEST_F(Sqlite3DataSourceTest, findClosestClassMismatch) {
  404. NameMatch name_match(www_name);
  405. data_source.findClosestEnclosure(name_match, rrclass_notmatch);
  406. EXPECT_EQ(static_cast<void*>(NULL), name_match.closestName());
  407. EXPECT_EQ(static_cast<void*>(NULL), name_match.bestDataSrc());
  408. }
  409. // If the query class is ANY, the result should be the same as the case where
  410. // the class exactly matches.
  411. TEST_F(Sqlite3DataSourceTest, findClosestClassAny) {
  412. NameMatch name_match(www_name);
  413. data_source.findClosestEnclosure(name_match, RRClass::ANY());
  414. EXPECT_EQ(zone_name, *name_match.closestName());
  415. EXPECT_EQ(&data_source, name_match.bestDataSrc());
  416. }
  417. TEST_F(Sqlite3DataSourceTest, findRRsetNormal) {
  418. // Without specifying the zone name, and then with the zone name
  419. checkFind(NORMAL, data_source, www_name, NULL, rrclass, rrclass, rrtype,
  420. rrttl, 0, common_a_data, &common_sig_data);
  421. checkFind(NORMAL, data_source, www_name, &zone_name, rrclass, rrclass,
  422. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  423. // With a zone name that doesn't match
  424. EXPECT_EQ(DataSrc::SUCCESS,
  425. data_source.findRRset(www_name, rrclass, rrtype,
  426. result_sets, find_flags, &nomatch_name));
  427. EXPECT_EQ(DataSrc::NO_SUCH_ZONE, find_flags);
  428. EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
  429. }
  430. TEST_F(Sqlite3DataSourceTest, findRRsetClassMismatch) {
  431. EXPECT_EQ(DataSrc::ERROR,
  432. data_source.findRRset(www_name, rrclass_notmatch, rrtype,
  433. result_sets, find_flags, NULL));
  434. }
  435. TEST_F(Sqlite3DataSourceTest, findRRsetClassAny) {
  436. checkFind(NORMAL, data_source, www_name, NULL, RRClass::ANY(), rrclass,
  437. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  438. }
  439. TEST_F(Sqlite3DataSourceTest, findRRsetClassClassAny) {
  440. checkFind(NORMAL, data_source, www_name, NULL, RRClass::ANY(), rrclass,
  441. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  442. }
  443. TEST_F(Sqlite3DataSourceTest, findRRsetNormalANY) {
  444. types.push_back(RRType::A());
  445. types.push_back(RRType::NSEC());
  446. ttls.push_back(RRTTL(3600));
  447. ttls.push_back(RRTTL(7200));
  448. answers.push_back(&common_a_data);
  449. answers.push_back(&www_nsec_data);
  450. signatures.push_back(&common_sig_data);
  451. signatures.push_back(&www_nsec_sig_data);
  452. rrtype = RRType::ANY();
  453. checkFind(NORMAL, data_source, www_name, NULL, rrclass, rrclass, rrtype,
  454. ttls, 0, types, answers, signatures);
  455. checkFind(NORMAL, data_source, www_name, &zone_name, rrclass, rrclass,
  456. rrtype, ttls, 0, types, answers, signatures);
  457. }
  458. // Case insensitive lookup
  459. TEST_F(Sqlite3DataSourceTest, findRRsetNormalCase) {
  460. checkFind(NORMAL, data_source, www_upper_name, NULL, rrclass, rrclass,
  461. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  462. checkFind(NORMAL, data_source, www_upper_name, &zone_name, rrclass, rrclass,
  463. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  464. EXPECT_EQ(DataSrc::SUCCESS,
  465. data_source.findRRset(www_upper_name, rrclass, rrtype,
  466. result_sets, find_flags, &nomatch_name));
  467. EXPECT_EQ(DataSrc::NO_SUCH_ZONE, find_flags);
  468. EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
  469. }
  470. TEST_F(Sqlite3DataSourceTest, findRRsetApexNS) {
  471. rrtype = RRType::NS();
  472. checkFind(NORMAL, data_source, zone_name, NULL, rrclass, rrclass, rrtype,
  473. rrttl, DataSrc::REFERRAL, apex_ns_data, &apex_ns_sig_data);
  474. checkFind(NORMAL, data_source, zone_name, &zone_name, rrclass, rrclass,
  475. rrtype, rrttl, DataSrc::REFERRAL, apex_ns_data,
  476. &apex_ns_sig_data);
  477. EXPECT_EQ(DataSrc::SUCCESS,
  478. data_source.findRRset(zone_name, rrclass, rrtype,
  479. result_sets, find_flags, &nomatch_name));
  480. EXPECT_EQ(DataSrc::NO_SUCH_ZONE, find_flags);
  481. EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
  482. }
  483. TEST_F(Sqlite3DataSourceTest, findRRsetApexANY) {
  484. types.push_back(RRType::SOA());
  485. types.push_back(RRType::NS());
  486. types.push_back(RRType::MX());
  487. types.push_back(RRType::NSEC());
  488. types.push_back(RRType::DNSKEY());
  489. ttls.push_back(rrttl); // SOA TTL
  490. ttls.push_back(rrttl); // NS TTL
  491. ttls.push_back(rrttl); // MX TTL
  492. ttls.push_back(RRTTL(7200)); // NSEC TTL
  493. ttls.push_back(rrttl); // DNSKEY TTL
  494. answers.push_back(&apex_soa_data);
  495. answers.push_back(&apex_ns_data);
  496. answers.push_back(&apex_mx_data);
  497. answers.push_back(&apex_nsec_data);
  498. answers.push_back(&apex_dnskey_data);
  499. signatures.push_back(&apex_soa_sig_data);
  500. signatures.push_back(&apex_ns_sig_data);
  501. signatures.push_back(&apex_mx_sig_data);
  502. signatures.push_back(&apex_nsec_sig_data);
  503. signatures.push_back(&apex_dnskey_sig_data);
  504. rrtype = RRType::ANY();
  505. // there is an NS at the zone apex, so the REFERRAL flag should
  506. // be set, but will ordinarily be ignored by the caller
  507. checkFind(NORMAL, data_source, zone_name, NULL, rrclass, rrclass, rrtype,
  508. ttls, DataSrc::REFERRAL, types, answers, signatures);
  509. checkFind(NORMAL, data_source, zone_name, &zone_name, rrclass, rrclass,
  510. rrtype, ttls, DataSrc::REFERRAL, types, answers, signatures);
  511. }
  512. TEST_F(Sqlite3DataSourceTest, findRRsetMixedANY) {
  513. // ANY query for mixed order RRs
  514. const Name qname("mix.example.com");
  515. types.push_back(RRType::A());
  516. types.push_back(RRType::AAAA());
  517. ttls.push_back(rrttl);
  518. ttls.push_back(rrttl);
  519. answers.push_back(&mix_a_data);
  520. answers.push_back(&mix_aaaa_data);
  521. signatures.push_back(NULL);
  522. signatures.push_back(NULL);
  523. rrtype = RRType::ANY();
  524. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  525. rrtype, ttls, 0, types, answers, signatures);
  526. }
  527. TEST_F(Sqlite3DataSourceTest, findRRsetApexNXRRSET) {
  528. rrtype = RRType::AAAA();
  529. EXPECT_EQ(DataSrc::SUCCESS,
  530. data_source.findRRset(zone_name, rrclass, rrtype,
  531. result_sets, find_flags, &zone_name));
  532. // there's an NS RRset at the apex name, so the REFERRAL flag should be
  533. // set, too.
  534. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  535. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  536. // Same test, without specifying the zone name
  537. EXPECT_EQ(DataSrc::SUCCESS,
  538. data_source.findRRset(zone_name, rrclass, rrtype,
  539. result_sets, find_flags, NULL));
  540. // there's an NS RRset at the apex name, so the REFERRAL flag should be
  541. // set, too.
  542. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  543. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  544. }
  545. // Matching a wildcard node. There's nothing special for the data source API
  546. // point of view, but perform minimal tests anyway.
  547. TEST_F(Sqlite3DataSourceTest, findRRsetWildcard) {
  548. const Name qname("*.wild.example.com");
  549. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  550. rrtype, rrttl, 0, wild_a_data, &common_sig_data);
  551. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  552. rrtype, rrttl, 0, wild_a_data, &common_sig_data);
  553. }
  554. TEST_F(Sqlite3DataSourceTest, findRRsetEmptyNode) {
  555. // foo.bar.example.com exists, but bar.example.com doesn't have any data.
  556. const Name qname("bar.example.com");
  557. EXPECT_EQ(DataSrc::SUCCESS,
  558. data_source.findRRset(qname, rrclass, rrtype,
  559. result_sets, find_flags, NULL));
  560. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  561. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  562. EXPECT_EQ(DataSrc::SUCCESS,
  563. data_source.findRRset(qname, rrclass, rrtype,
  564. result_sets, find_flags, &zone_name));
  565. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  566. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  567. }
  568. // There's nothing special about DNAME lookup for the data source API
  569. // point of view, but perform minimal tests anyway.
  570. TEST_F(Sqlite3DataSourceTest, findRRsetDNAME) {
  571. const Name qname("dname.example.com");
  572. rrtype = RRType::DNAME();
  573. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  574. rrtype, rrttl, 0, dname_data, &dname_sig_data);
  575. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  576. rrtype, rrttl, 0, dname_data, &dname_sig_data);
  577. }
  578. TEST_F(Sqlite3DataSourceTest, findRRsetCNAME) {
  579. const Name qname("foo.example.com");
  580. // This qname only has the CNAME (+ sigs). CNAME query is not different
  581. // from ordinary queries.
  582. rrtype = RRType::CNAME();
  583. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  584. rrtype, rrttl, 0, cname_data, &cname_sig_data);
  585. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  586. rrtype, rrttl, 0, cname_data, &cname_sig_data);
  587. // queries for (ordinary) different RR types that match the CNAME.
  588. // CNAME_FOUND flag is set, and the CNAME RR is returned instead of A
  589. rrtype = RRType::A();
  590. types.push_back(RRType::CNAME());
  591. ttls.push_back(rrttl);
  592. answers.push_back(&cname_data);
  593. signatures.push_back(&cname_sig_data);
  594. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  595. rrtype, ttls, DataSrc::CNAME_FOUND, types, answers, signatures);
  596. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  597. rrtype, ttls, DataSrc::CNAME_FOUND, types, answers, signatures);
  598. // NSEC query that match the CNAME.
  599. // CNAME_FOUND flag is NOT set, and the NSEC RR is returned instead of
  600. // CNAME.
  601. rrtype = RRType::NSEC();
  602. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  603. rrtype, RRTTL(7200), 0, cname_nsec_data, &cname_nsec_sig_data);
  604. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  605. rrtype, RRTTL(7200), 0, cname_nsec_data, &cname_nsec_sig_data);
  606. }
  607. TEST_F(Sqlite3DataSourceTest, findRRsetDelegation) {
  608. const Name qname("www.subzone.example.com");
  609. // query for a name under a zone cut. From the data source API point
  610. // of view this is no different than "NXDOMAIN".
  611. EXPECT_EQ(DataSrc::SUCCESS,
  612. data_source.findRRset(qname, rrclass, rrtype,
  613. result_sets, find_flags, NULL));
  614. EXPECT_EQ(DataSrc::NAME_NOT_FOUND, find_flags);
  615. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  616. }
  617. TEST_F(Sqlite3DataSourceTest, findRRsetDelegationAtZoneCut) {
  618. const Name qname("subzone.example.com");
  619. // query for a name *at* a zone cut. It matches the NS RRset for the
  620. // delegation.
  621. // For non-NS ordinary queries, "no type" should be set too, and no RRset is
  622. // returned.
  623. EXPECT_EQ(DataSrc::SUCCESS,
  624. data_source.findRRset(qname, rrclass, rrtype,
  625. result_sets, find_flags, NULL));
  626. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  627. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  628. EXPECT_EQ(DataSrc::SUCCESS,
  629. data_source.findRRset(qname, rrclass, rrtype,
  630. result_sets, find_flags, &zone_name));
  631. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  632. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  633. // For NS query, RRset is returned with the REFERRAL flag. No RRSIG should
  634. // be provided.
  635. rrtype = RRType::NS();
  636. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  637. rrtype, rrttl, DataSrc::REFERRAL, delegation_ns_data, NULL);
  638. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  639. rrtype, rrttl, DataSrc::REFERRAL, delegation_ns_data, NULL);
  640. // For ANY query. At the backend data source level, it returns all
  641. // existent records with their RRSIGs, setting the referral flag.
  642. rrtype = RRType::ANY();
  643. types.push_back(RRType::NS());
  644. types.push_back(RRType::NSEC());
  645. types.push_back(RRType::DS());
  646. ttls.push_back(rrttl);
  647. ttls.push_back(RRTTL(7200));
  648. ttls.push_back(rrttl);
  649. answers.push_back(&delegation_ns_data);
  650. answers.push_back(&delegation_nsec_data);
  651. answers.push_back(&delegation_ds_data);
  652. signatures.push_back(NULL);
  653. signatures.push_back(&delegation_nsec_sig_data);
  654. signatures.push_back(&delegation_ds_sig_data);
  655. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  656. rrtype, ttls, DataSrc::REFERRAL, types, answers,
  657. signatures);
  658. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  659. rrtype, ttls, DataSrc::REFERRAL, types, answers,
  660. signatures);
  661. // For NSEC query. At the backend data source level, it returns NSEC+
  662. // RRSIG with the referral flag.
  663. rrtype = RRType::NSEC();
  664. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  665. rrtype, RRTTL(7200), DataSrc::REFERRAL, delegation_nsec_data,
  666. &delegation_nsec_sig_data);
  667. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  668. rrtype, RRTTL(7200), DataSrc::REFERRAL, delegation_nsec_data,
  669. &delegation_nsec_sig_data);
  670. }
  671. TEST_F(Sqlite3DataSourceTest, findRRsetInChildZone) {
  672. const Name qname("www.sql1.example.com");
  673. const Name child_zone_name("sql1.example.com");
  674. // If we don't specify the zone, the data source should identify the
  675. // best matching zone.
  676. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  677. rrtype, rrttl, 0, child_a_data, &child_sig_data);
  678. // If we specify the parent zone, it's treated as NXDOMAIN because it's
  679. // under a zone cut.
  680. EXPECT_EQ(DataSrc::SUCCESS,
  681. data_source.findRRset(qname, rrclass, rrtype,
  682. result_sets, find_flags, &zone_name));
  683. EXPECT_EQ(DataSrc::NAME_NOT_FOUND, find_flags);
  684. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  685. // If we specify the child zone, it should be the same as the first case.
  686. checkFind(NORMAL, data_source, qname, &child_zone_name, rrclass, rrclass,
  687. rrtype, rrttl, 0, child_a_data, &child_sig_data);
  688. }
  689. TEST_F(Sqlite3DataSourceTest, findExactRRset) {
  690. // Normal case. No different than findRRset.
  691. checkFind(EXACT, data_source, www_name, &zone_name, rrclass, rrclass,
  692. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  693. }
  694. TEST_F(Sqlite3DataSourceTest, findExactRRsetClassMismatch) {
  695. EXPECT_EQ(DataSrc::ERROR,
  696. data_source.findExactRRset(www_name, rrclass_notmatch, rrtype,
  697. result_sets, find_flags, NULL));
  698. }
  699. TEST_F(Sqlite3DataSourceTest, findExactRRsetClassAny) {
  700. checkFind(EXACT, data_source, www_name, &zone_name, RRClass::ANY(), rrclass,
  701. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  702. }
  703. TEST_F(Sqlite3DataSourceTest, findRRsetNSEC3) {
  704. // Simple NSEC3 tests (more should be added)
  705. string hashstr("1BB7SO0452U1QHL98UISNDD9218GELR5");
  706. const Name nsec3_zonename("sql2.example.com");
  707. EXPECT_EQ(DataSrc::SUCCESS,
  708. data_source.findCoveringNSEC3(nsec3_zonename,
  709. hashstr, result_sets));
  710. RRsetList::iterator it = result_sets.begin();
  711. checkRRset(*it, Name(hashstr).concatenate(nsec3_zonename), rrclass,
  712. RRType::NSEC3(), RRTTL(7200), nsec3_data, &nsec3_sig_data);
  713. ++it;
  714. EXPECT_TRUE(it == result_sets.end());
  715. }
  716. TEST_F(Sqlite3DataSourceTest, findExactRRsetCNAME) {
  717. const Name qname("foo.example.com");
  718. // This qname only has the CNAME (+ sigs). In this case it should be
  719. // no different than findRRset for CNAME query.
  720. rrtype = RRType::CNAME();
  721. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  722. rrtype, rrttl, 0, cname_data, &cname_sig_data);
  723. // queries for (ordinary) different RR types that match the CNAME.
  724. // "type not found" set, but CNAME and its sig are returned (awkward,
  725. // but that's how it currently works).
  726. rrtype = RRType::A();
  727. types.push_back(RRType::CNAME());
  728. ttls.push_back(rrttl);
  729. answers.push_back(&cname_data);
  730. signatures.push_back(&cname_sig_data);
  731. checkFind(EXACT, data_source, qname, &zone_name, rrclass, rrclass,
  732. rrtype, ttls, DataSrc::TYPE_NOT_FOUND, types, answers,
  733. signatures);
  734. }
  735. void
  736. Sqlite3DataSourceTest::findReferralRRsetCommon(const Name& qname,
  737. const RRClass& qclass)
  738. {
  739. types.push_back(RRType::NS());
  740. types.push_back(RRType::DS());
  741. ttls.push_back(rrttl);
  742. ttls.push_back(rrttl);
  743. answers.push_back(&apex_ns_data);
  744. answers.push_back(&child_ds_data);
  745. signatures.push_back(NULL);
  746. signatures.push_back(&child_ds_sig_data);
  747. // Note: zone_name matters here because we need to perform the search
  748. // in the parent zone.
  749. checkFind(REFERRAL, data_source, qname, &zone_name, qclass, rrclass,
  750. rrtype, ttls, DataSrc::REFERRAL, types, answers, signatures);
  751. }
  752. TEST_F(Sqlite3DataSourceTest, findReferralRRset) {
  753. // A referral lookup searches for NS, DS, or DNAME, or their sigs.
  754. const Name qname("sql1.example.com");
  755. findReferralRRsetCommon(qname, rrclass);
  756. }
  757. TEST_F(Sqlite3DataSourceTest, findReferralRRsetClassMismatch) {
  758. EXPECT_EQ(DataSrc::ERROR,
  759. data_source.findReferral(www_name, rrclass_notmatch, result_sets,
  760. find_flags, NULL));
  761. }
  762. TEST_F(Sqlite3DataSourceTest, findReferralRRsetClassAny) {
  763. const Name qname("sql1.example.com");
  764. findReferralRRsetCommon(qname, RRClass::ANY());
  765. }
  766. TEST_F(Sqlite3DataSourceTest, findReferralRRsetDNAME) {
  767. // same as above. the DNAME case.
  768. const Name qname("dname.example.com");
  769. checkFind(REFERRAL, data_source, qname, &zone_name, rrclass, rrclass,
  770. RRType::DNAME(), rrttl, 0, dname_data, &dname_sig_data);
  771. }
  772. TEST_F(Sqlite3DataSourceTest, findReferralRRsetFail) {
  773. // qname has not "referral" records. the result should be "empty".
  774. EXPECT_EQ(DataSrc::SUCCESS,
  775. data_source.findReferral(www_name, rrclass,
  776. result_sets, find_flags, &zone_name));
  777. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  778. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  779. }
  780. void
  781. Sqlite3DataSourceTest::findAddressRRsetCommon(const RRClass& qclass) {
  782. // A referral lookup searches for A or AAAA, or their sigs.
  783. // A-only case
  784. checkFind(ADDRESS, data_source, www_name, &zone_name, qclass, rrclass,
  785. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  786. // AAAA-only case
  787. checkFind(ADDRESS, data_source, Name("ip6.example.com"), &zone_name,
  788. qclass, rrclass, RRType::AAAA(), rrttl, 0, common_aaaa_data,
  789. &common_aaaa_sig_data);
  790. // Dual-stack
  791. types.push_back(RRType::A());
  792. ttls.push_back(rrttl);
  793. answers.push_back(&common_a_data);
  794. signatures.push_back(&common_sig_data);
  795. types.push_back(RRType::AAAA());
  796. ttls.push_back(rrttl);
  797. answers.push_back(&common_aaaa_data);
  798. signatures.push_back(&common_aaaa_sig_data);
  799. checkFind(ADDRESS, data_source, Name("ip46.example.com"), &zone_name,
  800. rrclass, rrclass, rrtype, ttls, 0, types, answers, signatures);
  801. // The qname doesn't have no address records.
  802. EXPECT_EQ(DataSrc::SUCCESS,
  803. data_source.findAddrs(Name("text.example.com"), qclass,
  804. result_sets, find_flags, &zone_name));
  805. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  806. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  807. }
  808. TEST_F(Sqlite3DataSourceTest, findAddressRRset) {
  809. findAddressRRsetCommon(rrclass);
  810. }
  811. TEST_F(Sqlite3DataSourceTest, findAddressRRsetClassMismatch) {
  812. EXPECT_EQ(DataSrc::ERROR, data_source.findAddrs(www_name, rrclass_notmatch,
  813. result_sets, find_flags,
  814. NULL));
  815. }
  816. TEST_F(Sqlite3DataSourceTest, findAddressRRsetClassAny) {
  817. findAddressRRsetCommon(RRClass::ANY());
  818. }
  819. }