Skip to content

Commit

Permalink
[3587] Fixed generated config tests
Browse files Browse the repository at this point in the history
modified:   src/bin/dhcp4/tests/config_parser_unittest.cc
modified:   src/bin/dhcp4/tests/get_config_unittest.cc
modified:   src/bin/dhcp6/tests/config_parser_unittest.cc
modified:   src/bin/dhcp6/tests/get_config_unittest.cc
  • Loading branch information
tmarkwalder committed Nov 15, 2024
1 parent 3747220 commit fe77360
Show file tree
Hide file tree
Showing 4 changed files with 581 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/bin/dhcp4/tests/config_parser_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8191,7 +8191,6 @@ TEST_F(Dhcp4ParserTest, deprecatedRequireClientClassesCheck) {
})^";

ASSERT_NO_THROW(json = parseDHCP4(config));
extractConfig(config);

ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
checkResult(status, 1,
Expand Down Expand Up @@ -8247,7 +8246,6 @@ TEST_F(Dhcp4ParserTest, deprecatedOnlyIfRequiredCheck) {
})^";

ASSERT_NO_THROW(json = parseDHCP4(config));
extractConfig(config);

ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
checkResult(status, 1,
Expand Down
280 changes: 280 additions & 0 deletions src/bin/dhcp4/tests/get_config_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace {
///@{
/// @brief extracted configurations
const char* EXTRACTED_CONFIGS[] = {
/// put this after const char* EXTRACTED_CONFIGS[] = {
// CONFIGURATION 0
"{\n"
" \"interfaces-config\": {\n"
Expand Down Expand Up @@ -2567,11 +2568,58 @@ const char* EXTRACTED_CONFIGS[] = {
" \"renew-timer\": 1000,\n"
" \"subnet4\": [ ],\n"
" \"valid-lifetime\": 400\n"
" }\n",
// CONFIGURATION 80
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"shared-networks\": [\n"
" {\n"
" \"name\": \"net1\",\n"
" \"require-client-classes\": [ \"one\" ],\n"
" \"subnet4\": [\n"
" {\n"
" \"id\": 1,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"192.0.2.0/28\",\n"
" \"require-client-classes\": [ \"three\" ]\n"
" }\n"
" ],\n"
" \"require-client-classes\": [ \"two\" ],\n"
" \"subnet\": \"192.0.2.0/24\"\n"
" }\n"
" ]\n"
" }\n"
" ],\n"
" \"valid-lifetime\": 400\n"
" }\n",
// CONFIGURATION 81
"{\n"
" \"client-classes\": [\n"
" {\n"
" \"name\": \"foo\",\n"
" \"only-if-required\": true\n"
" }\n"
" ],\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"subnet4\": [ ],\n"
" \"valid-lifetime\": 400\n"
" }\n"
};

/// @brief unparsed configurations
const char* UNPARSED_CONFIGS[] = {
///put this after const char* UNPARSED_CONFIGS[] = {
// CONFIGURATION 0
"{\n"
" \"allocator\": \"iterative\",\n"
Expand Down Expand Up @@ -13085,6 +13133,238 @@ const char* UNPARSED_CONFIGS[] = {
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n",
// CONFIGURATION 80
"{\n"
" \"allocator\": \"iterative\",\n"
" \"authoritative\": false,\n"
" \"boot-file-name\": \"\",\n"
" \"calculate-tee-times\": false,\n"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\",\n"
" \"ddns-generated-prefix\": \"myhost\",\n"
" \"ddns-override-client-update\": false,\n"
" \"ddns-override-no-update\": false,\n"
" \"ddns-qualifying-suffix\": \"\",\n"
" \"ddns-replace-client-name\": \"never\",\n"
" \"ddns-send-updates\": true,\n"
" \"ddns-update-on-renew\": false,\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"enable-updates\": false,\n"
" \"max-queue-size\": 1024,\n"
" \"ncr-format\": \"JSON\",\n"
" \"ncr-protocol\": \"UDP\",\n"
" \"sender-ip\": \"0.0.0.0\",\n"
" \"sender-port\": 0,\n"
" \"server-ip\": \"127.0.0.1\",\n"
" \"server-port\": 53001\n"
" },\n"
" \"dhcp-queue-control\": {\n"
" \"capacity\": 64,\n"
" \"enable-queue\": false,\n"
" \"queue-type\": \"kea-ring4\"\n"
" },\n"
" \"dhcp4o6-port\": 0,\n"
" \"early-global-reservations-lookup\": false,\n"
" \"echo-client-id\": true,\n"
" \"expired-leases-processing\": {\n"
" \"flush-reclaimed-timer-wait-time\": 25,\n"
" \"hold-reclaimed-time\": 3600,\n"
" \"max-reclaim-leases\": 100,\n"
" \"max-reclaim-time\": 250,\n"
" \"reclaim-timer-wait-time\": 10,\n"
" \"unwarned-reclaim-cycles\": 5\n"
" },\n"
" \"hooks-libraries\": [ ],\n"
" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\", \"circuit-id\", \"client-id\" ],\n"
" \"hostname-char-replacement\": \"\",\n"
" \"hostname-char-set\": \"[^A-Za-z0-9.-]\",\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"ip-reservations-unique\": true,\n"
" \"lease-database\": {\n"
" \"type\": \"memfile\"\n"
" },\n"
" \"match-client-id\": true,\n"
" \"multi-threading\": {\n"
" \"enable-multi-threading\": true,\n"
" \"packet-queue-size\": 64,\n"
" \"thread-pool-size\": 0\n"
" },\n"
" \"next-server\": \"0.0.0.0\",\n"
" \"option-data\": [ ],\n"
" \"option-def\": [ ],\n"
" \"parked-packet-limit\": 256,\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"reservations-global\": false,\n"
" \"reservations-in-subnet\": true,\n"
" \"reservations-lookup-first\": false,\n"
" \"reservations-out-of-pool\": false,\n"
" \"sanity-checks\": {\n"
" \"extended-info-checks\": \"fix\",\n"
" \"lease-checks\": \"warn\"\n"
" },\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [\n"
" {\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": false,\n"
" \"evaluate-additional-classes\": [ \"one\" ],\n"
" \"max-valid-lifetime\": 400,\n"
" \"min-valid-lifetime\": 400,\n"
" \"name\": \"net1\",\n"
" \"option-data\": [ ],\n"
" \"rebind-timer\": 2000,\n"
" \"relay\": {\n"
" \"ip-addresses\": [ ]\n"
" },\n"
" \"renew-timer\": 1000,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"4o6-interface\": \"\",\n"
" \"4o6-interface-id\": \"\",\n"
" \"4o6-subnet\": \"\",\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": false,\n"
" \"evaluate-additional-classes\": [ \"two\" ],\n"
" \"id\": 1,\n"
" \"max-valid-lifetime\": 400,\n"
" \"min-valid-lifetime\": 400,\n"
" \"option-data\": [ ],\n"
" \"pools\": [\n"
" {\n"
" \"evaluate-additional-classes\": [ \"three\" ],\n"
" \"option-data\": [ ],\n"
" \"pool\": \"192.0.2.0/28\"\n"
" }\n"
" ],\n"
" \"rebind-timer\": 2000,\n"
" \"relay\": {\n"
" \"ip-addresses\": [ ]\n"
" },\n"
" \"renew-timer\": 1000,\n"
" \"reservations\": [ ],\n"
" \"store-extended-info\": false,\n"
" \"subnet\": \"192.0.2.0/24\",\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n"
" ],\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n"
" ],\n"
" \"stash-agent-options\": false,\n"
" \"statistic-default-sample-age\": 0,\n"
" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n",
// CONFIGURATION 81
"{\n"
" \"allocator\": \"iterative\",\n"
" \"authoritative\": false,\n"
" \"boot-file-name\": \"\",\n"
" \"calculate-tee-times\": false,\n"
" \"client-classes\": [\n"
" {\n"
" \"boot-file-name\": \"\",\n"
" \"name\": \"foo\",\n"
" \"next-server\": \"0.0.0.0\",\n"
" \"only-in-additional-list\": true,\n"
" \"option-data\": [ ],\n"
" \"option-def\": [ ],\n"
" \"server-hostname\": \"\"\n"
" }\n"
" ],\n"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\",\n"
" \"ddns-generated-prefix\": \"myhost\",\n"
" \"ddns-override-client-update\": false,\n"
" \"ddns-override-no-update\": false,\n"
" \"ddns-qualifying-suffix\": \"\",\n"
" \"ddns-replace-client-name\": \"never\",\n"
" \"ddns-send-updates\": true,\n"
" \"ddns-update-on-renew\": false,\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"enable-updates\": false,\n"
" \"max-queue-size\": 1024,\n"
" \"ncr-format\": \"JSON\",\n"
" \"ncr-protocol\": \"UDP\",\n"
" \"sender-ip\": \"0.0.0.0\",\n"
" \"sender-port\": 0,\n"
" \"server-ip\": \"127.0.0.1\",\n"
" \"server-port\": 53001\n"
" },\n"
" \"dhcp-queue-control\": {\n"
" \"capacity\": 64,\n"
" \"enable-queue\": false,\n"
" \"queue-type\": \"kea-ring4\"\n"
" },\n"
" \"dhcp4o6-port\": 0,\n"
" \"early-global-reservations-lookup\": false,\n"
" \"echo-client-id\": true,\n"
" \"expired-leases-processing\": {\n"
" \"flush-reclaimed-timer-wait-time\": 25,\n"
" \"hold-reclaimed-time\": 3600,\n"
" \"max-reclaim-leases\": 100,\n"
" \"max-reclaim-time\": 250,\n"
" \"reclaim-timer-wait-time\": 10,\n"
" \"unwarned-reclaim-cycles\": 5\n"
" },\n"
" \"hooks-libraries\": [ ],\n"
" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\", \"circuit-id\", \"client-id\" ],\n"
" \"hostname-char-replacement\": \"\",\n"
" \"hostname-char-set\": \"[^A-Za-z0-9.-]\",\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"ip-reservations-unique\": true,\n"
" \"lease-database\": {\n"
" \"type\": \"memfile\"\n"
" },\n"
" \"match-client-id\": true,\n"
" \"multi-threading\": {\n"
" \"enable-multi-threading\": true,\n"
" \"packet-queue-size\": 64,\n"
" \"thread-pool-size\": 0\n"
" },\n"
" \"next-server\": \"0.0.0.0\",\n"
" \"option-data\": [ ],\n"
" \"option-def\": [ ],\n"
" \"parked-packet-limit\": 256,\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"reservations-global\": false,\n"
" \"reservations-in-subnet\": true,\n"
" \"reservations-lookup-first\": false,\n"
" \"reservations-out-of-pool\": false,\n"
" \"sanity-checks\": {\n"
" \"extended-info-checks\": \"fix\",\n"
" \"lease-checks\": \"warn\"\n"
" },\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
" \"stash-agent-options\": false,\n"
" \"statistic-default-sample-age\": 0,\n"
" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n"
};

Expand Down
2 changes: 0 additions & 2 deletions src/bin/dhcp6/tests/config_parser_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9195,7 +9195,6 @@ TEST_F(Dhcp6ParserTest, deprecatedRequireClientClassesCheck) {
})^";

ASSERT_NO_THROW(json = parseDHCP6(config));
extractConfig(config);

ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
checkResult(status, 1,
Expand Down Expand Up @@ -9251,7 +9250,6 @@ TEST_F(Dhcp6ParserTest, deprecatedOnlyIfRequiredCheck) {
})^";

ASSERT_NO_THROW(json = parseDHCP6(config));
extractConfig(config);

ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
checkResult(status, 1,
Expand Down
Loading

0 comments on commit fe77360

Please sign in to comment.