|
@@ -1425,14 +1425,13 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulateOwnSpace) {
|
|
|
|
|
|
/// The purpose of this test is to verify that it is not allowed
|
|
/// The purpose of this test is to verify that it is not allowed
|
|
/// to override the standard option (that belongs to dhcp4 option
|
|
/// to override the standard option (that belongs to dhcp4 option
|
|
-/// space) and that it is allowed to define option in the dhcp4
|
|
|
|
-/// option space that has a code which is not used by any of the
|
|
|
|
-/// standard options.
|
|
|
|
|
|
+/// space and has its definition) and that it is allowed to define
|
|
|
|
+/// option in the dhcp4 option space that has a code which is not
|
|
|
|
+/// used by any of the standard options.
|
|
TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
|
|
TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
|
|
|
|
|
|
- // Configuration string. The option code 109 is unassigned
|
|
|
|
- // so it can be used for a custom option definition in
|
|
|
|
- // dhcp4 option space.
|
|
|
|
|
|
+ // Configuration string. The option code 109 is unassigned so it
|
|
|
|
+ // can be used for a custom option definition in dhcp4 option space.
|
|
std::string config =
|
|
std::string config =
|
|
"{ \"option-def\": [ {"
|
|
"{ \"option-def\": [ {"
|
|
" \"name\": \"foo\","
|
|
" \"name\": \"foo\","
|
|
@@ -1465,15 +1464,14 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
|
|
EXPECT_EQ(OPT_STRING_TYPE, def->getType());
|
|
EXPECT_EQ(OPT_STRING_TYPE, def->getType());
|
|
EXPECT_FALSE(def->getArrayType());
|
|
EXPECT_FALSE(def->getArrayType());
|
|
|
|
|
|
- // The combination of option space and code is
|
|
|
|
- // invalid. The 'dhcp4' option space groups
|
|
|
|
- // standard options and the code 100 is reserved
|
|
|
|
- // for one of them.
|
|
|
|
|
|
+ // The combination of option space and code is invalid. The 'dhcp4' option
|
|
|
|
+ // space groups standard options and the code 3 is reserved for one of
|
|
|
|
+ // them.
|
|
config =
|
|
config =
|
|
"{ \"option-def\": [ {"
|
|
"{ \"option-def\": [ {"
|
|
- " \"name\": \"foo\","
|
|
|
|
- " \"code\": 100,"
|
|
|
|
- " \"type\": \"string\","
|
|
|
|
|
|
+ " \"name\": \"routers\","
|
|
|
|
+ " \"code\": 3,"
|
|
|
|
+ " \"type\": \"ipv4-address\","
|
|
" \"array\": False,"
|
|
" \"array\": False,"
|
|
" \"record-types\": \"\","
|
|
" \"record-types\": \"\","
|
|
" \"space\": \"dhcp4\","
|
|
" \"space\": \"dhcp4\","
|
|
@@ -1487,6 +1485,40 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
|
|
ASSERT_TRUE(status);
|
|
ASSERT_TRUE(status);
|
|
// Expecting parsing error (error code 1).
|
|
// Expecting parsing error (error code 1).
|
|
checkResult(status, 1);
|
|
checkResult(status, 1);
|
|
|
|
+
|
|
|
|
+ /// @todo The option 65 is a standard DHCPv4 option. However, at this point
|
|
|
|
+ /// there is no definition for this option in libdhcp++, so it should be
|
|
|
|
+ /// allowed to define it from the configuration interface. This test will
|
|
|
|
+ /// have to be removed once definitions for remaining standard options are
|
|
|
|
+ /// created.
|
|
|
|
+ config =
|
|
|
|
+ "{ \"option-def\": [ {"
|
|
|
|
+ " \"name\": \"nis-server-addr\","
|
|
|
|
+ " \"code\": 65,"
|
|
|
|
+ " \"type\": \"ipv4-address\","
|
|
|
|
+ " \"array\": False,"
|
|
|
|
+ " \"record-types\": \"\","
|
|
|
|
+ " \"space\": \"dhcp4\","
|
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
|
+ " } ]"
|
|
|
|
+ "}";
|
|
|
|
+ json = Element::fromJSON(config);
|
|
|
|
+
|
|
|
|
+ // Use the configuration string to create new option definition.
|
|
|
|
+ EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
|
|
|
|
+ ASSERT_TRUE(status);
|
|
|
|
+ // Expecting success.
|
|
|
|
+ checkResult(status, 0);
|
|
|
|
+
|
|
|
|
+ def = CfgMgr::instance().getOptionDef("dhcp4", 65);
|
|
|
|
+ ASSERT_TRUE(def);
|
|
|
|
+
|
|
|
|
+ // Check the option data.
|
|
|
|
+ EXPECT_EQ("nis-server-addr", def->getName());
|
|
|
|
+ EXPECT_EQ(65, def->getCode());
|
|
|
|
+ EXPECT_EQ(OPT_IPV4_ADDRESS_TYPE, def->getType());
|
|
|
|
+ EXPECT_FALSE(def->getArrayType());
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// Goal of this test is to verify that global option
|
|
// Goal of this test is to verify that global option
|