2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[1788] extended auth.spec so an inmemory zone has an optional filetype item.

also added a new set of unittests that verify the new spec syntax.
This commit is contained in:
JINMEI Tatuya
2012-04-03 20:47:35 -07:00
parent 8ae80ada66
commit f4489fa39c
3 changed files with 72 additions and 1 deletions

View File

@@ -47,7 +47,13 @@
"item_type": "string", "item_type": "string",
"item_optional": false, "item_optional": false,
"item_default": "" "item_default": ""
}] },
{ "item_name": "filetype",
"item_type": "string",
"item_optional": true,
"item_default": "text"
}
]
} }
}] }]
} }

View File

@@ -3,6 +3,7 @@ AM_CPPFLAGS += -I$(top_builddir)/src/bin # for generated spec_config.h header
AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/bin AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/bin
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DAUTH_OBJ_DIR=\"$(abs_top_builddir)/src/bin/auth\"
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_top_srcdir)/src/lib/testutils/testdata\" AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_top_srcdir)/src/lib/testutils/testdata\"
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/testutils/testdata\" AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/testutils/testdata\"
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
@@ -30,6 +31,7 @@ run_unittests_SOURCES += ../common.h ../common.cc
run_unittests_SOURCES += ../statistics.h ../statistics.cc run_unittests_SOURCES += ../statistics.h ../statistics.cc
run_unittests_SOURCES += auth_srv_unittest.cc run_unittests_SOURCES += auth_srv_unittest.cc
run_unittests_SOURCES += config_unittest.cc run_unittests_SOURCES += config_unittest.cc
run_unittests_SOURCES += config_syntax_unittest.cc
run_unittests_SOURCES += command_unittest.cc run_unittests_SOURCES += command_unittest.cc
run_unittests_SOURCES += common_unittest.cc run_unittests_SOURCES += common_unittest.cc
run_unittests_SOURCES += query_unittest.cc run_unittests_SOURCES += query_unittest.cc

View File

@@ -0,0 +1,63 @@
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <cc/data.h>
#include <config/module_spec.h>
#include <gtest/gtest.h>
using namespace isc::data;
using namespace isc::config;
namespace {
const char* const SPEC_FILE = AUTH_OBJ_DIR "/auth.spec";
class AuthConfigSyntaxTest : public ::testing::Test {
protected:
AuthConfigSyntaxTest() : mspec_(moduleSpecFromFile(SPEC_FILE)),
errors_(Element::createList())
{}
ModuleSpec mspec_;
ElementPtr errors_;
};
TEST_F(AuthConfigSyntaxTest, inmemorySQLite3Backend) {
// Specifying non-default in-memory filetype
EXPECT_TRUE(
mspec_.validateConfig(
Element::fromJSON(
"{\"datasources\": "
" [{\"type\": \"memory\","
" \"zones\": [{\"origin\": \"example.com\","
" \"file\": \""
TEST_DATA_DIR "/example.zone\","
" \"filetype\": \"sqlite3\"}]}]}"),
false, errors_));
}
TEST_F(AuthConfigSyntaxTest, badInmemoryFileType) {
// Filetype must be a string
EXPECT_FALSE(
mspec_.validateConfig(
Element::fromJSON(
"{\"datasources\": "
" [{\"type\": \"memory\","
" \"zones\": [{\"origin\": \"example.com\","
" \"file\": \""
TEST_DATA_DIR "/example.zone\","
" \"filetype\": 42}]}]}"),
false, errors_));
}
}