|
@@ -106,6 +106,8 @@ public:
|
|
|
type_(type),
|
|
|
configuration_(configuration)
|
|
|
{
|
|
|
+ EXPECT_NE("MasterFiles", type) << "MasterFiles is a special case "
|
|
|
+ "and it never should be created as a data source client";
|
|
|
if (configuration_->getType() == Element::list) {
|
|
|
for (size_t i(0); i < configuration_->size(); ++i) {
|
|
|
zones.insert(Name(configuration_->get(i)->stringValue()));
|
|
@@ -501,6 +503,47 @@ TEST_F(ListTest, wrongConfig) {
|
|
|
"{\"type\": \"x\", \"cache-enable\": true, \"cache-zones\": 13}]",
|
|
|
"[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
"{\"type\": \"x\", \"cache-enable\": true, \"cache-zones\": {}}]",
|
|
|
+ // Some bad inputs for MasterFiles special case
|
|
|
+
|
|
|
+ // It must have the cache enabled
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": {}}]",
|
|
|
+ // No cache-zones allowed here
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": true,"
|
|
|
+ "\"param\": {}, \"cache-zones\": []}]",
|
|
|
+ // Some bad types of params
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": []}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": 13}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": true}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": null}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": \"x\"}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": {\".\": 13}}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": {\".\": true}}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": {\".\": null}}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": {\".\": []}}]",
|
|
|
+ "[{\"type\": \"test_type\", \"params\": 13}, "
|
|
|
+ "{\"type\": \"MasterFiles\", \"cache-enable\": false,"
|
|
|
+ "\"params\": {\".\": {}}}]",
|
|
|
NULL
|
|
|
};
|
|
|
// Put something inside to see it survives the exception
|
|
@@ -675,4 +718,27 @@ TEST_F(ListTest, badCache) {
|
|
|
checkDS(0, "test_type", "{}", false);
|
|
|
}
|
|
|
|
|
|
+TEST_F(ListTest, masterFiles) {
|
|
|
+ const ConstElementPtr elem(Element::fromJSON("["
|
|
|
+ "{"
|
|
|
+ " \"type\": \"MasterFiles\","
|
|
|
+ " \"cache-enable\": true,"
|
|
|
+ " \"params\": {"
|
|
|
+ " \".\": \"" TEST_DATA_DIR "/root.zone\""
|
|
|
+ " }"
|
|
|
+ "}]"));
|
|
|
+ list_->configure(*elem, true);
|
|
|
+
|
|
|
+ // It has only the cache
|
|
|
+ EXPECT_EQ(NULL, list_->getDataSources()[0].data_src_client_);
|
|
|
+
|
|
|
+ // And it can search
|
|
|
+ positiveResult(list_->find(Name(".")), ds_[0], Name("."), true, "com",
|
|
|
+ true);
|
|
|
+
|
|
|
+ // If cache is not enabled, nothing is loaded
|
|
|
+ list_->configure(*elem, true);
|
|
|
+ EXPECT_EQ(0, list_->getDataSources().size());
|
|
|
+}
|
|
|
+
|
|
|
}
|