|
@@ -461,7 +461,8 @@ TEST_F(Dhcp6ParserTest, optionDefIpv6Address) {
|
|
|
" \"type\": \"ipv6-address\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -499,7 +500,8 @@ TEST_F(Dhcp6ParserTest, optionDefRecord) {
|
|
|
" \"type\": \"record\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"uint16, ipv4-address, ipv6-address, string\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -546,7 +548,8 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) {
|
|
|
" \"type\": \"uint32\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" },"
|
|
|
" {"
|
|
|
" \"name\": \"foo-2\","
|
|
@@ -554,7 +557,8 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) {
|
|
|
" \"type\": \"ipv4-address\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -604,7 +608,8 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
|
|
|
" \"type\": \"uint32\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" },"
|
|
|
" {"
|
|
|
" \"name\": \"foo-2\","
|
|
@@ -612,7 +617,8 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
|
|
|
" \"type\": \"ipv4-address\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -640,7 +646,8 @@ TEST_F(Dhcp6ParserTest, optionDefArray) {
|
|
|
" \"type\": \"uint32\","
|
|
|
" \"array\": True,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -666,6 +673,47 @@ TEST_F(Dhcp6ParserTest, optionDefArray) {
|
|
|
EXPECT_TRUE(def->getArrayType());
|
|
|
}
|
|
|
|
|
|
+// The purpose of this test to verify that encapsulated option
|
|
|
+// space name may be specified.
|
|
|
+TEST_F(Dhcp6ParserTest, optionDefEncapsulate) {
|
|
|
+
|
|
|
+ // Configuration string. Included the encapsulated
|
|
|
+ // option space name.
|
|
|
+ std::string config =
|
|
|
+ "{ \"option-def\": [ {"
|
|
|
+ " \"name\": \"foo\","
|
|
|
+ " \"code\": 100,"
|
|
|
+ " \"type\": \"uint32\","
|
|
|
+ " \"array\": False,"
|
|
|
+ " \"record-types\": \"\","
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"sub-opts-space\""
|
|
|
+ " } ]"
|
|
|
+ "}";
|
|
|
+ ElementPtr json = Element::fromJSON(config);
|
|
|
+
|
|
|
+ // Make sure that the particular option definition does not exist.
|
|
|
+ OptionDefinitionPtr def = CfgMgr::instance().getOptionDef("isc", 100);
|
|
|
+ ASSERT_FALSE(def);
|
|
|
+
|
|
|
+ // Use the configuration string to create new option definition.
|
|
|
+ ConstElementPtr status;
|
|
|
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
|
|
|
+ ASSERT_TRUE(status);
|
|
|
+ checkResult(status, 0);
|
|
|
+
|
|
|
+ // The option definition should now be available in the CfgMgr.
|
|
|
+ def = CfgMgr::instance().getOptionDef("isc", 100);
|
|
|
+ ASSERT_TRUE(def);
|
|
|
+
|
|
|
+ // Check the option data.
|
|
|
+ EXPECT_EQ("foo", def->getName());
|
|
|
+ EXPECT_EQ(100, def->getCode());
|
|
|
+ EXPECT_EQ(OPT_UINT32_TYPE, def->getType());
|
|
|
+ EXPECT_FALSE(def->getArrayType());
|
|
|
+ EXPECT_EQ("sub-opts-space", def->getEncapsulatedSpace());
|
|
|
+}
|
|
|
+
|
|
|
/// The purpose of this test is to verify that the option definition
|
|
|
/// with invalid name is not accepted.
|
|
|
TEST_F(Dhcp6ParserTest, optionDefInvalidName) {
|
|
@@ -678,7 +726,8 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidName) {
|
|
|
" \"type\": \"string\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -703,7 +752,8 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidType) {
|
|
|
" \"type\": \"sting\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -728,7 +778,62 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidRecordType) {
|
|
|
" \"type\": \"record\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"uint32,uint8,sting\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
+ " } ]"
|
|
|
+ "}";
|
|
|
+ ElementPtr json = Element::fromJSON(config);
|
|
|
+
|
|
|
+ // Use the configuration string to create new option definition.
|
|
|
+ ConstElementPtr status;
|
|
|
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
|
|
|
+ ASSERT_TRUE(status);
|
|
|
+ // Expecting parsing error (error code 1).
|
|
|
+ checkResult(status, 1);
|
|
|
+}
|
|
|
+
|
|
|
+/// The goal of this test is to verify that the invalid encapsulated
|
|
|
+/// option space name is not accepted.
|
|
|
+TEST_F(Dhcp6ParserTest, optionDefInvalidEncapsulatedSpace) {
|
|
|
+ // Configuration string. The encapsulated option space
|
|
|
+ // name is invalid (% character is not allowed).
|
|
|
+ std::string config =
|
|
|
+ "{ \"option-def\": [ {"
|
|
|
+ " \"name\": \"foo\","
|
|
|
+ " \"code\": 100,"
|
|
|
+ " \"type\": \"uint32\","
|
|
|
+ " \"array\": False,"
|
|
|
+ " \"record-types\": \"\","
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"invalid%space%name\""
|
|
|
+ " } ]"
|
|
|
+ "}";
|
|
|
+ ElementPtr json = Element::fromJSON(config);
|
|
|
+
|
|
|
+ // Use the configuration string to create new option definition.
|
|
|
+ ConstElementPtr status;
|
|
|
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
|
|
|
+ ASSERT_TRUE(status);
|
|
|
+ // Expecting parsing error (error code 1).
|
|
|
+ checkResult(status, 1);
|
|
|
+}
|
|
|
+
|
|
|
+/// The goal of this test is to verify that the encapsulated
|
|
|
+/// option space name can't be specified for the option that
|
|
|
+/// comprises an array of data fields.
|
|
|
+TEST_F(Dhcp6ParserTest, optionDefEncapsulatedSpaceAndArray) {
|
|
|
+ // Configuration string. The encapsulated option space
|
|
|
+ // name is set to non-empty value and the array flag
|
|
|
+ // is set.
|
|
|
+ std::string config =
|
|
|
+ "{ \"option-def\": [ {"
|
|
|
+ " \"name\": \"foo\","
|
|
|
+ " \"code\": 100,"
|
|
|
+ " \"type\": \"uint32\","
|
|
|
+ " \"array\": True,"
|
|
|
+ " \"record-types\": \"\","
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"valid-space-name\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -741,6 +846,31 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidRecordType) {
|
|
|
checkResult(status, 1);
|
|
|
}
|
|
|
|
|
|
+/// The goal of this test is to verify that the option may not
|
|
|
+/// encapsulate option space it belongs to.
|
|
|
+TEST_F(Dhcp6ParserTest, optionDefEncapsulateOwnSpace) {
|
|
|
+ // Configuration string. Option is set to encapsulate
|
|
|
+ // option space it belongs to.
|
|
|
+ std::string config =
|
|
|
+ "{ \"option-def\": [ {"
|
|
|
+ " \"name\": \"foo\","
|
|
|
+ " \"code\": 100,"
|
|
|
+ " \"type\": \"uint32\","
|
|
|
+ " \"array\": False,"
|
|
|
+ " \"record-types\": \"\","
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"isc\""
|
|
|
+ " } ]"
|
|
|
+ "}";
|
|
|
+ ElementPtr json = Element::fromJSON(config);
|
|
|
+
|
|
|
+ // Use the configuration string to create new option definition.
|
|
|
+ ConstElementPtr status;
|
|
|
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
|
|
|
+ ASSERT_TRUE(status);
|
|
|
+ // Expecting parsing error (error code 1).
|
|
|
+ checkResult(status, 1);
|
|
|
+}
|
|
|
|
|
|
/// The purpose of this test is to verify that it is not allowed
|
|
|
/// to override the standard option (that belongs to dhcp6 option
|
|
@@ -759,7 +889,8 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {
|
|
|
" \"type\": \"string\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"dhcp6\""
|
|
|
+ " \"space\": \"dhcp6\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
ElementPtr json = Element::fromJSON(config);
|
|
@@ -794,7 +925,8 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {
|
|
|
" \"type\": \"string\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"dhcp6\""
|
|
|
+ " \"space\": \"dhcp6\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ]"
|
|
|
"}";
|
|
|
json = Element::fromJSON(config);
|
|
@@ -916,7 +1048,8 @@ TEST_F(Dhcp6ParserTest, optionDataTwoSpaces) {
|
|
|
" \"type\": \"uint32\","
|
|
|
" \"array\": False,"
|
|
|
" \"record-types\": \"\","
|
|
|
- " \"space\": \"isc\""
|
|
|
+ " \"space\": \"isc\","
|
|
|
+ " \"encapsulate\": \"\""
|
|
|
" } ],"
|
|
|
"\"subnet6\": [ { "
|
|
|
" \"pool\": [ \"2001:db8:1::/80\" ],"
|