Commit 83a6c441 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[2213] command does not need own catch

parent 7b11fd33
......@@ -176,12 +176,8 @@ public:
virtual ConstElementPtr exec(AuthSrv& server,
isc::data::ConstElementPtr args)
{
try {
server.loadZone(args);
return (createAnswer());
} catch (const LoadZoneCommandError& lzce) {
return (createAnswer(1, lzce.what()));
}
server.loadZone(args);
return (createAnswer());
}
};
......
......@@ -267,6 +267,15 @@ public:
isc_throw(LoadZoneCommandError,
"loadZone argument has no 'origin' value");
}
if (args->get("origin")->getType() != data::Element::string) {
isc_throw(LoadZoneCommandError,
"loadZone argument 'origin' value not a string");
}
if (args->contains("class") &&
args->get("class")->getType() != data::Element::string) {
isc_throw(LoadZoneCommandError,
"loadZone argument 'class' value not a string");
}
sendCommand(datasrc_clientmgr_internal::LOADZONE, args);
}
......
......@@ -209,6 +209,11 @@ TEST(DataSrcClientsMgrTest, reload) {
mgr.loadZone(args);
EXPECT_EQ(2, FakeDataSrcClientsBuilder::command_queue->size());
// Should fail with non-string 'class' value
args->set("class", Element::create(1));
EXPECT_THROW(mgr.loadZone(args), LoadZoneCommandError);
EXPECT_EQ(2, FakeDataSrcClientsBuilder::command_queue->size());
// Should succeed without 'class'
args->remove("class");
mgr.loadZone(args);
......@@ -219,6 +224,11 @@ TEST(DataSrcClientsMgrTest, reload) {
EXPECT_THROW(mgr.loadZone(args), LoadZoneCommandError);
EXPECT_EQ(3, FakeDataSrcClientsBuilder::command_queue->size());
// And for 'origin' that is not a string
args->set("origin", Element::create(1));
EXPECT_THROW(mgr.loadZone(args), LoadZoneCommandError);
EXPECT_EQ(3, FakeDataSrcClientsBuilder::command_queue->size());
// same for empty data and data that is not a map
EXPECT_THROW(mgr.loadZone(isc::data::ConstElementPtr()),
LoadZoneCommandError);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment