|
@@ -72,32 +72,6 @@ private:
|
|
|
isc::testutils::TestSocketRequestor sock_requestor_;
|
|
|
};
|
|
|
|
|
|
-TEST_F(AuthConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_datasourceConfig
|
|
|
-#else
|
|
|
- datasourceConfig
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- // By default, we don't have any in-memory data source.
|
|
|
- EXPECT_FALSE(server.hasInMemoryClient());
|
|
|
- configureAuthServer(server, Element::fromJSON(
|
|
|
- "{\"datasources\": [{\"type\": \"memory\"}]}"));
|
|
|
- // after successful configuration, we should have one (with empty zoneset).
|
|
|
- EXPECT_TRUE(server.hasInMemoryClient());
|
|
|
- EXPECT_EQ(0, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(AuthConfigTest, databaseConfig) {
|
|
|
- // right now, "database_file" is handled separately, so the parser
|
|
|
- // doesn't recognize it, but it shouldn't throw an exception due to that.
|
|
|
- EXPECT_NO_THROW(configureAuthServer(
|
|
|
- server,
|
|
|
- Element::fromJSON(
|
|
|
- "{\"database_file\": \"should_be_ignored\"}")));
|
|
|
-}
|
|
|
-
|
|
|
TEST_F(AuthConfigTest, versionConfig) {
|
|
|
// make sure it does not throw on 'version'
|
|
|
EXPECT_NO_THROW(configureAuthServer(
|
|
@@ -112,28 +86,12 @@ TEST_F(AuthConfigTest, exceptionGuarantee) {
|
|
|
EXPECT_THROW(configureAuthServer(
|
|
|
server,
|
|
|
Element::fromJSON(
|
|
|
- "{\"datasources\": [{\"type\": \"memory\"}], "
|
|
|
- " \"no_such_config_var\": 1}")),
|
|
|
+ "{ \"no_such_config_var\": 1}")),
|
|
|
AuthConfigError);
|
|
|
// The server state shouldn't change
|
|
|
EXPECT_FALSE(server.hasInMemoryClient());
|
|
|
}
|
|
|
|
|
|
-TEST_F(AuthConfigTest, exceptionConversion) {
|
|
|
- // This configuration contains a bogus RR class, which will trigger an
|
|
|
- // exception from libdns++. configureAuthServer() should convert this
|
|
|
- // to AuthConfigError and rethrow the converted one.
|
|
|
- EXPECT_THROW(configureAuthServer(
|
|
|
- server,
|
|
|
- Element::fromJSON(
|
|
|
- "{\"datasources\": "
|
|
|
- " [{\"type\": \"memory\","
|
|
|
- " \"class\": \"BADCLASS\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"example.zone\"}]}]}")),
|
|
|
- AuthConfigError);
|
|
|
-}
|
|
|
-
|
|
|
TEST_F(AuthConfigTest, badConfig) {
|
|
|
// These should normally not happen, but should be handled to avoid
|
|
|
// an unexpected crash due to a bug of the caller.
|
|
@@ -172,343 +130,6 @@ TEST_F(AuthConfigTest, listenAddressConfig) {
|
|
|
EXPECT_EQ(DNSService::SERVER_SYNC_OK, dnss_.getUDPFdParams().at(1).options);
|
|
|
}
|
|
|
|
|
|
-class MemoryDatasrcConfigTest : public AuthConfigTest {
|
|
|
-protected:
|
|
|
- MemoryDatasrcConfigTest() :
|
|
|
- parser(createAuthConfigParser(server, "datasources"))
|
|
|
- {}
|
|
|
- ~MemoryDatasrcConfigTest() {
|
|
|
- delete parser;
|
|
|
- }
|
|
|
- AuthConfigParser* parser;
|
|
|
-};
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest, addZeroDataSrc) {
|
|
|
- parser->build(Element::fromJSON("[]"));
|
|
|
- parser->commit();
|
|
|
- EXPECT_FALSE(server.hasInMemoryClient());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_addEmpty
|
|
|
-#else
|
|
|
- addEmpty
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- // By default, we don't have any in-memory data source.
|
|
|
- EXPECT_FALSE(server.hasInMemoryClient());
|
|
|
- parser->build(Element::fromJSON("[{\"type\": \"memory\"}]"));
|
|
|
- parser->commit();
|
|
|
- EXPECT_EQ(0, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_addZeroZone
|
|
|
-#else
|
|
|
- addZeroZone
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- parser->build(Element::fromJSON("[{\"type\": \"memory\","
|
|
|
- " \"zones\": []}]"));
|
|
|
- parser->commit();
|
|
|
- EXPECT_EQ(0, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_addOneZone
|
|
|
-#else
|
|
|
- addOneZone
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.zone\"}]}]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
- // Check it actually loaded something
|
|
|
- EXPECT_EQ(ZoneFinder::SUCCESS, server.getInMemoryClient(rrclass)->findZone(
|
|
|
- Name("ns.example.com.")).zone_finder->find(Name("ns.example.com."),
|
|
|
- RRType::A())->code);
|
|
|
-}
|
|
|
-
|
|
|
-// This test uses dynamic load of a data source module, and won't work when
|
|
|
-// statically linked.
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_addOneWithFiletypeSQLite3
|
|
|
-#else
|
|
|
- addOneWithFiletypeSQLite3
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- const string test_db = TEST_DATA_BUILDDIR "/auth_test.sqlite3.copied";
|
|
|
- stringstream ss("example.org. 3600 IN SOA . . 0 0 0 0 0\n");
|
|
|
- createSQLite3DB(rrclass, Name("example.org"), test_db.c_str(), ss);
|
|
|
-
|
|
|
- // In-memory with an SQLite3 data source as the backend.
|
|
|
- parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.org\","
|
|
|
- " \"file\": \""
|
|
|
- + test_db + "\","
|
|
|
- " \"filetype\": \"sqlite3\"}]}]"));
|
|
|
- parser->commit();
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-
|
|
|
- // Failure case: the specified zone doesn't exist in the DB file.
|
|
|
- delete parser;
|
|
|
- parser = createAuthConfigParser(server, "datasources");
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \""
|
|
|
- + test_db + "\","
|
|
|
- " \"filetype\": \"sqlite3\"}]}]")),
|
|
|
- DataSourceError);
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_addOneWithFiletypeText
|
|
|
-#else
|
|
|
- addOneWithFiletypeText
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- // Explicitly specifying "text" is okay.
|
|
|
- parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \""
|
|
|
- TEST_DATA_DIR "/example.zone\","
|
|
|
- " \"filetype\": \"text\"}]}]"));
|
|
|
- parser->commit();
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_addMultiZones
|
|
|
-#else
|
|
|
- addMultiZones
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.zone\"},"
|
|
|
- " {\"origin\": \"example.org\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.org.zone\"},"
|
|
|
- " {\"origin\": \"example.net\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.net.zone\"}]}]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_EQ(3, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_replace
|
|
|
-#else
|
|
|
- replace
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.zone\"}]}]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
- EXPECT_EQ(isc::datasrc::result::SUCCESS,
|
|
|
- server.getInMemoryClient(rrclass)->findZone(
|
|
|
- Name("example.com")).code);
|
|
|
-
|
|
|
- // create a new parser, and install a new set of configuration. It
|
|
|
- // should replace the old one.
|
|
|
- delete parser;
|
|
|
- parser = createAuthConfigParser(server, "datasources");
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.org\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.org.zone\"},"
|
|
|
- " {\"origin\": \"example.net\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.net.zone\"}]}]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_EQ(2, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
- EXPECT_EQ(isc::datasrc::result::NOTFOUND,
|
|
|
- server.getInMemoryClient(rrclass)->findZone(
|
|
|
- Name("example.com")).code);
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_exception
|
|
|
-#else
|
|
|
- exception
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- // Load a zone
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.zone\"}]}]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
- EXPECT_EQ(isc::datasrc::result::SUCCESS,
|
|
|
- server.getInMemoryClient(rrclass)->findZone(
|
|
|
- Name("example.com")).code);
|
|
|
-
|
|
|
- // create a new parser, and try to load something. It will throw,
|
|
|
- // the given master file should not exist
|
|
|
- delete parser;
|
|
|
- parser = createAuthConfigParser(server, "datasources");
|
|
|
- EXPECT_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.org\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.org.zone\"},"
|
|
|
- " {\"origin\": \"example.net\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/nonexistent.zone\"}]}]")),
|
|
|
- isc::datasrc::DataSourceError);
|
|
|
- // As that one throwed exception, it is not expected from us to
|
|
|
- // commit it
|
|
|
-
|
|
|
- // The original should be untouched
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
- EXPECT_EQ(isc::datasrc::result::SUCCESS,
|
|
|
- server.getInMemoryClient(rrclass)->findZone(
|
|
|
- Name("example.com")).code);
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_remove
|
|
|
-#else
|
|
|
- remove
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.zone\"}]}]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
|
|
-
|
|
|
- delete parser;
|
|
|
- parser = createAuthConfigParser(server, "datasources");
|
|
|
- EXPECT_NO_THROW(parser->build(Element::fromJSON("[]")));
|
|
|
- EXPECT_NO_THROW(parser->commit());
|
|
|
- EXPECT_FALSE(server.hasInMemoryClient());
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest, addDuplicateZones) {
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.zone\"},"
|
|
|
- " {\"origin\": \"example.com\","
|
|
|
- " \"file\": \"" TEST_DATA_DIR
|
|
|
- "/example.com.zone\"}]}]")),
|
|
|
- DataSourceError);
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest, addBadZone) {
|
|
|
- // origin and file are missing
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{}]}]")),
|
|
|
- DataSourceError);
|
|
|
-
|
|
|
- // origin is missing
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"file\": \"example.zone\"}]}]")),
|
|
|
- DataSourceError);
|
|
|
-
|
|
|
- // file is missing
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\"}]}]")),
|
|
|
- DataSourceError);
|
|
|
-
|
|
|
- // missing zone file
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\"}]}]")),
|
|
|
- DataSourceError);
|
|
|
-
|
|
|
- // bogus origin name
|
|
|
- EXPECT_THROW(parser->build(Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"zones\": [{\"origin\": \"example..com\","
|
|
|
- " \"file\": \"example.zone\"}]}]")),
|
|
|
- DataSourceError);
|
|
|
-
|
|
|
- // bogus RR class name
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"class\": \"BADCLASS\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"example.zone\"}]}]")),
|
|
|
- InvalidRRClass);
|
|
|
-
|
|
|
- // valid RR class, but not currently supported
|
|
|
- EXPECT_THROW(parser->build(
|
|
|
- Element::fromJSON(
|
|
|
- "[{\"type\": \"memory\","
|
|
|
- " \"class\": \"CH\","
|
|
|
- " \"zones\": [{\"origin\": \"example.com\","
|
|
|
- " \"file\": \"example.zone\"}]}]")),
|
|
|
- isc::InvalidParameter);
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(MemoryDatasrcConfigTest,
|
|
|
-#ifdef USE_STATIC_LINK
|
|
|
- DISABLED_badDatasrcType
|
|
|
-#else
|
|
|
- badDatasrcType
|
|
|
-#endif
|
|
|
- )
|
|
|
-{
|
|
|
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"type\": \"badsrc\"}]")),
|
|
|
- AuthConfigError);
|
|
|
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"notype\": \"memory\"}]")),
|
|
|
- AuthConfigError);
|
|
|
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"type\": 1}]")),
|
|
|
- isc::data::TypeError);
|
|
|
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"type\": \"memory\"},"
|
|
|
- " {\"type\": \"memory\"}]")),
|
|
|
- AuthConfigError);
|
|
|
-}
|
|
|
-
|
|
|
class StatisticsIntervalConfigTest : public AuthConfigTest {
|
|
|
protected:
|
|
|
StatisticsIntervalConfigTest() :
|