mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[1788] reject in-memory file types other than "text" for now.
This commit is contained in:
committed by
Michal 'vorner' Vaner
parent
36ec15a272
commit
00bc99c5a2
@@ -163,7 +163,15 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
|
|||||||
const string file_txt = file ? file->stringValue() : "";
|
const string file_txt = file ? file->stringValue() : "";
|
||||||
if (file_txt.empty()) {
|
if (file_txt.empty()) {
|
||||||
isc_throw(AuthConfigError, "Missing zone file for zone: "
|
isc_throw(AuthConfigError, "Missing zone file for zone: "
|
||||||
<< origin->str());
|
<< origin_txt);
|
||||||
|
}
|
||||||
|
// XXX: we need to hardcode the default, see above.
|
||||||
|
ConstElementPtr filetype = zone_config->get("filetype");
|
||||||
|
const string filetype_txt = filetype ? filetype->stringValue() :
|
||||||
|
"text";
|
||||||
|
if (filetype_txt != "text") {
|
||||||
|
isc_throw(AuthConfigError, "Invalid filetype for zone "
|
||||||
|
<< origin_txt << ": " << filetype_txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: we don't want to have such small try-catch blocks for each
|
// Note: we don't want to have such small try-catch blocks for each
|
||||||
|
@@ -201,13 +201,26 @@ TEST_F(MemoryDatasrcConfigTest, addOneZone) {
|
|||||||
RRType::A())->code);
|
RRType::A())->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MemoryDatasrcConfigTest, addOneSQLite3Zone) {
|
TEST_F(MemoryDatasrcConfigTest, addOneWithFiletype) {
|
||||||
|
// Until #1792 is completed, only "text" filetype is allowed.
|
||||||
|
EXPECT_THROW(parser->build(
|
||||||
|
Element::fromJSON(
|
||||||
|
"[{\"type\": \"memory\","
|
||||||
|
" \"zones\": [{\"origin\": \"example.com\","
|
||||||
|
" \"file\": \""
|
||||||
|
TEST_DATA_DIR "/example.zone\","
|
||||||
|
" \"filetype\": \"sqlite3\"}]}]")),
|
||||||
|
AuthConfigError);
|
||||||
|
|
||||||
|
// Explicitly specifying "text" is okay.
|
||||||
parser->build(Element::fromJSON(
|
parser->build(Element::fromJSON(
|
||||||
"[{\"type\": \"memory\","
|
"[{\"type\": \"memory\","
|
||||||
" \"zones\": [{\"origin\": \"example.com\","
|
" \"zones\": [{\"origin\": \"example.com\","
|
||||||
" \"file\": \""
|
" \"file\": \""
|
||||||
TEST_DATA_DIR "/example.zone\","
|
TEST_DATA_DIR "/example.zone\","
|
||||||
" \"filetype\": \"sqlite3\"}]}]"));
|
" \"filetype\": \"text\"}]}]"));
|
||||||
|
parser->commit();
|
||||||
|
EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MemoryDatasrcConfigTest, addMultiZones) {
|
TEST_F(MemoryDatasrcConfigTest, addMultiZones) {
|
||||||
|
Reference in New Issue
Block a user