diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index b517abcb4a9a4299f08125f4574180b19e989c3c..d4a6319196fe1c70b13508fb86f068aa78a58bd5 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -207,25 +207,25 @@ public: params["space"] = DHCP4_OPTION_SPACE; params["code"] = "56"; params["data"] = "ABCDEF0105"; - params["csv-format"] = "False"; + params["csv-format"] = "false"; } else if (parameter == "space") { params["name"] = "dhcp-message"; params["space"] = param_value; params["code"] = "56"; params["data"] = "ABCDEF0105"; - params["csv-format"] = "False"; + params["csv-format"] = "false"; } else if (parameter == "code") { params["name"] = "dhcp-message"; params["space"] = DHCP4_OPTION_SPACE; params["code"] = param_value; params["data"] = "ABCDEF0105"; - params["csv-format"] = "False"; + params["csv-format"] = "false"; } else if (parameter == "data") { params["name"] = "dhcp-message"; params["space"] = DHCP4_OPTION_SPACE; params["code"] = "56"; params["data"] = param_value; - params["csv-format"] = "False"; + params["csv-format"] = "false"; } else if (parameter == "csv-format") { params["name"] = "dhcp-message"; params["space"] = DHCP4_OPTION_SPACE; @@ -1670,7 +1670,7 @@ TEST_F(Dhcp4ParserTest, optionDefArray) { " \"name\": \"foo\"," " \"code\": 100," " \"type\": \"uint32\"," - " \"array\": True," + " \"array\": true," " \"space\": \"isc\"" " } ]" "}"; @@ -1851,7 +1851,7 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulatedSpaceAndArray) { " \"name\": \"foo\"," " \"code\": 100," " \"type\": \"uint32\"," - " \"array\": True," + " \"array\": true," " \"space\": \"isc\"," " \"encapsulate\": \"valid-space-name\"" " } ]" @@ -1994,12 +1994,12 @@ TEST_F(Dhcp4ParserTest, optionDataDefaultsGlobal) { "\"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"ABCDEF0105\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"default-ip-ttl\"," " \"data\": \"01\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," @@ -2066,12 +2066,12 @@ TEST_F(Dhcp4ParserTest, optionDataDefaultsSubnet) { " \"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"ABCDEF0105\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"default-ip-ttl\"," " \"data\": \"01\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]" " } ]," "\"valid-lifetime\": 4000 }"; @@ -2137,7 +2137,7 @@ TEST_F(Dhcp4ParserTest, optionDataTwoSpaces) { "\"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"ABCDEF0105\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"foo\"," @@ -2330,7 +2330,7 @@ TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) { "\"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"AB\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ]," @@ -2338,12 +2338,12 @@ TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) { " \"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"ABCDEF0105\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"default-ip-ttl\"," " \"data\": \"01\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]" " } ]," "\"valid-lifetime\": 4000 }"; @@ -2481,7 +2481,7 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) { " \"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"0102030405060708090A\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]" " }," " {" @@ -2490,7 +2490,7 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) { " \"option-data\": [ {" " \"name\": \"default-ip-ttl\"," " \"data\": \"FF\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]" " } ]," "\"valid-lifetime\": 4000 }"; @@ -2638,7 +2638,7 @@ TEST_F(Dhcp4ParserTest, stdOptionData) { params["code"] = "41"; // Specify option values in a CSV (user friendly) format. params["data"] = "192.0.2.10, 192.0.2.1, 192.0.2.3"; - params["csv-format"] = "True"; + params["csv-format"] = "true"; std::string config = createConfigWithOption(params); ElementPtr json = Element::fromJSON(config); @@ -2794,7 +2794,7 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) { "\"renew-timer\": 1000," "\"option-data\": [ {" " \"name\": \"vendor-encapsulated-options\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"foo\"," @@ -2806,7 +2806,7 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) { " \"space\": \"vendor-encapsulated-options-space\"," " \"code\": 2," " \"data\": \"192.168.2.1\"," - " \"csv-format\": True" + " \"csv-format\": true" " } ]," "\"option-def\": [ {" " \"name\": \"foo\"," @@ -2890,14 +2890,14 @@ TEST_F(Dhcp4ParserTest, vendorOptionsHex) { " \"space\": \"vendor-4491\"," // VENDOR_ID_CABLE_LABS = 4491 " \"code\": 100," // just a random code " \"data\": \"ABCDEF0105\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"option-two\"," " \"space\": \"vendor-1234\"," " \"code\": 100," " \"data\": \"1234\"," - " \"csv-format\": False" + " \"csv-format\": false" " } ]," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"192.0.2.1-192.0.2.10\" } ]," @@ -3016,7 +3016,7 @@ buildHooksLibrariesConfig(const std::vector& libraries) { "\"option-data\": [ {" " \"name\": \"dhcp-message\"," " \"data\": \"ABCDEF0105\"," - " \"csv-format\": False" + " \"csv-format\": false" " }," " {" " \"name\": \"foo\"," diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 0f7033c011e3f6f1bfafa4e24dc80d37e672140f..363fa176d7020ddd240cd869425bee4161cc3f67 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -1067,7 +1067,7 @@ TEST_F(Dhcpv4SrvTest, vendorOptionsDocsis) { " \"space\": \"vendor-4491\"," " \"code\": 2," " \"data\": \"10.253.175.16\"," - " \"csv-format\": True" + " \"csv-format\": true" " }]," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"10.254.226.0/25\" } ]," @@ -1358,7 +1358,7 @@ TEST_F(Dhcpv4SrvTest, vendorOptionsORO) { " \"space\": \"vendor-4491\"," " \"code\": 2," " \"data\": \"192.0.2.1, 192.0.2.2\"," - " \"csv-format\": True" + " \"csv-format\": true" " }]," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"192.0.2.0/25\" } ]," @@ -1448,7 +1448,7 @@ TEST_F(Dhcpv4SrvTest, vendorOptionsDocsisDefinitions) { " \"code\": "; string config_postfix = "," " \"data\": \"192.0.2.1\"," - " \"csv-format\": True" + " \"csv-format\": true" " }]," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.50\" } ]," diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll index e5d89907aff0f9e290b4f20f84e64c3e5d8a68b6..e781055a4a0e0fe1960b5309d8f3b97628a5d5ea 100644 --- a/src/bin/dhcp6/dhcp6_lexer.ll +++ b/src/bin/dhcp6/dhcp6_lexer.ll @@ -1076,6 +1076,12 @@ null { return isc::dhcp::Dhcp6Parser::make_NULL_TYPE(driver.loc_); } +(?i:true) driver.error (driver.loc_, "JSON true reserved keyword is lower case only"); + +(?i:false) driver.error (driver.loc_, "JSON false reserved keyword is lower case only"); + +(?i:null) driver.error (driver.loc_, "JSON null reserved keyword is lower case only"); + <*>. driver.error (driver.loc_, "Invalid character: " + std::string(yytext)); <> { diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index 5d8b3d5cacf5d51fbcc9b2352fabb87de85c28bc..75bc5fdbd3af9080305cb1ef5d7618bf9c8dff25 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -330,13 +330,22 @@ TEST(ParserTest, errors) { Parser6Context::PARSER_JSON, "Can't open include file /foo/bar"); - // case sensitivity + // JSON keywords testError("{ \"foo\": True }", + Parser6Context::PARSER_JSON, + ":1.10-13: JSON true reserved keyword is lower case only"); + testError("{ \"foo\": False }", + Parser6Context::PARSER_JSON, + ":1.10-14: JSON false reserved keyword is lower case only"); + testError("{ \"foo\": NULL }", + Parser6Context::PARSER_JSON, + ":1.10-13: JSON null reserved keyword is lower case only"); + testError("{ \"foo\": Tru }", Parser6Context::PARSER_JSON, ":1.10: Invalid character: T"); - testError("{ \"foo\": NULL }", + testError("{ \"foo\": nul }", Parser6Context::PARSER_JSON, - ":1.10: Invalid character: N"); + ":1.10: Invalid character: n"); // numbers testError("123", diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 80765703a723335e60fb14078a5f5b6873677644..a54f8123854301b6cf7a2b1bf2b2790d3787ad7d 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -20,7 +20,6 @@ #include #include -#include // for iequals #include #include @@ -458,10 +457,10 @@ fromStringstreamBool(std::istream& in, const std::string& file, // This will move the pos to the end of the value. const std::string word = wordFromStringstream(in, pos); - if (boost::iequals(word, "True")) { + if (word == "true") { return (Element::create(true, Element::Position(file, line, start_pos))); - } else if (boost::iequals(word, "False")) { + } else if (word == "false") { return (Element::create(false, Element::Position(file, line, start_pos))); } else { @@ -480,7 +479,7 @@ fromStringstreamNull(std::istream& in, const std::string& file, const uint32_t start_pos = pos; // This will move the pos to the end of the value. const std::string word = wordFromStringstream(in, pos); - if (boost::iequals(word, "null")) { + if (word == "null") { return (Element::create(Element::Position(file, line, start_pos))); } else { throwJSONError(std::string("Bad null value: ") + word, file, @@ -659,16 +658,13 @@ Element::fromJSON(std::istream& in, const std::string& file, int& line, el_read = true; break; case 't': - case 'T': case 'f': - case 'F': in.putback(c); --pos; element = fromStringstreamBool(in, file, line, pos); el_read = true; break; case 'n': - case 'N': in.putback(c); --pos; element = fromStringstreamNull(in, file, line, pos); diff --git a/src/lib/cc/tests/data_unittests.cc b/src/lib/cc/tests/data_unittests.cc index 6b1a657e5c0b8b62f091707e1869b9a0e8a04b26..4615e9714e0d2a48a463b5ddb054ad3b9c178b4b 100644 --- a/src/lib/cc/tests/data_unittests.cc +++ b/src/lib/cc/tests/data_unittests.cc @@ -131,11 +131,13 @@ TEST(Element, from_and_to_json) { sv.push_back("{1}"); //ElementPtr ep = Element::fromJSON("\"aaa\nbbb\"err"); //std::cout << ep << std::endl; - sv.push_back("\n\nTru"); + sv.push_back("\n\nTrue"); + sv.push_back("\n\ntru"); sv.push_back("{ \n \"aaa\nbbb\"err:"); - sv.push_back("{ \t\n \"aaa\nbbb\"\t\n\n:\n True, \"\\\""); + sv.push_back("{ \t\n \"aaa\nbbb\"\t\n\n:\n true, \"\\\""); sv.push_back("{ \"a\": None}"); sv.push_back(""); + sv.push_back("NULL"); sv.push_back("nul"); sv.push_back("hello\"foobar\""); sv.push_back("\"foobar\"hello"); @@ -178,12 +180,6 @@ TEST(Element, from_and_to_json) { EXPECT_EQ("0.01", Element::fromJSON("1.0e-2")->str()); EXPECT_EQ("0.012", Element::fromJSON("1.2e-2")->str()); EXPECT_EQ("0.012", Element::fromJSON("1.2E-2")->str()); - EXPECT_EQ("null", Element::fromJSON("Null")->str()); - EXPECT_EQ("null", Element::fromJSON("NULL")->str()); - EXPECT_EQ("false", Element::fromJSON("False")->str()); - EXPECT_EQ("false", Element::fromJSON("FALSE")->str()); - EXPECT_EQ("true", Element::fromJSON("True")->str()); - EXPECT_EQ("true", Element::fromJSON("TRUE")->str()); EXPECT_EQ("\"\"", Element::fromJSON(" \n \t \r \f \b \"\" \n \f \t \r \b")->str()); EXPECT_EQ("{ }", Element::fromJSON("{ \n \r \t \b \f }")->str()); EXPECT_EQ("[ ]", Element::fromJSON("[ \n \r \f \t \b ]")->str()); @@ -709,35 +705,35 @@ TEST(Element, equals) { EXPECT_NE(*efs("1"), *efs("2")); EXPECT_NE(*efs("1"), *efs("\"1\"")); EXPECT_NE(*efs("1"), *efs("[]")); - EXPECT_NE(*efs("1"), *efs("True")); + EXPECT_NE(*efs("1"), *efs("true")); EXPECT_NE(*efs("1"), *efs("{}")); EXPECT_EQ(*efs("1.1"), *efs("1.1")); EXPECT_NE(*efs("1.0"), *efs("1")); EXPECT_NE(*efs("1.1"), *efs("\"1\"")); EXPECT_NE(*efs("1.1"), *efs("[]")); - EXPECT_NE(*efs("1.1"), *efs("True")); + EXPECT_NE(*efs("1.1"), *efs("true")); EXPECT_NE(*efs("1.1"), *efs("{}")); - EXPECT_EQ(*efs("True"), *efs("True")); - EXPECT_NE(*efs("True"), *efs("False")); - EXPECT_NE(*efs("True"), *efs("1")); - EXPECT_NE(*efs("True"), *efs("\"1\"")); - EXPECT_NE(*efs("True"), *efs("[]")); - EXPECT_NE(*efs("True"), *efs("{}")); + EXPECT_EQ(*efs("true"), *efs("true")); + EXPECT_NE(*efs("true"), *efs("false")); + EXPECT_NE(*efs("true"), *efs("1")); + EXPECT_NE(*efs("true"), *efs("\"1\"")); + EXPECT_NE(*efs("true"), *efs("[]")); + EXPECT_NE(*efs("true"), *efs("{}")); EXPECT_EQ(*efs("\"foo\""), *efs("\"foo\"")); EXPECT_NE(*efs("\"foo\""), *efs("\"bar\"")); EXPECT_NE(*efs("\"foo\""), *efs("1")); EXPECT_NE(*efs("\"foo\""), *efs("\"1\"")); - EXPECT_NE(*efs("\"foo\""), *efs("True")); + EXPECT_NE(*efs("\"foo\""), *efs("true")); EXPECT_NE(*efs("\"foo\""), *efs("[]")); EXPECT_NE(*efs("\"foo\""), *efs("{}")); EXPECT_EQ(*efs("[]"), *efs("[]")); EXPECT_EQ(*efs("[ 1, 2, 3 ]"), *efs("[ 1, 2, 3 ]")); - EXPECT_EQ(*efs("[ \"a\", [ True, 1], 2.2 ]"), *efs("[ \"a\", [ True, 1], 2.2 ]")); - EXPECT_NE(*efs("[ \"a\", [ True, 1], 2.2 ]"), *efs("[ \"a\", [ True, 2], 2.2 ]")); + EXPECT_EQ(*efs("[ \"a\", [ true, 1], 2.2 ]"), *efs("[ \"a\", [ true, 1], 2.2 ]")); + EXPECT_NE(*efs("[ \"a\", [ true, 1], 2.2 ]"), *efs("[ \"a\", [ true, 2], 2.2 ]")); EXPECT_NE(*efs("[]"), *efs("[1]")); EXPECT_NE(*efs("[]"), *efs("1")); EXPECT_NE(*efs("[]"), *efs("\"1\"")); diff --git a/src/lib/config/documentation.txt b/src/lib/config/documentation.txt index c6dd1ac72e8a4d7f5eee6bf3a4e48aba00e5a6e5..b4055ea0745453cc53c73f02907776fdc6753ee0 100644 --- a/src/lib/config/documentation.txt +++ b/src/lib/config/documentation.txt @@ -33,7 +33,7 @@ To add a simple configuration option, let's say an int, we make it the following "config_data" contains a list of elements of the form { "item_name": "name" "item_type": "integer|real|boolean|string|list|map" - "item_optional": True|False + "item_optional": true|false "item_default": } diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index 12f1590e188b424b4fb32db1445e585ecd11e242..89bfd7b0e4fcb8bef8de4b343edf88bb55a165b8 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -117,7 +117,7 @@ template<> void ValueParser::build(isc::data::ConstElementPtr value) { // Invoke common code for all specializations of build(). buildCommon(value); // The Config Manager checks if user specified a - // valid value for a boolean parameter: True or False. + // valid value for a boolean parameter: true or false. // We should have a boolean Element, use value directly try { value_ = value->boolValue(); @@ -1475,11 +1475,11 @@ D2ClientConfigParser::build(isc::data::ConstElementPtr client_config) { mode_str = string_values_->getOptionalParam("replace-client-name", D2ClientConfig:: DFT_REPLACE_CLIENT_NAME_MODE); - if (boost::iequals(mode_str, "FALSE")) { + if (boost::iequals(mode_str, "false")) { // @todo add a debug log replace_client_name_mode = D2ClientConfig::RCM_NEVER; } - else if (boost::iequals(mode_str, "TRUE")) { + else if (boost::iequals(mode_str, "true")) { // @todo add a debug log replace_client_name_mode = D2ClientConfig::RCM_WHEN_PRESENT; } else { diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc index eeb7c96b87957357465a84b48c4c2c98bc4a8542..8503168fb9f3e6d18617a9295682e9e7efe9dad9 100644 --- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc @@ -483,7 +483,7 @@ TEST_F(ParseConfigTest, basicOptionDefTest) { " \"name\": \"foo\"," " \"code\": 100," " \"type\": \"ipv4-address\"," - " \"array\": False," + " \"array\": false," " \"record-types\": \"\"," " \"space\": \"isc\"," " \"encapsulate\": \"\"" @@ -604,7 +604,7 @@ TEST_F(ParseConfigTest, basicOptionDataTest) { " \"space\": \"isc\"," " \"code\": 100," " \"data\": \"192.0.2.0\"," - " \"csv-format\": True" + " \"csv-format\": true" " } ]" "}"; @@ -733,7 +733,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatWithOptionDef) { " \"name\": \"swap-server\"," " \"space\": \"dhcp4\"," " \"code\": 16," - " \"csv-format\": True," + " \"csv-format\": true," " \"data\": \"192.0.2.0\"" " } ]" "}"; @@ -753,7 +753,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatWithOptionDef) { " \"name\": \"swap-server\"," " \"space\": \"dhcp4\"," " \"code\": 16," - " \"csv-format\": False," + " \"csv-format\": false," " \"data\": \"C0000200\"" " } ]" "}"; @@ -840,7 +840,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatNoOptionDef) { " \"name\": \"foo-name\"," " \"space\": \"dhcp6\"," " \"code\": 25000," - " \"csv-format\": True," + " \"csv-format\": true," " \"data\": \"0\"" " } ]" "}"; @@ -855,7 +855,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatNoOptionDef) { " \"name\": \"foo-name\"," " \"space\": \"dhcp6\"," " \"code\": 25000," - " \"csv-format\": False," + " \"csv-format\": false," " \"data\": \"0\"" " } ]" "}"; @@ -974,7 +974,7 @@ TEST_F(ParseConfigTest, optionDataMinimalWithOptionDef) { " \"name\": \"foo-name\"," " \"code\": 2345," " \"type\": \"ipv6-address\"," - " \"array\": True," + " \"array\": true," " \"space\": \"dhcp6\"" " } ]," " \"option-data\": [ {" @@ -1000,7 +1000,7 @@ TEST_F(ParseConfigTest, optionDataMinimalWithOptionDef) { " \"name\": \"foo-name\"," " \"code\": 2345," " \"type\": \"ipv6-address\"," - " \"array\": True," + " \"array\": true," " \"space\": \"dhcp6\"" " } ]," " \"option-data\": [ {"