sqlite3_unittest.cc 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  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. ConstElementPtr SQLITE_DBFILE_EXAMPLE = Element::fromJSON(
  39. "{ \"database_file\": \"" TEST_DATA_DIR "/test.sqlite3\"}");
  40. ConstElementPtr SQLITE_DBFILE_EXAMPLE2 = Element::fromJSON(
  41. "{ \"database_file\": \"" TEST_DATA_DIR "/example2.com.sqlite3\"}");
  42. ConstElementPtr SQLITE_DBFILE_EXAMPLE_ROOT = Element::fromJSON(
  43. "{ \"database_file\": \"" TEST_DATA_DIR "/test-root.sqlite3\"}");
  44. ConstElementPtr SQLITE_DBFILE_BROKENDB = Element::fromJSON(
  45. "{ \"database_file\": \"" TEST_DATA_DIR "/brokendb.sqlite3\"}");
  46. ConstElementPtr SQLITE_DBFILE_MEMORY = Element::fromJSON(
  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. ConstElementPtr SQLITE_DBFILE_NOTEXIST = Element::fromJSON(
  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. vector<string>::const_iterator data_it = expected_data.begin();
  225. for (; data_it != expected_data.end(); ++data_it) {
  226. EXPECT_FALSE(rdata_iterator->isLast());
  227. if (rdata_iterator->isLast()) {
  228. // buggy case, should stop here
  229. break;
  230. }
  231. // We use text-based comparison so that we can easily identify which
  232. // data causes the error. RDATA::compare() is the most strict
  233. // comparison method, but in this case text-based comparison should
  234. // be okay because we generate the text data from Rdata objects
  235. // rather than hand-write the expected text.
  236. EXPECT_EQ(createRdata(expected_type, expected_class,
  237. *data_it)->toText(),
  238. rdata_iterator->getCurrent().toText());
  239. rdata_iterator->next();
  240. }
  241. if (expected_sig_data != NULL) {
  242. RRsetPtr sig_rrset = rrset->getRRsig();
  243. EXPECT_FALSE(sig_rrset == NULL);
  244. if (sig_rrset != NULL) { // check this to avoid possible bug.
  245. // Note: we assume the TTL for RRSIG is the same as that of the
  246. // RRSIG target.
  247. checkRRset(sig_rrset, expected_name, expected_class,
  248. RRType::RRSIG(), expected_rrttl, *expected_sig_data,
  249. NULL);
  250. }
  251. } else {
  252. EXPECT_TRUE(NULL == rrset->getRRsig());
  253. }
  254. EXPECT_TRUE(rdata_iterator->isLast());
  255. }
  256. void
  257. checkFind(FindMode mode, const Sqlite3DataSrc& data_source,
  258. const Name& expected_name, const Name* zone_name,
  259. const RRClass& qclass, const RRClass& expected_class,
  260. const RRType& expected_type, const vector<RRTTL>& expected_ttls,
  261. const uint32_t expected_flags, const vector<RRType>& expected_types,
  262. const vector<const vector<string>* >& expected_answers,
  263. const vector<const vector<string>* >& expected_signatures)
  264. {
  265. RRsetList result_sets;
  266. uint32_t find_flags;
  267. unsigned int rrset_matched = 0;
  268. unsigned int rrset_count = 0;
  269. switch (mode) {
  270. case NORMAL:
  271. EXPECT_EQ(DataSrc::SUCCESS,
  272. data_source.findRRset(expected_name, qclass,
  273. expected_type, result_sets, find_flags,
  274. zone_name));
  275. break;
  276. case EXACT:
  277. EXPECT_EQ(DataSrc::SUCCESS,
  278. data_source.findExactRRset(expected_name, qclass,
  279. expected_type, result_sets,
  280. find_flags, zone_name));
  281. break;
  282. case ADDRESS:
  283. EXPECT_EQ(DataSrc::SUCCESS,
  284. data_source.findAddrs(expected_name, qclass, result_sets,
  285. find_flags, zone_name));
  286. break;
  287. case REFERRAL:
  288. EXPECT_EQ(DataSrc::SUCCESS,
  289. data_source.findReferral(expected_name, qclass, result_sets,
  290. find_flags, zone_name));
  291. break;
  292. }
  293. EXPECT_EQ(expected_flags, find_flags);
  294. RRsetList::iterator it = result_sets.begin();
  295. for (; it != result_sets.end(); ++it) {
  296. vector<RRType>::const_iterator found_type =
  297. find(expected_types.begin(), expected_types.end(),
  298. (*it)->getType());
  299. // there should be a match
  300. EXPECT_TRUE(found_type != expected_types.end());
  301. if (found_type != expected_types.end()) {
  302. unsigned int index = distance(expected_types.begin(), found_type);
  303. checkRRset(*it, expected_name, expected_class, (*it)->getType(),
  304. expected_ttls[index], *expected_answers[index],
  305. expected_signatures[index]);
  306. ++rrset_matched;
  307. }
  308. ++rrset_count;
  309. }
  310. EXPECT_EQ(expected_types.size(), rrset_count);
  311. EXPECT_EQ(expected_types.size(), rrset_matched);
  312. }
  313. void
  314. checkFind(FindMode mode, const Sqlite3DataSrc& data_source,
  315. const Name& expected_name, const Name* zone_name,
  316. const RRClass& qclass, const RRClass& expected_class,
  317. const RRType& expected_type, const RRTTL& expected_rrttl,
  318. const uint32_t expected_flags,
  319. const vector<string>& expected_data,
  320. const vector<string>* expected_sig_data)
  321. {
  322. vector<RRType> types;
  323. vector<RRTTL> ttls;
  324. vector<const vector<string>* > answers;
  325. vector<const vector<string>* > signatures;
  326. types.push_back(expected_type);
  327. ttls.push_back(expected_rrttl);
  328. answers.push_back(&expected_data);
  329. signatures.push_back(expected_sig_data);
  330. checkFind(mode, data_source, expected_name, zone_name, qclass,
  331. expected_class, expected_type, ttls, expected_flags, types,
  332. answers, signatures);
  333. }
  334. TEST_F(Sqlite3DataSourceTest, close) {
  335. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  336. }
  337. TEST_F(Sqlite3DataSourceTest, reOpen) {
  338. // Replace the data with a totally different zone. This should succeed,
  339. // and shouldn't match any names in the previously managed domains.
  340. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  341. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE2));
  342. DataSrcMatch match(www_name, rrclass);
  343. data_source.findClosestEnclosure(match);
  344. EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
  345. EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
  346. }
  347. TEST_F(Sqlite3DataSourceTest, openFail) {
  348. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  349. EXPECT_THROW(data_source.init(SQLITE_DBFILE_NOTEXIST), Sqlite3Error);
  350. }
  351. TEST_F(Sqlite3DataSourceTest, doubleOpen) {
  352. // An attempt of duplicate open should trigger an exception.
  353. EXPECT_THROW(data_source.init(SQLITE_DBFILE_EXAMPLE), DataSourceError);
  354. }
  355. TEST_F(Sqlite3DataSourceTest, doubleClose) {
  356. // An attempt of duplicate close should trigger an exception.
  357. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  358. EXPECT_THROW(data_source.close(), DataSourceError);
  359. }
  360. TEST_F(Sqlite3DataSourceTest, openBrokenDB) {
  361. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  362. // The database exists but is broken. An exception will be thrown
  363. // in the middle of the initialization.
  364. EXPECT_THROW(data_source.init(SQLITE_DBFILE_BROKENDB), Sqlite3Error);
  365. // Confirming the strong exception guarantee: the data source must be
  366. // in the closed state.
  367. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE));
  368. }
  369. // This test only confirms that on-the-fly schema creation works.
  370. TEST_F(Sqlite3DataSourceTest, memoryDB) {
  371. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  372. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_MEMORY));
  373. }
  374. TEST_F(Sqlite3DataSourceTest, findClosestEnclosure) {
  375. DataSrcMatch match(www_name, rrclass);
  376. data_source.findClosestEnclosure(match);
  377. EXPECT_EQ(zone_name, *match.getEnclosingZone());
  378. EXPECT_EQ(&data_source, match.getDataSource());
  379. }
  380. TEST_F(Sqlite3DataSourceTest, findClosestEnclosureMatchRoot) {
  381. EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
  382. EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE_ROOT));
  383. DataSrcMatch match(Name("org."), rrclass);
  384. data_source.findClosestEnclosure(match);
  385. EXPECT_EQ(Name("."), *match.getEnclosingZone());
  386. EXPECT_EQ(&data_source, match.getDataSource());
  387. }
  388. TEST_F(Sqlite3DataSourceTest, findClosestEnclosureAtDelegation) {
  389. // The search name exists both in the parent and child zones, but
  390. // child has a better match.
  391. DataSrcMatch match(child_name, rrclass);
  392. data_source.findClosestEnclosure(match);
  393. EXPECT_EQ(child_name, *match.getEnclosingZone());
  394. EXPECT_EQ(&data_source, match.getDataSource());
  395. }
  396. TEST_F(Sqlite3DataSourceTest, findClosestEnclosureNoMatch) {
  397. DataSrcMatch match(nomatch_name, rrclass);
  398. data_source.findClosestEnclosure(match);
  399. EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
  400. EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
  401. }
  402. TEST_F(Sqlite3DataSourceTest, findClosestClassMismatch) {
  403. DataSrcMatch match(nomatch_name, rrclass);
  404. data_source.findClosestEnclosure(match);
  405. EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
  406. EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
  407. }
  408. // If the query class is ANY, the result should be the same as the case where
  409. // the class exactly matches.
  410. TEST_F(Sqlite3DataSourceTest, findClosestClassAny) {
  411. DataSrcMatch match(www_name, RRClass::ANY());
  412. data_source.findClosestEnclosure(match);
  413. EXPECT_EQ(zone_name, *match.getEnclosingZone());
  414. EXPECT_EQ(&data_source, match.getDataSource());
  415. }
  416. TEST_F(Sqlite3DataSourceTest, findRRsetNormal) {
  417. // Without specifying the zone name, and then with the zone name
  418. checkFind(NORMAL, data_source, www_name, NULL, rrclass, rrclass, rrtype,
  419. rrttl, 0, common_a_data, &common_sig_data);
  420. checkFind(NORMAL, data_source, www_name, &zone_name, rrclass, rrclass,
  421. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  422. // With a zone name that doesn't match
  423. EXPECT_EQ(DataSrc::SUCCESS,
  424. data_source.findRRset(www_name, rrclass, rrtype,
  425. result_sets, find_flags, &nomatch_name));
  426. EXPECT_EQ(DataSrc::NO_SUCH_ZONE, find_flags);
  427. EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
  428. }
  429. TEST_F(Sqlite3DataSourceTest, findRRsetClassMismatch) {
  430. EXPECT_EQ(DataSrc::ERROR,
  431. data_source.findRRset(www_name, rrclass_notmatch, rrtype,
  432. result_sets, find_flags, NULL));
  433. }
  434. TEST_F(Sqlite3DataSourceTest, findRRsetClassAny) {
  435. checkFind(NORMAL, data_source, www_name, NULL, RRClass::ANY(), rrclass,
  436. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  437. }
  438. TEST_F(Sqlite3DataSourceTest, findRRsetClassClassAny) {
  439. checkFind(NORMAL, data_source, www_name, NULL, RRClass::ANY(), rrclass,
  440. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  441. }
  442. TEST_F(Sqlite3DataSourceTest, findRRsetNormalANY) {
  443. types.push_back(RRType::A());
  444. types.push_back(RRType::NSEC());
  445. ttls.push_back(RRTTL(3600));
  446. ttls.push_back(RRTTL(7200));
  447. answers.push_back(&common_a_data);
  448. answers.push_back(&www_nsec_data);
  449. signatures.push_back(&common_sig_data);
  450. signatures.push_back(&www_nsec_sig_data);
  451. rrtype = RRType::ANY();
  452. checkFind(NORMAL, data_source, www_name, NULL, rrclass, rrclass, rrtype,
  453. ttls, 0, types, answers, signatures);
  454. checkFind(NORMAL, data_source, www_name, &zone_name, rrclass, rrclass,
  455. rrtype, ttls, 0, types, answers, signatures);
  456. }
  457. // Case insensitive lookup
  458. TEST_F(Sqlite3DataSourceTest, findRRsetNormalCase) {
  459. checkFind(NORMAL, data_source, www_upper_name, NULL, rrclass, rrclass,
  460. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  461. checkFind(NORMAL, data_source, www_upper_name, &zone_name, rrclass, rrclass,
  462. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  463. EXPECT_EQ(DataSrc::SUCCESS,
  464. data_source.findRRset(www_upper_name, rrclass, rrtype,
  465. result_sets, find_flags, &nomatch_name));
  466. EXPECT_EQ(DataSrc::NO_SUCH_ZONE, find_flags);
  467. EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
  468. }
  469. TEST_F(Sqlite3DataSourceTest, findRRsetApexNS) {
  470. rrtype = RRType::NS();
  471. checkFind(NORMAL, data_source, zone_name, NULL, rrclass, rrclass, rrtype,
  472. rrttl, DataSrc::REFERRAL, apex_ns_data, &apex_ns_sig_data);
  473. checkFind(NORMAL, data_source, zone_name, &zone_name, rrclass, rrclass,
  474. rrtype, rrttl, DataSrc::REFERRAL, apex_ns_data,
  475. &apex_ns_sig_data);
  476. EXPECT_EQ(DataSrc::SUCCESS,
  477. data_source.findRRset(zone_name, rrclass, rrtype,
  478. result_sets, find_flags, &nomatch_name));
  479. EXPECT_EQ(DataSrc::NO_SUCH_ZONE, find_flags);
  480. EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
  481. }
  482. TEST_F(Sqlite3DataSourceTest, findRRsetApexANY) {
  483. types.push_back(RRType::SOA());
  484. types.push_back(RRType::NS());
  485. types.push_back(RRType::MX());
  486. types.push_back(RRType::NSEC());
  487. types.push_back(RRType::DNSKEY());
  488. ttls.push_back(rrttl); // SOA TTL
  489. ttls.push_back(rrttl); // NS TTL
  490. ttls.push_back(rrttl); // MX TTL
  491. ttls.push_back(RRTTL(7200)); // NSEC TTL
  492. ttls.push_back(rrttl); // DNSKEY TTL
  493. answers.push_back(&apex_soa_data);
  494. answers.push_back(&apex_ns_data);
  495. answers.push_back(&apex_mx_data);
  496. answers.push_back(&apex_nsec_data);
  497. answers.push_back(&apex_dnskey_data);
  498. signatures.push_back(&apex_soa_sig_data);
  499. signatures.push_back(&apex_ns_sig_data);
  500. signatures.push_back(&apex_mx_sig_data);
  501. signatures.push_back(&apex_nsec_sig_data);
  502. signatures.push_back(&apex_dnskey_sig_data);
  503. rrtype = RRType::ANY();
  504. // there is an NS at the zone apex, so the REFERRAL flag should
  505. // be set, but will ordinarily be ignored by the caller
  506. checkFind(NORMAL, data_source, zone_name, NULL, rrclass, rrclass, rrtype,
  507. ttls, DataSrc::REFERRAL, types, answers, signatures);
  508. checkFind(NORMAL, data_source, zone_name, &zone_name, rrclass, rrclass,
  509. rrtype, ttls, DataSrc::REFERRAL, types, answers, signatures);
  510. }
  511. TEST_F(Sqlite3DataSourceTest, findRRsetMixedANY) {
  512. // ANY query for mixed order RRs
  513. const Name qname("mix.example.com");
  514. types.push_back(RRType::A());
  515. types.push_back(RRType::AAAA());
  516. ttls.push_back(rrttl);
  517. ttls.push_back(rrttl);
  518. answers.push_back(&mix_a_data);
  519. answers.push_back(&mix_aaaa_data);
  520. signatures.push_back(NULL);
  521. signatures.push_back(NULL);
  522. rrtype = RRType::ANY();
  523. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  524. rrtype, ttls, 0, types, answers, signatures);
  525. }
  526. TEST_F(Sqlite3DataSourceTest, findRRsetApexNXRRSET) {
  527. rrtype = RRType::AAAA();
  528. EXPECT_EQ(DataSrc::SUCCESS,
  529. data_source.findRRset(zone_name, rrclass, rrtype,
  530. result_sets, find_flags, &zone_name));
  531. // there's an NS RRset at the apex name, so the REFERRAL flag should be
  532. // set, too.
  533. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  534. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  535. // Same test, without specifying the zone name
  536. EXPECT_EQ(DataSrc::SUCCESS,
  537. data_source.findRRset(zone_name, rrclass, rrtype,
  538. result_sets, find_flags, NULL));
  539. // there's an NS RRset at the apex name, so the REFERRAL flag should be
  540. // set, too.
  541. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  542. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  543. }
  544. // Matching a wildcard node. There's nothing special for the data source API
  545. // point of view, but perform minimal tests anyway.
  546. TEST_F(Sqlite3DataSourceTest, findRRsetWildcard) {
  547. const Name qname("*.wild.example.com");
  548. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  549. rrtype, rrttl, 0, wild_a_data, &common_sig_data);
  550. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  551. rrtype, rrttl, 0, wild_a_data, &common_sig_data);
  552. }
  553. TEST_F(Sqlite3DataSourceTest, findRRsetEmptyNode) {
  554. // foo.bar.example.com exists, but bar.example.com doesn't have any data.
  555. const Name qname("bar.example.com");
  556. EXPECT_EQ(DataSrc::SUCCESS,
  557. data_source.findRRset(qname, rrclass, rrtype,
  558. result_sets, find_flags, NULL));
  559. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  560. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  561. EXPECT_EQ(DataSrc::SUCCESS,
  562. data_source.findRRset(qname, rrclass, rrtype,
  563. result_sets, find_flags, &zone_name));
  564. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  565. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  566. }
  567. // There's nothing special about DNAME lookup for the data source API
  568. // point of view, but perform minimal tests anyway.
  569. TEST_F(Sqlite3DataSourceTest, findRRsetDNAME) {
  570. const Name qname("dname.example.com");
  571. rrtype = RRType::DNAME();
  572. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  573. rrtype, rrttl, 0, dname_data, &dname_sig_data);
  574. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  575. rrtype, rrttl, 0, dname_data, &dname_sig_data);
  576. }
  577. TEST_F(Sqlite3DataSourceTest, findRRsetCNAME) {
  578. const Name qname("foo.example.com");
  579. // This qname only has the CNAME (+ sigs). CNAME query is not different
  580. // from ordinary queries.
  581. rrtype = RRType::CNAME();
  582. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  583. rrtype, rrttl, 0, cname_data, &cname_sig_data);
  584. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  585. rrtype, rrttl, 0, cname_data, &cname_sig_data);
  586. // queries for (ordinary) different RR types that match the CNAME.
  587. // CNAME_FOUND flag is set, and the CNAME RR is returned instead of A
  588. rrtype = RRType::A();
  589. types.push_back(RRType::CNAME());
  590. ttls.push_back(rrttl);
  591. answers.push_back(&cname_data);
  592. signatures.push_back(&cname_sig_data);
  593. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  594. rrtype, ttls, DataSrc::CNAME_FOUND, types, answers, signatures);
  595. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  596. rrtype, ttls, DataSrc::CNAME_FOUND, types, answers, signatures);
  597. // NSEC query that match the CNAME.
  598. // CNAME_FOUND flag is NOT set, and the NSEC RR is returned instead of
  599. // CNAME.
  600. rrtype = RRType::NSEC();
  601. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  602. rrtype, RRTTL(7200), 0, cname_nsec_data, &cname_nsec_sig_data);
  603. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  604. rrtype, RRTTL(7200), 0, cname_nsec_data, &cname_nsec_sig_data);
  605. }
  606. TEST_F(Sqlite3DataSourceTest, findRRsetDelegation) {
  607. const Name qname("www.subzone.example.com");
  608. // query for a name under a zone cut. From the data source API point
  609. // of view this is no different than "NXDOMAIN".
  610. EXPECT_EQ(DataSrc::SUCCESS,
  611. data_source.findRRset(qname, rrclass, rrtype,
  612. result_sets, find_flags, NULL));
  613. EXPECT_EQ(DataSrc::NAME_NOT_FOUND, find_flags);
  614. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  615. }
  616. TEST_F(Sqlite3DataSourceTest, findRRsetDelegationAtZoneCut) {
  617. const Name qname("subzone.example.com");
  618. // query for a name *at* a zone cut. It matches the NS RRset for the
  619. // delegation.
  620. // For non-NS ordinary queries, "no type" should be set too, and no RRset is
  621. // returned.
  622. EXPECT_EQ(DataSrc::SUCCESS,
  623. data_source.findRRset(qname, rrclass, rrtype,
  624. result_sets, find_flags, NULL));
  625. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  626. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  627. EXPECT_EQ(DataSrc::SUCCESS,
  628. data_source.findRRset(qname, rrclass, rrtype,
  629. result_sets, find_flags, &zone_name));
  630. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND | DataSrc::REFERRAL, find_flags);
  631. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  632. // For NS query, RRset is returned with the REFERRAL flag. No RRSIG should
  633. // be provided.
  634. rrtype = RRType::NS();
  635. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  636. rrtype, rrttl, DataSrc::REFERRAL, delegation_ns_data, NULL);
  637. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  638. rrtype, rrttl, DataSrc::REFERRAL, delegation_ns_data, NULL);
  639. // For ANY query. At the backend data source level, it returns all
  640. // existent records with their RRSIGs, setting the referral flag.
  641. rrtype = RRType::ANY();
  642. types.push_back(RRType::NS());
  643. types.push_back(RRType::NSEC());
  644. types.push_back(RRType::DS());
  645. ttls.push_back(rrttl);
  646. ttls.push_back(RRTTL(7200));
  647. ttls.push_back(rrttl);
  648. answers.push_back(&delegation_ns_data);
  649. answers.push_back(&delegation_nsec_data);
  650. answers.push_back(&delegation_ds_data);
  651. signatures.push_back(NULL);
  652. signatures.push_back(&delegation_nsec_sig_data);
  653. signatures.push_back(&delegation_ds_sig_data);
  654. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  655. rrtype, ttls, DataSrc::REFERRAL, types, answers,
  656. signatures);
  657. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  658. rrtype, ttls, DataSrc::REFERRAL, types, answers,
  659. signatures);
  660. // For NSEC query. At the backend data source level, it returns NSEC+
  661. // RRSIG with the referral flag.
  662. rrtype = RRType::NSEC();
  663. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  664. rrtype, RRTTL(7200), DataSrc::REFERRAL, delegation_nsec_data,
  665. &delegation_nsec_sig_data);
  666. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  667. rrtype, RRTTL(7200), DataSrc::REFERRAL, delegation_nsec_data,
  668. &delegation_nsec_sig_data);
  669. }
  670. TEST_F(Sqlite3DataSourceTest, findRRsetInChildZone) {
  671. const Name qname("www.sql1.example.com");
  672. const Name child_zone_name("sql1.example.com");
  673. // If we don't specify the zone, the data source should identify the
  674. // best matching zone.
  675. checkFind(NORMAL, data_source, qname, NULL, rrclass, rrclass,
  676. rrtype, rrttl, 0, child_a_data, &child_sig_data);
  677. // If we specify the parent zone, it's treated as NXDOMAIN because it's
  678. // under a zone cut.
  679. EXPECT_EQ(DataSrc::SUCCESS,
  680. data_source.findRRset(qname, rrclass, rrtype,
  681. result_sets, find_flags, &zone_name));
  682. EXPECT_EQ(DataSrc::NAME_NOT_FOUND, find_flags);
  683. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  684. // If we specify the child zone, it should be the same as the first case.
  685. checkFind(NORMAL, data_source, qname, &child_zone_name, rrclass, rrclass,
  686. rrtype, rrttl, 0, child_a_data, &child_sig_data);
  687. }
  688. TEST_F(Sqlite3DataSourceTest, findExactRRset) {
  689. // Normal case. No different than findRRset.
  690. checkFind(EXACT, data_source, www_name, &zone_name, rrclass, rrclass,
  691. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  692. }
  693. TEST_F(Sqlite3DataSourceTest, findExactRRsetClassMismatch) {
  694. EXPECT_EQ(DataSrc::ERROR,
  695. data_source.findExactRRset(www_name, rrclass_notmatch, rrtype,
  696. result_sets, find_flags, NULL));
  697. }
  698. TEST_F(Sqlite3DataSourceTest, findExactRRsetClassAny) {
  699. checkFind(EXACT, data_source, www_name, &zone_name, RRClass::ANY(), rrclass,
  700. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  701. }
  702. TEST_F(Sqlite3DataSourceTest, findRRsetNSEC3) {
  703. // Simple NSEC3 tests (more should be added)
  704. string hashstr("1BB7SO0452U1QHL98UISNDD9218GELR5");
  705. const Name nsec3_zonename("sql2.example.com");
  706. EXPECT_EQ(DataSrc::SUCCESS,
  707. data_source.findCoveringNSEC3(nsec3_zonename,
  708. hashstr, result_sets));
  709. RRsetList::iterator it = result_sets.begin();
  710. checkRRset(*it, Name(hashstr).concatenate(nsec3_zonename), rrclass,
  711. RRType::NSEC3(), RRTTL(7200), nsec3_data, &nsec3_sig_data);
  712. ++it;
  713. EXPECT_TRUE(it == result_sets.end());
  714. }
  715. TEST_F(Sqlite3DataSourceTest, findExactRRsetCNAME) {
  716. const Name qname("foo.example.com");
  717. // This qname only has the CNAME (+ sigs). In this case it should be
  718. // no different than findRRset for CNAME query.
  719. rrtype = RRType::CNAME();
  720. checkFind(NORMAL, data_source, qname, &zone_name, rrclass, rrclass,
  721. rrtype, rrttl, 0, cname_data, &cname_sig_data);
  722. // queries for (ordinary) different RR types that match the CNAME.
  723. // "type not found" set, but CNAME and its sig are returned (awkward,
  724. // but that's how it currently works).
  725. rrtype = RRType::A();
  726. types.push_back(RRType::CNAME());
  727. ttls.push_back(rrttl);
  728. answers.push_back(&cname_data);
  729. signatures.push_back(&cname_sig_data);
  730. checkFind(EXACT, data_source, qname, &zone_name, rrclass, rrclass,
  731. rrtype, ttls, DataSrc::TYPE_NOT_FOUND, types, answers,
  732. signatures);
  733. }
  734. void
  735. Sqlite3DataSourceTest::findReferralRRsetCommon(const Name& qname,
  736. const RRClass& qclass)
  737. {
  738. types.push_back(RRType::NS());
  739. types.push_back(RRType::DS());
  740. ttls.push_back(rrttl);
  741. ttls.push_back(rrttl);
  742. answers.push_back(&apex_ns_data);
  743. answers.push_back(&child_ds_data);
  744. signatures.push_back(NULL);
  745. signatures.push_back(&child_ds_sig_data);
  746. // Note: zone_name matters here because we need to perform the search
  747. // in the parent zone.
  748. checkFind(REFERRAL, data_source, qname, &zone_name, qclass, rrclass,
  749. rrtype, ttls, DataSrc::REFERRAL, types, answers, signatures);
  750. }
  751. TEST_F(Sqlite3DataSourceTest, findReferralRRset) {
  752. // A referral lookup searches for NS, DS, or DNAME, or their sigs.
  753. const Name qname("sql1.example.com");
  754. findReferralRRsetCommon(qname, rrclass);
  755. }
  756. TEST_F(Sqlite3DataSourceTest, findReferralRRsetClassMismatch) {
  757. EXPECT_EQ(DataSrc::ERROR,
  758. data_source.findReferral(www_name, rrclass_notmatch, result_sets,
  759. find_flags, NULL));
  760. }
  761. TEST_F(Sqlite3DataSourceTest, findReferralRRsetClassAny) {
  762. const Name qname("sql1.example.com");
  763. findReferralRRsetCommon(qname, RRClass::ANY());
  764. }
  765. TEST_F(Sqlite3DataSourceTest, findReferralRRsetDNAME) {
  766. // same as above. the DNAME case.
  767. const Name qname("dname.example.com");
  768. checkFind(REFERRAL, data_source, qname, &zone_name, rrclass, rrclass,
  769. RRType::DNAME(), rrttl, 0, dname_data, &dname_sig_data);
  770. }
  771. TEST_F(Sqlite3DataSourceTest, findReferralRRsetFail) {
  772. // qname has not "referral" records. the result should be "empty".
  773. EXPECT_EQ(DataSrc::SUCCESS,
  774. data_source.findReferral(www_name, rrclass,
  775. result_sets, find_flags, &zone_name));
  776. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  777. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  778. }
  779. void
  780. Sqlite3DataSourceTest::findAddressRRsetCommon(const RRClass& qclass) {
  781. // A referral lookup searches for A or AAAA, or their sigs.
  782. // A-only case
  783. checkFind(ADDRESS, data_source, www_name, &zone_name, qclass, rrclass,
  784. rrtype, rrttl, 0, common_a_data, &common_sig_data);
  785. // AAAA-only case
  786. checkFind(ADDRESS, data_source, Name("ip6.example.com"), &zone_name,
  787. qclass, rrclass, RRType::AAAA(), rrttl, 0, common_aaaa_data,
  788. &common_aaaa_sig_data);
  789. // Dual-stack
  790. types.push_back(RRType::A());
  791. ttls.push_back(rrttl);
  792. answers.push_back(&common_a_data);
  793. signatures.push_back(&common_sig_data);
  794. types.push_back(RRType::AAAA());
  795. ttls.push_back(rrttl);
  796. answers.push_back(&common_aaaa_data);
  797. signatures.push_back(&common_aaaa_sig_data);
  798. checkFind(ADDRESS, data_source, Name("ip46.example.com"), &zone_name,
  799. rrclass, rrclass, rrtype, ttls, 0, types, answers, signatures);
  800. // The qname doesn't have no address records.
  801. EXPECT_EQ(DataSrc::SUCCESS,
  802. data_source.findAddrs(Name("text.example.com"), qclass,
  803. result_sets, find_flags, &zone_name));
  804. EXPECT_EQ(DataSrc::TYPE_NOT_FOUND, find_flags);
  805. EXPECT_TRUE(result_sets.begin() == result_sets.end());
  806. }
  807. TEST_F(Sqlite3DataSourceTest, findAddressRRset) {
  808. findAddressRRsetCommon(rrclass);
  809. }
  810. TEST_F(Sqlite3DataSourceTest, findAddressRRsetClassMismatch) {
  811. EXPECT_EQ(DataSrc::ERROR, data_source.findAddrs(www_name, rrclass_notmatch,
  812. result_sets, find_flags,
  813. NULL));
  814. }
  815. TEST_F(Sqlite3DataSourceTest, findAddressRRsetClassAny) {
  816. findAddressRRsetCommon(RRClass::ANY());
  817. }
  818. }