Commit 49655910 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[2213] add test for AuthSrv::loadZone()

parent 83a6c441
......@@ -324,7 +324,14 @@ public:
///
/// This method should only be called from the LoadZoneCommand class,
/// internally it will tell the clients builder thread to reload
/// the zone specified in the arguments.
/// the zone specified in the arguments in the background.
///
/// \param args Element argument that should be a map of the form
/// { "class": "IN", "origin": "example.com" }
/// (but class is optional and will default to IN)
///
/// \exception LoadZoneCommandError if the args value is null, or not in
/// the expected format
void loadZone(isc::data::ConstElementPtr args);
private:
......
......@@ -1715,6 +1715,15 @@ namespace {
isc::config::parseAnswer(command_result, response);
EXPECT_EQ(0, command_result);
}
void sendCommand(AuthSrv& server, const std::string& command,
ConstElementPtr args, int expected_result) {
ConstElementPtr response = execAuthServerCommand(server, command,
args);
int command_result = -1;
isc::config::parseAnswer(command_result, response);
EXPECT_EQ(expected_result, command_result);
}
} // end anonymous namespace
TEST_F(AuthSrvTest, DDNSForwardCreateDestroy) {
......@@ -1786,4 +1795,18 @@ TEST_F(AuthSrvTest, DDNSForwardCreateDestroy) {
Opcode::UPDATE().getCode(), QR_FLAG, 0, 0, 0, 0);
}
TEST_F(AuthSrvTest, loadZoneCommand) {
// Just some very basic tests, to check the command is accepted, and that
// it raises on bad arguments, but not on correct ones (full testing
// is handled in the unit tests for the corresponding classes)
// Empty map should fail
ElementPtr args(Element::createMap());
sendCommand(server, "loadzone", args, 1);
// Setting an origin should be enough (even if it isn't actually loaded,
// it should be initially accepted)
args->set("origin", Element::create("example.com"));
sendCommand(server, "loadzone", args, 0);
}
}
......@@ -486,14 +486,6 @@ TEST_F(DataSrcClientsBuilderTest, loadZoneInvalidParams) {
// class or origin is missing: result in assertion failure
if (!isc::util::unittests::runningOnValgrind()) {
/*
EXPECT_DEATH_IF_SUPPORTED({
builder.handleCommand(
Command(LOADZONE,
Element::fromJSON(
"{\"origin\": \"test1.example\"}")));
}, "");
*/
EXPECT_DEATH_IF_SUPPORTED({
builder.handleCommand(Command(LOADZONE,
Element::fromJSON(
......
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