From: Marcin Siodelski Date: Wed, 9 Jan 2013 18:45:18 +0000 (+0100) Subject: [2317] Check for duplicated option definitions. X-Git-Tag: bind10-1.0.0-rc-release~100^2~2^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5477d36770d789ce36b2a74acedf64cf63e79460;p=thirdparty%2Fkea.git [2317] Check for duplicated option definitions. --- diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 5a3d078f12..7201ec30c8 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -578,6 +578,43 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) { EXPECT_FALSE(def2->getArrayType()); } +// The goal of this test is to verify that the duplicated option +// definition is not accepted. +TEST_F(Dhcp4ParserTest, optionDefDuplicate) { + + // Configuration string. Both option definitions have + // the same code and belong to the same option space. + // This configuration should not be accepted. + std::string config = + "{ \"option-def\": [ {" + " \"name\": \"foo\"," + " \"code\": 100," + " \"type\": \"uint32\"," + " \"array\": False," + " \"record-types\": \"\"," + " \"space\": \"isc\"" + " }," + " {" + " \"name\": \"foo-2\"," + " \"code\": 100," + " \"type\": \"ipv4-address\"," + " \"array\": False," + " \"record-types\": \"\"," + " \"space\": \"isc\"" + " } ]" + "}"; + ElementPtr json = Element::fromJSON(config); + + // Make sure that the option definition does not exist yet. + ASSERT_FALSE(CfgMgr::instance().getOptionDef("isc", 100)); + + // Use the configuration string to create new option definitions. + ConstElementPtr status; + EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json)); + ASSERT_TRUE(status); + checkResult(status, 1); +} + // The goal of this test is to verify that the option definition // comprising an array of uint32 values can be created. TEST_F(Dhcp4ParserTest, optionDefArray) {