From d7a926a72f1d0dd22f2ae675a43df192935c3b8c Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Fri, 29 May 2020 18:37:18 +0200 Subject: [PATCH] [#916] Checkpoint: updated agents/servers --- src/bin/agent/tests/ca_process_tests.sh.in | 7 +- src/bin/agent/tests/parser_unittests.cc | 68 +++------------- src/bin/d2/tests/d2_process_tests.sh.in | 22 ++---- src/bin/d2/tests/parser_unittest.cc | 79 +++---------------- src/bin/netconf/tests/parser_unittests.cc | 27 +++++-- .../netconf/tests/shtests/netconf_tests.sh.in | 8 +- 6 files changed, 55 insertions(+), 156 deletions(-) diff --git a/src/bin/agent/tests/ca_process_tests.sh.in b/src/bin/agent/tests/ca_process_tests.sh.in index c903b40a00..6173d3410d 100644 --- a/src/bin/agent/tests/ca_process_tests.sh.in +++ b/src/bin/agent/tests/ca_process_tests.sh.in @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2016-2020 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 @@ -16,10 +16,7 @@ EXPECTED_VERSION="@PACKAGE_VERSION@" CONFIG="{ \"Control-agent\": { - \"http-host\": \"127.0.0.1\" - }, - \"Logging\": - { + \"http-host\": \"127.0.0.1\", \"loggers\": [ { \"name\": \"kea-ctrl-agent\", diff --git a/src/bin/agent/tests/parser_unittests.cc b/src/bin/agent/tests/parser_unittests.cc index af6ef13b6a..d8cabd4e05 100644 --- a/src/bin/agent/tests/parser_unittests.cc +++ b/src/bin/agent/tests/parser_unittests.cc @@ -120,54 +120,6 @@ TEST(ParserTest, keywordJSON) { testParser(txt, ParserContext::PARSER_JSON); } -// This test checks that the DhcpDdns configuration is accepted -// by the parser. -TEST(ParserTest, keywordDhcpDdns) { - string txt = - "{ \"DhcpDdns\" : \n" - "{ \n" - " \"ip-address\": \"192.168.77.1\", \n" - " \"port\": 777 , \n " - " \"ncr-protocol\": \"UDP\", \n" - "\"tsig-keys\": [], \n" - "\"forward-ddns\" : {}, \n" - "\"reverse-ddns\" : {} \n" - "} \n" - "} \n"; - testParser(txt, ParserContext::PARSER_AGENT); -} - -// This test checks that the Dhcp6 configuration is accepted -// by the parser. -TEST(ParserTest, keywordDhcp6) { - string txt = "{ \"Dhcp6\": { \"interfaces-config\": {" - " \"interfaces\": [ \"type\", \"htype\" ] },\n" - "\"preferred-lifetime\": 3000,\n" - "\"rebind-timer\": 2000, \n" - "\"renew-timer\": 1000, \n" - "\"subnet6\": [ { " - " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ]," - " \"subnet\": \"2001:db8:1::/48\", " - " \"interface\": \"test\" } ],\n" - "\"valid-lifetime\": 4000 } }"; - testParser(txt, ParserContext::PARSER_AGENT); -} - -// This test checks that the Dhcp4 configuration is accepted -// by the parser. -TEST(ParserTest, keywordDhcp4) { - string txt = "{ \"Dhcp4\": { \"interfaces-config\": {" - " \"interfaces\": [ \"type\", \"htype\" ] },\n" - "\"rebind-timer\": 2000, \n" - "\"renew-timer\": 1000, \n" - "\"subnet4\": [ { " - " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," - " \"subnet\": \"192.0.2.0/24\", " - " \"interface\": \"test\" } ],\n" - "\"valid-lifetime\": 4000 } }"; - testParser(txt, ParserContext::PARSER_AGENT); -} - // This test checks if full config (with top level and Control-agent objects) can // be parsed with syntactic checking (and as pure JSON). TEST(ParserTest, keywordAgent) { @@ -562,18 +514,24 @@ TEST(ParserTest, errors) { "expecting }"); testError("{ 123 }\n", ParserContext::PARSER_AGENT, - ":1.3-5: syntax error, unexpected integer"); + ":1.3-5: syntax error, unexpected integer, " + "expecting Control-agent"); testError("{ \"foo\" }\n", ParserContext::PARSER_JSON, ":1.9: syntax error, unexpected }, " "expecting :"); testError("{ \"foo\" }\n", ParserContext::PARSER_AGENT, - ":1.9: syntax error, unexpected }, expecting :"); + ":1.3-7: syntax error, unexpected constant string, " + "expecting Control-agent"); testError("{ \"foo\":null }\n", ParserContext::PARSER_AGENT, - ":1.3-7: got unexpected keyword " - "\"foo\" in toplevel map."); + ":1.3-7: syntax error, unexpected constant string, " + "expecting Control-agent"); + testError("{ \"Logging\":null }\n", + ParserContext::PARSER_AGENT, + ":1.3-11: syntax error, unexpected constant string, " + "expecting Control-agent"); testError("{ \"Control-agent\" }\n", ParserContext::PARSER_AGENT, ":1.19: syntax error, unexpected }, " @@ -696,6 +654,6 @@ TEST(ParserTest, unicodeSlash) { EXPECT_EQ("////", result->stringValue()); } -}; -}; -}; +} +} +} diff --git a/src/bin/d2/tests/d2_process_tests.sh.in b/src/bin/d2/tests/d2_process_tests.sh.in index 959b63c76f..ebdd01e0a6 100644 --- a/src/bin/d2/tests/d2_process_tests.sh.in +++ b/src/bin/d2/tests/d2_process_tests.sh.in @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2014-2020 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 @@ -18,10 +18,7 @@ CONFIG="{ \"port\": 53001, \"tsig-keys\": [], \"forward-ddns\" : {}, - \"reverse-ddns\" : {} - }, - \"Logging\": - { + \"reverse-ddns\" : {}, \"loggers\": [ { \"name\": \"kea-dhcp-ddns\", @@ -44,10 +41,7 @@ CONFIG_BAD_SYNTAX="{ \"port\": BOGUS, \"tsig-keys\": [], \"forward-ddns\" : {}, - \"reverse-ddns\" : {} - }, - \"Logging\": - { + \"reverse-ddns\" : {}, \"loggers\": [ { \"name\": \"kea-dhcp-ddns\", @@ -70,10 +64,7 @@ CONFIG_BAD_VALUE="{ \"port\": 80000, \"tsig-keys\": [], \"forward-ddns\" : {}, - \"reverse-ddns\" : {} - }, - \"Logging\": - { + \"reverse-ddns\" : {}, \"loggers\": [ { \"name\": \"kea-dhcp-ddns\", @@ -97,10 +88,7 @@ CONFIG_INVALID="{ \"port\": BOGUS, \"tsig-keys\": [], \"forward-ddns\" : {}, - \"reverse-ddns\" : {} - }, - \"Logging\": - { + \"reverse-ddns\" : {}, \"loggers\": [ { \"name\": \"kea-dhcp-ddns\", diff --git a/src/bin/d2/tests/parser_unittest.cc b/src/bin/d2/tests/parser_unittest.cc index 88d1f1dd69..7fa44c7aa4 100644 --- a/src/bin/d2/tests/parser_unittest.cc +++ b/src/bin/d2/tests/parser_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 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 @@ -136,57 +136,6 @@ TEST(ParserTest, keywordDhcpDdns) { testParser(txt, D2ParserContext::PARSER_DHCPDDNS); } -TEST(ParserTest, keywordDhcp6) { - string txt = "{ \"Dhcp6\": { \"interfaces-config\": {" - " \"interfaces\": [ \"type\", \"htype\" ] },\n" - "\"preferred-lifetime\": 3000,\n" - "\"rebind-timer\": 2000, \n" - "\"renew-timer\": 1000, \n" - "\"subnet6\": [ { " - " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ]," - " \"subnet\": \"2001:db8:1::/48\", " - " \"interface\": \"test\" } ],\n" - "\"valid-lifetime\": 4000 } }"; - testParser(txt, D2ParserContext::PARSER_DHCPDDNS); -} - -TEST(ParserTest, keywordDhcp4) { - string txt = "{ \"Dhcp4\": { \"interfaces-config\": {" - " \"interfaces\": [ \"type\", \"htype\" ] },\n" - "\"rebind-timer\": 2000, \n" - "\"renew-timer\": 1000, \n" - "\"subnet4\": [ { " - " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," - " \"subnet\": \"192.0.2.0/24\", " - " \"interface\": \"test\" } ],\n" - "\"valid-lifetime\": 4000 } }"; - testParser(txt, D2ParserContext::PARSER_DHCPDDNS); -} - -TEST(ParserTest, keywordControlAgent) { - string txt = "{ \"Control-agent\": { } }"; - testParser(txt, D2ParserContext::PARSER_DHCPDDNS); -} - -TEST(ParserTest, Logging) { - string txt = "{ \"Logging\": { \n" - " \"loggers\": [ \n" - " { \n" - " \"name\": \"kea-dhcp6\", \n" - " \"output_options\": [ \n" - " { \n" - " \"output\": \"stdout\" \n" - " } \n" - " ], \n" - " \"debuglevel\": 0, \n" - " \"severity\": \"INFO\" \n" - " } \n" - " ] }\n" - "} \n"; - testParser(txt, D2ParserContext::PARSER_DHCPDDNS); -} - - // Tests if bash (#) comments are supported. That's the only comment type that // was supported by the old parser. TEST(ParserTest, bashComments) { @@ -517,26 +466,24 @@ TEST(ParserTest, errors) { "expecting }"); testError("{ 123 }\n", D2ParserContext::PARSER_DHCPDDNS, - ":1.3-5: syntax error, unexpected integer"); + ":1.3-5: syntax error, unexpected integer, " + "expecting DhcpDdns"); testError("{ \"foo\" }\n", D2ParserContext::PARSER_JSON, ":1.9: syntax error, unexpected }, " "expecting :"); testError("{ \"foo\" }\n", D2ParserContext::PARSER_DHCPDDNS, - ":1.9: syntax error, unexpected }, expecting :"); + ":1.3-7: syntax error, unexpected constant string, " + "expecting DhcpDdns"); testError("{ \"foo\":null }\n", D2ParserContext::PARSER_DHCPDDNS, - ":1.3-7: got unexpected keyword " - "\"foo\" in toplevel map."); - testError("{ \"Dhcp6\" }\n", - D2ParserContext::PARSER_DHCPDDNS, - ":1.11: syntax error, unexpected }, " - "expecting :"); - testError("{ \"Dhcp4\":[]\n", + ":1.3-7: syntax error, unexpected constant string, " + "expecting DhcpDdns"); + testError("{ \"Logging\":null }\n", D2ParserContext::PARSER_DHCPDDNS, - ":2.1: syntax error, unexpected end of file, " - "expecting \",\" or }"); + ":1.3-11: syntax error, unexpected constant string, " + "expecting DhcpDdns"); testError("{}{}\n", D2ParserContext::PARSER_JSON, ":1.3: syntax error, unexpected {, " @@ -651,6 +598,6 @@ TEST(ParserTest, unicodeSlash) { EXPECT_EQ("////", result->stringValue()); } -}; -}; -}; +} +} +} diff --git a/src/bin/netconf/tests/parser_unittests.cc b/src/bin/netconf/tests/parser_unittests.cc index ed9dba9698..959fe31e90 100644 --- a/src/bin/netconf/tests/parser_unittests.cc +++ b/src/bin/netconf/tests/parser_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2020 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 @@ -574,7 +574,7 @@ TEST(ParserTest, errors) { testError("{ 123 }\n", ParserContext::PARSER_NETCONF, ":1.3-5: syntax error, unexpected integer, " - "expecting Netconf or Logging"); + "expecting Netconf"); testError("{ \"foo\" }\n", ParserContext::PARSER_JSON, ":1.9: syntax error, unexpected }, " @@ -582,11 +582,15 @@ TEST(ParserTest, errors) { testError("{ \"foo\" }\n", ParserContext::PARSER_NETCONF, ":1.3-7: syntax error, unexpected constant string, " - "expecting Netconf or Logging"); + "expecting Netconf"); testError("{ \"foo\":null }\n", ParserContext::PARSER_NETCONF, ":1.3-7: syntax error, unexpected constant string, " - "expecting Netconf or Logging"); + "expecting Netconf"); + testError("{ \"Logging\":null }\n", + ParserContext::PARSER_NETCONF, + ":1.3-11: syntax error, unexpected constant string, " + "expecting Netconf"); testError("{ \"Netconf\" }\n", ParserContext::PARSER_NETCONF, ":1.13: syntax error, unexpected }, " @@ -661,6 +665,15 @@ TEST(ParserTest, errors) { ParserContext::PARSER_NETCONF, ":3.3-11: duplicate user-context/comment entries " "(previous at :2:19)"); + + // duplicate Netconf entries + testError("{ \"Netconf\":{\n" + " \"comment\": \"first\" },\n" + " \"Netconf\":{\n" + " \"comment\": \"second\" }}\n", + ParserContext::PARSER_NETCONF, + ":3:3: duplicate Netconf entries in toplevel map " + "(previous at :1:3)"); } // Check unicode escapes @@ -704,6 +717,6 @@ TEST(ParserTest, unicodeSlash) { EXPECT_EQ("////", result->stringValue()); } -}; -}; -}; +} +} +} diff --git a/src/bin/netconf/tests/shtests/netconf_tests.sh.in b/src/bin/netconf/tests/shtests/netconf_tests.sh.in index abc6203643..3f631de731 100644 --- a/src/bin/netconf/tests/shtests/netconf_tests.sh.in +++ b/src/bin/netconf/tests/shtests/netconf_tests.sh.in @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2018-2020 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 @@ -21,11 +21,7 @@ CONFIG="{ { \"comment\": \"simply use defaults...\" } - } - }, - - \"Logging\": - { + }, \"loggers\": [ { \"name\": \"kea-netconf\", -- 2.47.2