Commit 0a6b0221 authored by Francis Dupont's avatar Francis Dupont Committed by Tomek Mrugalski
Browse files

[fdunparse2] Finished d2 and agent

parent 406bb64b
......@@ -1686,6 +1686,7 @@ AC_CONFIG_FILES([Makefile
src/bin/agent/Makefile
src/bin/agent/tests/Makefile
src/bin/agent/tests/ca_process_tests.sh
src/bin/agent/tests/test_data_files_config.h
src/bin/agent/tests/test_libraries.h
src/bin/d2/Makefile
src/bin/d2/tests/Makefile
......
......@@ -160,29 +160,33 @@ CtrlAgentCfgContext::setControlSocketInfo(const isc::data::ConstElementPtr& cont
ElementPtr
CtrlAgentCfgContext::toElement() const {
ElementPtr result = Element::createMap();
ElementPtr ca = Element::createMap();
// Set http-host
result->set("http-host", Element::create(http_host_));
ca->set("http-host", Element::create(http_host_));
// Set http-port
result->set("http-port",
Element::create(static_cast<int64_t>(http_port_)));
// hooks-libraries
result->set("hooks-libraries", hooks_config_.toElement());
// control-sockets
ca->set("http-port", Element::create(static_cast<int64_t>(http_port_)));
// Set hooks-libraries
ca->set("hooks-libraries", hooks_config_.toElement());
// Set control-sockets
ElementPtr control_sockets = Element::createMap();
// dhcp4-server
// Set dhcp4-server
if (ctrl_sockets_[TYPE_DHCP4]) {
control_sockets->set("dhcp4-server", ctrl_sockets_[TYPE_DHCP4]);
}
// dhcp6-server
// Set dhcp6-server
if (ctrl_sockets_[TYPE_DHCP6]) {
control_sockets->set("dhcp6-server", ctrl_sockets_[TYPE_DHCP6]);
}
// d2-server
// Set d2-server
if (ctrl_sockets_[TYPE_D2]) {
control_sockets->set("d2-server", ctrl_sockets_[TYPE_D2]);
}
result->set("control-sockets", control_sockets);
ca->set("control-sockets", control_sockets);
// Set Control-agent
ElementPtr result = Element::createMap();
result->set("Control-agent", ca);
// Set Logging (not yet)
return (result);
}
......
/ca_unittests
/ca_process_tests.sh
/test_data_files_config.h
/test_libraries.h
......@@ -4,7 +4,10 @@ SHTESTS =
SHTESTS += ca_process_tests.sh
noinst_SCRIPTS = ca_process_tests.sh
EXTRA_DIST = ca_process_tests.sh.in
EXTRA_DIST += testdata/get_config.json
noinst_LTLIBRARIES = libbasic.la
# test using command-line arguments, so use check-local target instead of TESTS
......@@ -50,6 +53,7 @@ ca_unittests_SOURCES += ca_response_creator_unittests.cc
ca_unittests_SOURCES += ca_response_creator_factory_unittests.cc
ca_unittests_SOURCES += ca_unittests.cc
ca_unittests_SOURCES += parser_unittests.cc
ca_unittests_SOURCES += get_config_unittest.cc
ca_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
ca_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
......@@ -87,7 +91,7 @@ libbasic_la_LIBADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
libbasic_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
libbasic_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
nodist_ca_unittests_SOURCES = test_libraries.h
nodist_ca_unittests_SOURCES = test_data_files_config.h test_libraries.h
endif
......
{
"Control-agent": {
"control-sockets": {
"d2-server": {
"socket-name": "/path/to/the/unix/socket-d2",
"socket-type": "unix"
},
"dhcp4-server": {
"socket-name": "/path/to/the/unix/socket-v4",
"socket-type": "unix"
},
"dhcp6-server": {
"socket-name": "/path/to/the/unix/socket-v6",
"socket-type": "unix"
}
},
"hooks-libraries": [
{
"library": "/tmp/kea/src/bin/agent/tests/.libs/libbasic.so",
"parameters": {
"param1": "foo"
}
}
],
"http-host": "localhost",
"http-port": 8000
}
}
......@@ -9,12 +9,14 @@
#include <d2/d2_simple_parser.h>
#include <d2/tests/parser_unittest.h>
#include <cc/data.h>
#include <testutils/test_to_element.h>
#include <boost/lexical_cast.hpp>
using namespace isc;
using namespace isc::data;
using namespace isc::d2;
using namespace isc::test;
namespace {
......@@ -659,6 +661,9 @@ TEST_F(TSIGKeyInfoParserTest, validEntry) {
// Verify the key contents.
EXPECT_TRUE(checkKey(key_, "d2_key_one", "HMAC-MD5",
"dGhpcyBrZXkgd2lsbCBtYXRjaA==", 120));
// Verify unparsing.
runToElementTest<TSIGKeyInfo>(config, *key_);
}
/// @brief Verifies that attempting to parse an invalid list of TSIGKeyInfo
......@@ -880,6 +885,9 @@ TEST_F(DnsServerInfoParserTest, validEntry) {
ASSERT_TRUE(server_);
EXPECT_TRUE(checkServer(server_, "", "127.0.0.1", 100));
// Verify unparsing.
runToElementTest<DnsServerInfo>(config, *server_);
// Valid entries for static ip, no port
// This will fail without invoking set defaults
config = " { \"ip-address\": \"192.168.2.5\" }";
......@@ -1022,6 +1030,21 @@ TEST_F(DdnsDomainParserTest, validDomain) {
EXPECT_TRUE(server);
EXPECT_TRUE(checkServer(server, "", "127.0.0.3", 300));
// Verify unparsing.
ElementPtr json;
ASSERT_NO_THROW(json = Element::fromJSON(config));
ConstElementPtr servers_json;
ASSERT_NO_THROW(servers_json = json->get("dns-servers"));
ASSERT_TRUE(servers_json);
ASSERT_EQ(Element::list, servers_json->getType());
for (size_t i = 0; i < servers_json->size(); ++i) {
ElementPtr server_json;
ASSERT_NO_THROW(server_json = servers_json->getNonConst(i));
ASSERT_NO_THROW(server_json->set("hostname",
Element::create(std::string())));
}
runToElementTest<DdnsDomain>(json, *domain_);
}
/// @brief Tests the fundamentals of parsing DdnsDomain lists.
......@@ -1146,4 +1169,3 @@ TEST_F(DdnsDomainListParserTest, duplicateDomain) {
}
};
......@@ -11,7 +11,7 @@
#include <process/testutils/d_test_stubs.h>
#include <d2/d2_config.h>
#include <d2/d2_cfg_mgr.h>
#include <d2/tests/parser_unittest.h>
#include <d2/parser_context.h>
#include <gtest/gtest.h>
#include <iostream>
......
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