Commit 7f108b1a authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[1793] Tests for the loadzone command

It puts the configuration of the zone (which is loaded from SQLite3
database) and the database at the disposition of the test. Then it asks
it to load the zone and it expects it to load it.
parent a93523df
......@@ -14,6 +14,8 @@
#include <config.h>
#include "datasrc_util.h"
#include <auth/auth_srv.h>
#include <auth/auth_config.h>
#include <auth/command.h>
......@@ -50,8 +52,12 @@ using namespace isc::data;
using namespace isc::datasrc;
using namespace isc::config;
using namespace isc::testutils;
using namespace isc::auth::unittest;
namespace {
const char* const SPEC_FILE = AUTH_OBJ_DIR "/auth.spec";
class AuthCommandTest : public ::testing::Test {
AuthCommandTest() :
......@@ -246,6 +252,65 @@ TEST_F(AuthCommandTest, loadZone) {
// This test uses dynamic load of a data source module, and won't work when
// statically linked.
// Prepare the database first
const string test_db = TEST_DATA_BUILDDIR "/auth_test.sqlite3.copied";
stringstream ss(" 3600 IN SOA . . 0 0 0 0 0\n");
createSQLite3DB(RRClass::IN(), Name(""), test_db.c_str(), ss);
// Then store a config of the zone to the auth server
// This omits many config options of the auth server, but these are
// not read now.
isc::testutils::MockSession session;
// The session should not take care of anything or start anything, we
// need it only to hold the config we're going to put into it.
ModuleCCSession moduleSession(SPEC_FILE, session, NULL, NULL, false,
// This describes the data source in the configuration
ElementPtr map(Element::fromJSON("{\"datasources\": ["
" {"
" \"type\": \"memory\","
" \"zones\": ["
" {"
" \"origin\": \"\","
" \"file\": \"" + test_db + "\","
" \"filetype\": \"sqlite3\""
" }"
" ]"
" }"
// The loadzone command needs the zone to be already loaded, because
// it is used for reloading only
AuthSrv::InMemoryClientPtr dsrc(new InMemoryClient());
dsrc->addZone(ZoneFinderPtr(new InMemoryZoneFinder(RRClass::IN(),
server_.setInMemoryClient(RRClass::IN(), dsrc);
// Now send the command to reload it
result_ = execAuthServerCommand(server_, "loadzone",
Element::fromJSON("{\"origin\": \"\"}"));
// Get the zone and look if there are data in it (the original one was
// empty)
EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
find(Name(""), RRType::SOA())->code);
TEST_F(AuthCommandTest, loadBrokenZone) {
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