Browse Source

[1065] Tests for subdomain match in SQLite

Both test where it should match and test where it should not.
Michal 'vorner' Vaner 13 years ago
parent
commit
0c9db8bbeb
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

+ 10 - 0
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

@@ -240,6 +240,16 @@ TEST_F(SQLite3Access, getRecords) {
     checkRecordRow(columns, "RRSIG", "3600", "DNSKEY",
                    "DNSKEY 5 2 3600 20100322084538 20100220084538 "
                    "33495 example.com. FAKEFAKEFAKEFAKE");
+
+    // Try searching for subdomain
+    // There's foo.bar.example.com in the data
+    db->searchForRecords(zone_id, "bar.example.com.", true);
+    EXPECT_TRUE(db->getNextRecord(columns, column_count));
+    checkRecordRow(columns, "A", "3600", "", "192.0.2.1");
+    EXPECT_FALSE(db->getNextRecord(columns, column_count));
+    // But we shouldn't match mix.example.com here
+    db->searchForRecords(zone_id, "ix.example.com.", true);
+    EXPECT_FALSE(db->getNextRecord(columns, column_count));
 }
 
 } // end anonymous namespace