Commit fe79959e authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Finishing merge of trac5495 (comment/user-context for d2 and ca)

parents 5bb69e0a 6240cdb6
1386. [func] fdupont
Extented comment / user-context support to DHCP-DDNS and
Control Agent configuration syntax.
(Trac #5495, git xxx)
1385. [func] tomek
lease4-wipe and lease6-wipe are now able to wipe all leases
from all configured subnets if subnet-id specified is 0
......
// This is an example configuration file for D2, Kea's DHCP-DDNS processor.
// It uses embedded (i.e., which will be included in configuration objects
// and not stripped by at lexical analysis) comments.
// It uses embedded comments which will be included in configuration objects
// within user-contexts rather than stripped away by at lexical analysis.
{
"DhcpDdns":
......
......@@ -257,16 +257,22 @@ TEST_F(CtrlAgentGetCfgTest, simple) {
prettyPrint(unparsed, std::cerr, 0, 4);
std::cerr << "\n";
} else {
// get the expected config using the agent syntax parser
ElementPtr jsond;
ASSERT_NO_THROW(jsond = parseAGENT(expected, true));
// get the expected config using the generic JSON syntax parser
ElementPtr jsonj;
ASSERT_NO_THROW(jsonj = parseJSON(expected));
// the generic JSON parser does not handle comments
EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj)));
// replace the path by its actual value
ConstElementPtr ca;
ASSERT_NO_THROW(ca = jsonj->get("Control-agent"));
ASSERT_TRUE(ca);
pathReplacer(ca);
// check that unparsed and updated expected values match
EXPECT_TRUE(isEquivalent(unparsed, jsonj));
// check on pretty prints too
std::string current = prettyPrint(unparsed, 0, 4);
std::string expected2 = prettyPrint(jsonj, 0, 4);
EXPECT_EQ(expected2, current);
......
......@@ -240,12 +240,17 @@ TEST_F(D2GetConfigTest, sample1) {
prettyPrint(unparsed, std::cerr, 0, 4);
std::cerr << "\n";
} else {
// get the expected config using the d2 syntax parser
ElementPtr jsond;
ASSERT_NO_THROW(jsond = parseDHCPDDNS(expected, true));
// get the expected config using the generic JSON syntax parser
ElementPtr jsonj;
ASSERT_NO_THROW(jsonj = parseJSON(expected));
// the generic JSON parser does not handle comments
EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj)));
// check that unparsed and expected values match
EXPECT_TRUE(isEquivalent(unparsed, jsonj));
// check on pretty prints too
std::string current = prettyPrint(unparsed, 0, 4) + "\n";
EXPECT_EQ(expected, current);
if (expected != current) {
......
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -318,12 +318,17 @@ TEST_P(Dhcp4GetConfigTest, run) {
ASSERT_NO_THROW(outputFormatted(dhcp->str()));
} else {
expected = UNPARSED_CONFIGS[config_counter];
// get the expected config using the dhcpv4 syntax parser
ElementPtr jsond;
ASSERT_NO_THROW(jsond = parseDHCP4(expected, true));
ElementPtr jsonj;
// get the expected config using the generic JSON syntax parser
ASSERT_NO_THROW(jsonj = parseJSON(expected));
EXPECT_TRUE(isEquivalent(dhcp, jsonj));
// the generic JSON parser does not handle comments
EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj)));
// check that unparsed and expected values match
EXPECT_TRUE(isEquivalent(dhcp, jsonj));
// check on pretty prints too
std::string current = prettyPrint(dhcp, 4, 4) + "\n";
EXPECT_EQ(expected, current);
if (expected != current) {
......
......@@ -322,12 +322,17 @@ TEST_P(Dhcp6GetConfigTest, run) {
ASSERT_NO_THROW(outputFormatted(dhcp->str()));
} else {
expected = UNPARSED_CONFIGS[config_counter];
// get the expected config using the dhcpv6 syntax parser
ElementPtr jsond;
ASSERT_NO_THROW(jsond = parseDHCP6(expected, true));
// get the expected config using the generic JSON syntax parser
ElementPtr jsonj;
ASSERT_NO_THROW(jsonj = parseJSON(expected));
EXPECT_TRUE(isEquivalent(dhcp, jsonj));
// the generic JSON parser does not handle comments
EXPECT_TRUE(isEquivalent(jsond, moveComments(jsonj)));
// check that unparsed and expected values match
EXPECT_TRUE(isEquivalent(dhcp, jsonj));
// check on pretty prints too
std::string current = prettyPrint(dhcp, 4, 4) + "\n";
EXPECT_EQ(expected, current);
if (expected != current) {
......
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