Skip to content

Commit d959d41

Browse files
fxduponttmarkwalder
authored andcommitted
[#3583] Added syntax UTs
1 parent 64c15b1 commit d959d41

6 files changed

+1019
-14
lines changed

src/bin/dhcp4/tests/classify_unittest.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ TEST_F(ClassifyTest, vendorOptionClassTagTest) {
17521752
"code": 103,
17531753
"type": "string"
17541754
}],
1755-
"option-data": [{
1755+
"option-data": [{
17561756
"space": "vendor-4491",
17571757
"code": 101,
17581758
"csv-format": true,
@@ -1801,7 +1801,7 @@ TEST_F(ClassifyTest, vendorOptionClassTagTest) {
18011801
// Add the ORO sub-option requesting all three sub-options.
18021802
boost::shared_ptr<OptionUint8Array> vendor_oro(new OptionUint8Array(Option::V4,
18031803
DOCSIS3_V4_ORO));
1804-
vendor_oro->addValue(101);
1804+
vendor_oro->addValue(101);
18051805
vendor_oro->addValue(102);
18061806
vendor_oro->addValue(103);
18071807
vendor->addOption(vendor_oro);
@@ -1832,7 +1832,7 @@ TEST_F(ClassifyTest, vendorOptionClassTagTest) {
18321832
EXPECT_TRUE(vendor_resp->getOption(103));
18331833
}
18341834

1835-
// Verifies that a requested VIVCO suboption can be gated by
1835+
// Verifies that a requested VIVCO suboption can be gated by
18361836
// option class tagging.
18371837
TEST_F(ClassifyTest, vivcoOptionClassTagTest) {
18381838
IfaceMgrTestConfig test_config(true);
@@ -1926,7 +1926,7 @@ TEST_F(ClassifyTest, vivcoOptionClassTagTest) {
19261926
ASSERT_FALSE(tmp);
19271927
}
19281928

1929-
// Verifies that requested VIVSO suboption can be gated by
1929+
// Verifies that requested VIVSO suboption can be gated by
19301930
// option class tagging.
19311931
TEST_F(ClassifyTest, vivsoOptionClassTagTest) {
19321932
IfaceMgrTestConfig test_config(true);
@@ -2105,7 +2105,7 @@ TEST_F(ClassifyTest, basicOptionClassTagTest) {
21052105
tmp = response1->getOption(DHO_DOMAIN_NAME_SERVERS);
21062106
EXPECT_TRUE(tmp);
21072107

2108-
// Verify that server id is present and is the configured value.
2108+
// Verify that server id is present and is the configured value.
21092109
checkServerIdentifier(response1, "192.0.2.0");
21102110

21112111
// Try again with a client id that does not match "melon".

src/bin/dhcp4/tests/config_parser_unittest.cc

+65-1
Original file line numberDiff line numberDiff line change
@@ -8013,7 +8013,71 @@ TEST_F(Dhcp4ParserTest, storeDdnsConflictResolutionMode) {
80138013
}
80148014
}
80158015

8016-
//This test verifies that duplicates in option-data.client-classes
8016+
// This test verifies that class tagging can occur at any scope.
8017+
TEST_F(Dhcp4ParserTest, classTagging) {
8018+
std::string config = "{ " + genIfaceConfig() + ","
8019+
R"^(
8020+
"option-data": [{
8021+
"name": "domain-name",
8022+
"data": "example.com",
8023+
"client-classes": [ "in-global" ]
8024+
}],
8025+
"valid-lifetime": 4000,
8026+
"rebind-timer": 2000,
8027+
"renew-timer": 1000,
8028+
"shared-networks": [{
8029+
"name": "foo",
8030+
"subnet4": [{
8031+
"id": 1,
8032+
"subnet": "192.0.2.0/24",
8033+
"option-data": [{
8034+
"name": "domain-name",
8035+
"data": "example.com",
8036+
"client-classes": [ "in-subnet" ]
8037+
}],
8038+
"pools": [{
8039+
"pool": "192.0.2.0/28",
8040+
"option-data": [{
8041+
"name": "domain-name",
8042+
"data": "example.com",
8043+
"client-classes": [ "in-pool" ]
8044+
}]
8045+
}],
8046+
"reservations": [{
8047+
"hw-address": "AA:BB:CC:DD:EE:FF",
8048+
"option-data": [{
8049+
"name": "domain-name",
8050+
"data": "example.com",
8051+
"client-classes": [ "in-reservation" ]
8052+
}]
8053+
}]
8054+
}],
8055+
"option-data": [{
8056+
"name": "domain-name",
8057+
"data": "example.com",
8058+
"client-classes": [ "in-network" ]
8059+
}]
8060+
}],
8061+
"client-classes": [{
8062+
"name": "foo",
8063+
"option-data": [{
8064+
"name": "domain-name",
8065+
"data": "example.com",
8066+
"client-classes": [ "in-class" ]
8067+
}]
8068+
}]
8069+
})^";
8070+
8071+
ConstElementPtr json;
8072+
ASSERT_NO_THROW(json = parseDHCP4(config));
8073+
extractConfig(config);
8074+
8075+
ConstElementPtr status;
8076+
ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
8077+
checkResult(status, 0);
8078+
}
8079+
8080+
// This test verifies that duplicates in option-data.client-classes
80178081
// are ignored and do not affect class order.
80188082
TEST_F(Dhcp4ParserTest, optionClientClassesDuplicateCheck) {
80198083
std::string config = "{ " + genIfaceConfig() + ","

0 commit comments

Comments
 (0)