diff options
author | Francis Dupont <fdupont@isc.org> | 2020-04-11 20:21:13 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2020-06-15 16:13:38 +0200 |
commit | c2e71eef0554fd30b30a0a2187a2accf151480ca (patch) | |
tree | a434cfd9fda6071f17a48f1badd7355755efd641 /src/bin/dhcp4/tests | |
parent | [#1189] Ready: test improvement ported to v6 (diff) | |
download | kea-c2e71eef0554fd30b30a0a2187a2accf151480ca.tar.xz kea-c2e71eef0554fd30b30a0a2187a2accf151480ca.zip |
[#1100] Got rid of comment extraction
Diffstat (limited to 'src/bin/dhcp4/tests')
-rw-r--r-- | src/bin/dhcp4/tests/get_config_unittest.cc | 144 | ||||
-rw-r--r-- | src/bin/dhcp4/tests/get_config_unittest.cc.skel | 4 |
2 files changed, 98 insertions, 50 deletions
diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index 1604fb200c..cac614e0f3 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -1937,88 +1937,112 @@ const char* EXTRACTED_CONFIGS[] = { " }\n", // CONFIGURATION 67 "{\n" -" \"comment\": \"A DHCPv4 server\",\n" " \"client-classes\": [\n" " {\n" -" \"comment\": \"match all\",\n" " \"name\": \"all\",\n" -" \"test\": \"'' == ''\"\n" +" \"test\": \"'' == ''\",\n" +" \"user-context\": {\n" +" \"comment\": \"match all\"\n" +" }\n" " },\n" " {\n" " \"name\": \"none\"\n" " },\n" " {\n" -" \"comment\": \"a comment\",\n" " \"name\": \"both\",\n" " \"user-context\": {\n" +" \"comment\": \"a comment\",\n" " \"version\": 1\n" " }\n" " }\n" " ],\n" " \"control-socket\": {\n" -" \"comment\": \"Indirect comment\",\n" " \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n" -" \"socket-type\": \"unix\"\n" +" \"socket-type\": \"unix\",\n" +" \"user-context\": {\n" +" \"comment\": \"Indirect comment\"\n" +" }\n" " },\n" " \"dhcp-ddns\": {\n" -" \"comment\": \"No dynamic DNS\",\n" -" \"enable-updates\": false\n" +" \"enable-updates\": false,\n" +" \"user-context\": {\n" +" \"comment\": \"No dynamic DNS\"\n" +" }\n" " },\n" " \"interfaces-config\": {\n" -" \"comment\": \"Use wildcard\",\n" " \"interfaces\": [ \"*\" ],\n" -" \"re-detect\": false\n" +" \"re-detect\": false,\n" +" \"user-context\": {\n" +" \"comment\": \"Use wildcard\"\n" +" }\n" " },\n" " \"option-data\": [\n" " {\n" -" \"comment\": \"Set option value\",\n" " \"csv-format\": false,\n" " \"data\": \"ABCDEF0105\",\n" -" \"name\": \"dhcp-message\"\n" +" \"name\": \"dhcp-message\",\n" +" \"user-context\": {\n" +" \"comment\": \"Set option value\"\n" +" }\n" " }\n" " ],\n" " \"option-def\": [\n" " {\n" -" \"comment\": \"An option definition\",\n" " \"code\": 100,\n" " \"name\": \"foo\",\n" " \"space\": \"isc\",\n" -" \"type\": \"ipv4-address\"\n" +" \"type\": \"ipv4-address\",\n" +" \"user-context\": {\n" +" \"comment\": \"An option definition\"\n" +" }\n" " }\n" " ],\n" " \"shared-networks\": [\n" " {\n" -" \"comment\": \"A shared network\",\n" " \"name\": \"foo\",\n" " \"subnet4\": [\n" " {\n" -" \"comment\": \"A subnet\",\n" " \"id\": 100,\n" " \"pools\": [\n" " {\n" -" \"comment\": \"A pool\",\n" -" \"pool\": \"192.0.1.1-192.0.1.10\"\n" +" \"pool\": \"192.0.1.1-192.0.1.10\",\n" +" \"user-context\": {\n" +" \"comment\": \"A pool\"\n" +" }\n" " }\n" " ],\n" " \"reservations\": [\n" " {\n" -" \"comment\": \"A host reservation\",\n" " \"hostname\": \"foo.example.com\",\n" " \"hw-address\": \"AA:BB:CC:DD:EE:FF\",\n" " \"option-data\": [\n" " {\n" -" \"comment\": \"An option in a reservation\",\n" " \"data\": \"example.com\",\n" -" \"name\": \"domain-name\"\n" +" \"name\": \"domain-name\",\n" +" \"user-context\": {\n" +" \"comment\": \"An option in a reservation\"\n" +" }\n" " }\n" -" ]\n" +" ],\n" +" \"user-context\": {\n" +" \"comment\": \"A host reservation\"\n" +" }\n" " }\n" " ],\n" -" \"subnet\": \"192.0.1.0/24\"\n" +" \"subnet\": \"192.0.1.0/24\",\n" +" \"user-context\": {\n" +" \"comment\": \"A subnet\"\n" +" }\n" " }\n" -" ]\n" +" ],\n" +" \"user-context\": {\n" +" \"comment\": \"A shared network\"\n" +" }\n" " }\n" -" ]\n" +" ],\n" +" \"user-context\": {\n" +" \"comment\": \"A DHCPv4 server\"\n" +" }\n" " }\n", // CONFIGURATION 68 "{\n" @@ -9665,20 +9689,21 @@ const char* UNPARSED_CONFIGS[] = { " }\n", // CONFIGURATION 67 "{\n" -" \"comment\": \"A DHCPv4 server\",\n" " \"authoritative\": false,\n" " \"boot-file-name\": \"\",\n" " \"calculate-tee-times\": false,\n" " \"client-classes\": [\n" " {\n" -" \"comment\": \"match all\",\n" " \"boot-file-name\": \"\",\n" " \"name\": \"all\",\n" " \"next-server\": \"0.0.0.0\",\n" " \"option-data\": [ ],\n" " \"option-def\": [ ],\n" " \"server-hostname\": \"\",\n" -" \"test\": \"'' == ''\"\n" +" \"test\": \"'' == ''\",\n" +" \"user-context\": {\n" +" \"comment\": \"match all\"\n" +" }\n" " },\n" " {\n" " \"boot-file-name\": \"\",\n" @@ -9689,7 +9714,6 @@ const char* UNPARSED_CONFIGS[] = { " \"server-hostname\": \"\"\n" " },\n" " {\n" -" \"comment\": \"a comment\",\n" " \"boot-file-name\": \"\",\n" " \"name\": \"both\",\n" " \"next-server\": \"0.0.0.0\",\n" @@ -9697,14 +9721,17 @@ const char* UNPARSED_CONFIGS[] = { " \"option-def\": [ ],\n" " \"server-hostname\": \"\",\n" " \"user-context\": {\n" +" \"comment\": \"a comment\",\n" " \"version\": 1\n" " }\n" " }\n" " ],\n" " \"control-socket\": {\n" -" \"comment\": \"Indirect comment\",\n" " \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n" -" \"socket-type\": \"unix\"\n" +" \"socket-type\": \"unix\",\n" +" \"user-context\": {\n" +" \"comment\": \"Indirect comment\"\n" +" }\n" " },\n" " \"ddns-generated-prefix\": \"myhost\",\n" " \"ddns-override-client-update\": false,\n" @@ -9714,7 +9741,6 @@ const char* UNPARSED_CONFIGS[] = { " \"ddns-send-updates\": true,\n" " \"decline-probation-period\": 86400,\n" " \"dhcp-ddns\": {\n" -" \"comment\": \"No dynamic DNS\",\n" " \"enable-updates\": false,\n" " \"max-queue-size\": 1024,\n" " \"ncr-format\": \"JSON\",\n" @@ -9722,7 +9748,10 @@ const char* UNPARSED_CONFIGS[] = { " \"sender-ip\": \"0.0.0.0\",\n" " \"sender-port\": 0,\n" " \"server-ip\": \"127.0.0.1\",\n" -" \"server-port\": 53001\n" +" \"server-port\": 53001,\n" +" \"user-context\": {\n" +" \"comment\": \"No dynamic DNS\"\n" +" }\n" " },\n" " \"dhcp-queue-control\": {\n" " \"capacity\": 500,\n" @@ -9744,9 +9773,11 @@ const char* UNPARSED_CONFIGS[] = { " \"hostname-char-replacement\": \"\",\n" " \"hostname-char-set\": \"[^A-Za-z0-9.-]\",\n" " \"interfaces-config\": {\n" -" \"comment\": \"Use wildcard\",\n" " \"interfaces\": [ \"*\" ],\n" -" \"re-detect\": false\n" +" \"re-detect\": false,\n" +" \"user-context\": {\n" +" \"comment\": \"Use wildcard\"\n" +" }\n" " },\n" " \"lease-database\": {\n" " \"type\": \"memfile\"\n" @@ -9760,25 +9791,29 @@ const char* UNPARSED_CONFIGS[] = { " \"next-server\": \"0.0.0.0\",\n" " \"option-data\": [\n" " {\n" -" \"comment\": \"Set option value\",\n" " \"always-send\": false,\n" " \"code\": 56,\n" " \"csv-format\": false,\n" " \"data\": \"ABCDEF0105\",\n" " \"name\": \"dhcp-message\",\n" -" \"space\": \"dhcp4\"\n" +" \"space\": \"dhcp4\",\n" +" \"user-context\": {\n" +" \"comment\": \"Set option value\"\n" +" }\n" " }\n" " ],\n" " \"option-def\": [\n" " {\n" -" \"comment\": \"An option definition\",\n" " \"array\": false,\n" " \"code\": 100,\n" " \"encapsulate\": \"\",\n" " \"name\": \"foo\",\n" " \"record-types\": \"\",\n" " \"space\": \"isc\",\n" -" \"type\": \"ipv4-address\"\n" +" \"type\": \"ipv4-address\",\n" +" \"user-context\": {\n" +" \"comment\": \"An option definition\"\n" +" }\n" " }\n" " ],\n" " \"reservation-mode\": \"all\",\n" @@ -9789,7 +9824,6 @@ const char* UNPARSED_CONFIGS[] = { " \"server-tag\": \"\",\n" " \"shared-networks\": [\n" " {\n" -" \"comment\": \"A shared network\",\n" " \"calculate-tee-times\": false,\n" " \"name\": \"foo\",\n" " \"option-data\": [ ],\n" @@ -9799,7 +9833,6 @@ const char* UNPARSED_CONFIGS[] = { " \"store-extended-info\": false,\n" " \"subnet4\": [\n" " {\n" -" \"comment\": \"A subnet\",\n" " \"4o6-interface\": \"\",\n" " \"4o6-interface-id\": \"\",\n" " \"4o6-subnet\": \"\",\n" @@ -9808,9 +9841,11 @@ const char* UNPARSED_CONFIGS[] = { " \"option-data\": [ ],\n" " \"pools\": [\n" " {\n" -" \"comment\": \"A pool\",\n" " \"option-data\": [ ],\n" -" \"pool\": \"192.0.1.1-192.0.1.10\"\n" +" \"pool\": \"192.0.1.1-192.0.1.10\",\n" +" \"user-context\": {\n" +" \"comment\": \"A pool\"\n" +" }\n" " }\n" " ],\n" " \"relay\": {\n" @@ -9818,7 +9853,6 @@ const char* UNPARSED_CONFIGS[] = { " },\n" " \"reservations\": [\n" " {\n" -" \"comment\": \"A host reservation\",\n" " \"boot-file-name\": \"\",\n" " \"client-classes\": [ ],\n" " \"hostname\": \"foo.example.com\",\n" @@ -9826,27 +9860,38 @@ const char* UNPARSED_CONFIGS[] = { " \"next-server\": \"0.0.0.0\",\n" " \"option-data\": [\n" " {\n" -" \"comment\": \"An option in a reservation\",\n" " \"always-send\": false,\n" " \"code\": 15,\n" " \"csv-format\": true,\n" " \"data\": \"example.com\",\n" " \"name\": \"domain-name\",\n" -" \"space\": \"dhcp4\"\n" +" \"space\": \"dhcp4\",\n" +" \"user-context\": {\n" +" \"comment\": \"An option in a reservation\"\n" +" }\n" " }\n" " ],\n" -" \"server-hostname\": \"\"\n" +" \"server-hostname\": \"\",\n" +" \"user-context\": {\n" +" \"comment\": \"A host reservation\"\n" +" }\n" " }\n" " ],\n" " \"store-extended-info\": false,\n" " \"subnet\": \"192.0.1.0/24\",\n" " \"t1-percent\": 0.5,\n" " \"t2-percent\": 0.875,\n" +" \"user-context\": {\n" +" \"comment\": \"A subnet\"\n" +" },\n" " \"valid-lifetime\": 7200\n" " }\n" " ],\n" " \"t1-percent\": 0.5,\n" " \"t2-percent\": 0.875,\n" +" \"user-context\": {\n" +" \"comment\": \"A shared network\"\n" +" },\n" " \"valid-lifetime\": 7200\n" " }\n" " ],\n" @@ -9856,6 +9901,9 @@ const char* UNPARSED_CONFIGS[] = { " \"subnet4\": [ ],\n" " \"t1-percent\": 0.5,\n" " \"t2-percent\": 0.875,\n" +" \"user-context\": {\n" +" \"comment\": \"A DHCPv4 server\"\n" +" },\n" " \"valid-lifetime\": 7200\n" " }\n", // CONFIGURATION 68 @@ -10693,7 +10741,7 @@ static_assert(max_config_counter == sizeof(UNPARSED_CONFIGS) / sizeof(char*), void outputFormatted(const std::string& config) { // pretty print it - ConstElementPtr json = extractComments(parseDHCP4(config)); + ConstElementPtr json = parseDHCP4(config); std::string prettier = prettyPrint(json, 4, 4); // get it as a line array std::list<std::string> lines; diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc.skel b/src/bin/dhcp4/tests/get_config_unittest.cc.skel index ebfd146b82..4ffc908e41 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp4/tests/get_config_unittest.cc.skel @@ -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 @@ -104,7 +104,7 @@ static_assert(max_config_counter == sizeof(UNPARSED_CONFIGS) / sizeof(char*), void outputFormatted(const std::string& config) { // pretty print it - ConstElementPtr json = extractComments(parseDHCP4(config)); + ConstElementPtr json = parseDHCP4(config); std::string prettier = prettyPrint(json, 4, 4); // get it as a line array std::list<std::string> lines; |