From: Razvan Becheriu Date: Tue, 19 Jul 2022 20:04:46 +0000 (+0300) Subject: [#2474] added unittests which load and validate example files X-Git-Tag: Kea-2.2.0~7 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd22d2110258085828a86697f5708b2ad415d7b4;p=thirdparty%2Fkea.git [#2474] added unittests which load and validate example files --- diff --git a/doc/examples/kea4/advanced.json b/doc/examples/kea4/advanced.json index 652acddafd..4b25f46cee 100644 --- a/doc/examples/kea4/advanced.json +++ b/doc/examples/kea4/advanced.json @@ -18,9 +18,9 @@ { "Dhcp4": { - // Kea is told to listen on ethX interface only. + // Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ], + "interfaces": [ "eth0" ], // This specifies what type of socket Kea uses. Currently supported // are 'raw' (which is the default) and 'udp'. Raw has the benefit diff --git a/doc/examples/kea4/all-keys-netconf.json b/doc/examples/kea4/all-keys-netconf.json index a754256e99..baa1594c22 100644 --- a/doc/examples/kea4/all-keys-netconf.json +++ b/doc/examples/kea4/all-keys-netconf.json @@ -298,13 +298,13 @@ "hosts-databases": [ { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 3306, @@ -313,7 +313,7 @@ "type": "mysql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Read only mode. "readonly": false, @@ -334,13 +334,13 @@ }, { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 5432, @@ -349,7 +349,7 @@ "type": "postgresql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Connection reconnect wait time. // This parameter governs how long Kea waits before attempting @@ -398,7 +398,7 @@ // Specifies a list of interfaces on which the Kea DHCPv4 // server should listen to the DHCP requests. "interfaces": [ - "ethX" + "eth0" ], // Enumeration which indicates what interface should be used @@ -689,7 +689,7 @@ // Specifies that this shared network is selected for the // requests received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Shared network level flag specifying whether the client // identifier should be used for identifying clients. @@ -778,7 +778,7 @@ "4o6-subnet": "2001:db8:1:1::/64", // Subnet level authoritative flag. - "authoritative": true, + "authoritative": false, // Subnet level bootfile name, set in 'file' field. "boot-file-name": "", @@ -823,7 +823,7 @@ // Specifies that this subnet is selected for the requests // received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Subnet level flag specifying whether the client identifier // should be used for identifying clients. diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index 40c0f3a2fb..3b3b722b4e 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -298,13 +298,13 @@ "hosts-databases": [ { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 3306, @@ -313,7 +313,7 @@ "type": "mysql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Read only mode. "readonly": false, @@ -334,13 +334,13 @@ }, { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 5432, @@ -349,11 +349,14 @@ "type": "postgresql", // User name to be used to access the database. - "user": "kea" + "user": "keatest" }, { + // Name of the database to connect to. + "name": "keatest", + // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 9042, @@ -362,7 +365,7 @@ "type": "mysql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Connection reconnect wait time. // This parameter governs how long Kea waits before attempting @@ -411,7 +414,7 @@ // Specifies a list of interfaces on which the Kea DHCPv4 // server should listen to the DHCP requests. "interfaces": [ - "ethX" + "eth0" ], // Enumeration which indicates what interface should be used @@ -702,7 +705,7 @@ // Specifies that this shared network is selected for the // requests received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Shared network level flag specifying whether the client // identifier should be used for identifying clients. @@ -791,7 +794,7 @@ "4o6-subnet": "2001:db8:1:1::/64", // Subnet level authoritative flag. - "authoritative": true, + "authoritative": false, // Subnet level bootfile name, set in 'file' field. "boot-file-name": "", @@ -836,7 +839,7 @@ // Specifies that this subnet is selected for the requests // received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Subnet level flag specifying whether the client identifier // should be used for identifying clients. diff --git a/doc/examples/kea4/all-options.json b/doc/examples/kea4/all-options.json index e0ec867b85..49dbbf9fad 100644 --- a/doc/examples/kea4/all-options.json +++ b/doc/examples/kea4/all-options.json @@ -1229,7 +1229,7 @@ { "code": 114, "data": "https://default.example.org", - "name": "default-url" + "name": "v4-captive-portal" }, // Option code 115 is unassigned. @@ -1491,13 +1491,6 @@ "name": "v4-portparams" }, - // Type: string - { - "code": 160, - "data": "portal", - "name": "v4-captive-portal" - }, - // Option codes 161-209 are unassigned. /* diff --git a/doc/examples/kea4/backends.json b/doc/examples/kea4/backends.json index 84ef38bbda..40e0c39d7f 100644 --- a/doc/examples/kea4/backends.json +++ b/doc/examples/kea4/backends.json @@ -8,9 +8,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify lease type. Exactly one lease-database section @@ -81,7 +81,7 @@ { "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea4/classify.json b/doc/examples/kea4/classify.json index 5a623b718f..3f68c123a0 100644 --- a/doc/examples/kea4/classify.json +++ b/doc/examples/kea4/classify.json @@ -3,9 +3,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Let's use the simplest backend: memfile and use some reasonable values @@ -81,7 +81,7 @@ "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", "client-class": "VoIP", - "interface": "ethX" + "interface": "eth0" }, // This one doesn't have any client-class specified, so everyone @@ -97,7 +97,7 @@ "hw-address": "1a:1b:1c:1d:1e:1f", "client-classes": [ "VoIP" ] } ], - "interface": "ethX" + "interface": "eth0" }, // The following list defines a subnet with pools. For some pools @@ -119,7 +119,7 @@ } ], "subnet": "192.0.4.0/23", - "interface": "ethY" + "interface": "eth1" } ], diff --git a/doc/examples/kea4/classify2.json b/doc/examples/kea4/classify2.json index e9d82ac7bd..955e6bde35 100644 --- a/doc/examples/kea4/classify2.json +++ b/doc/examples/kea4/classify2.json @@ -4,9 +4,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Let's use the simplest backend: memfile and use some reasonable values @@ -89,7 +89,7 @@ "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", "client-class": "VoIP", - "interface": "ethX" + "interface": "eth0" }, // This one doesn't have any client-class specified, so everyone // is allowed in. The normal subnet selection rules still apply, @@ -104,7 +104,7 @@ "hw-address": "1a:1b:1c:1d:1e:1f", "client-classes": [ "VoIP" ] } ], - "interface": "ethX", + "interface": "eth0", "require-client-classes": [ "second_subnet" ] }, @@ -125,15 +125,15 @@ "pool": "192.0.5.1 - 192.0.5.200" } ], "subnet": "192.0.4.0/23", - "interface": "ethY" + "interface": "eth1" }, // This subnet is divided in two pools for unknown and known // (i.e. which have a reservation) clients. The built-in KNOWN and // UNKNOWN classes are set or not at host reservation lookup (KNOWN if // this returns something, UNKNOWN if this finds nothing) and client -//classes depending on it are evaluated. +// classes depending on it are evaluated. // This happens after subnet selection and before address allocation -//from pools. +// from pools. { "pools": [ { diff --git a/doc/examples/kea4/config-backend.json b/doc/examples/kea4/config-backend.json index adcfd8eed6..aae0f34436 100644 --- a/doc/examples/kea4/config-backend.json +++ b/doc/examples/kea4/config-backend.json @@ -11,9 +11,9 @@ // either "all" or "server1" will be used by this instance. "server-tag": "server1", - // Kea is told to listen on ethX interface only. + // Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Use memfile lease database backend. diff --git a/doc/examples/kea4/dhcpv4-over-dhcpv6.json b/doc/examples/kea4/dhcpv4-over-dhcpv6.json index 779041b172..52cdc1c1ac 100644 --- a/doc/examples/kea4/dhcpv4-over-dhcpv6.json +++ b/doc/examples/kea4/dhcpv4-over-dhcpv6.json @@ -7,7 +7,7 @@ "Dhcp4": { "interfaces-config": { - "interfaces": [ "eno33554984" ] + "interfaces": [ "eth0" ] }, "lease-database": { @@ -21,7 +21,7 @@ "subnet4": [ { "subnet": "10.10.10.0/24", // Don't forget the "4o6-" before "interface" here! - "4o6-interface": "eno33554984", + "4o6-interface": "eth0", "4o6-subnet": "2001:db8:1:1::/64", "pools": [ { "pool": "10.10.10.100 - 10.10.10.199" } ] } ], diff --git a/doc/examples/kea4/global-reservations.json b/doc/examples/kea4/global-reservations.json index 3c579df317..d25200c38e 100644 --- a/doc/examples/kea4/global-reservations.json +++ b/doc/examples/kea4/global-reservations.json @@ -9,9 +9,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of June @@ -144,7 +144,7 @@ // Note: flexible identifier requires flex_id hook library to be // loaded to work. { - "flex-id": "s0mEVaLue", + "flex-id": "'s0mEVaLue'", "ip-address": "192.0.2.206" } ], diff --git a/doc/examples/kea4/ha-load-balancing-primary.json b/doc/examples/kea4/ha-load-balancing-primary.json index e5cb40f1e1..ae730e5926 100644 --- a/doc/examples/kea4/ha-load-balancing-primary.json +++ b/doc/examples/kea4/ha-load-balancing-primary.json @@ -14,7 +14,7 @@ // Add names of your network interfaces to listen on. "interfaces-config": { // The DHCPv4 server listens on this interface. - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Control socket is required for communication between the Control diff --git a/doc/examples/kea4/hooks-radius.json b/doc/examples/kea4/hooks-radius.json index 14ffefe10b..f00190e1e9 100644 --- a/doc/examples/kea4/hooks-radius.json +++ b/doc/examples/kea4/hooks-radius.json @@ -69,8 +69,8 @@ { // Kea is told to listen on specific interfaces only. "interfaces-config": { - // You should probably list your network interfaces here (e.g. "en0") - "interfaces": [ "en0" ] + // You should probably list your network interfaces here (e.g. "eth1961") + "interfaces": [ "eth1961" ] }, // Set up the storage for leases. @@ -101,7 +101,7 @@ // Set the subnet ID (aka RADIUS NAS port). "id": 14, "subnet": "192.0.2.0/24", - "interface": "en0", + "interface": "eth1961", "pools": [ { // Red pool (10-19 are for reservations) diff --git a/doc/examples/kea4/hooks.json b/doc/examples/kea4/hooks.json index 9006c7661e..0d6e29bbec 100644 --- a/doc/examples/kea4/hooks.json +++ b/doc/examples/kea4/hooks.json @@ -5,9 +5,9 @@ {"Dhcp4": { -// Kea is told to listen on the ethX interface only. +// Kea is told to listen on the eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Set up the storage for leases. @@ -22,7 +22,7 @@ { "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea4/leases-expiration.json b/doc/examples/kea4/leases-expiration.json index ca4b3db05b..c40dd5d546 100644 --- a/doc/examples/kea4/leases-expiration.json +++ b/doc/examples/kea4/leases-expiration.json @@ -5,9 +5,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -49,7 +49,7 @@ { "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea4/multiple-options.json b/doc/examples/kea4/multiple-options.json index 925ef3bbd2..949889127f 100644 --- a/doc/examples/kea4/multiple-options.json +++ b/doc/examples/kea4/multiple-options.json @@ -4,9 +4,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of diff --git a/doc/examples/kea4/mysql-reservations.json b/doc/examples/kea4/mysql-reservations.json index 86a7accbcb..57429857be 100644 --- a/doc/examples/kea4/mysql-reservations.json +++ b/doc/examples/kea4/mysql-reservations.json @@ -5,9 +5,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, @@ -59,9 +59,9 @@ "type": "mysql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, - "name": "kea", - "user": "kea", - "password": "kea", + "name": "keatest", + "user": "keatest", + "password": "keatest", "host": "localhost", "port": 3306, "trust-anchor": "my-ca", @@ -79,7 +79,7 @@ { "pools": [ { "pool": "192.0.2.10 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX", + "interface": "eth0", "id": 1 } ], diff --git a/doc/examples/kea4/pgsql-reservations.json b/doc/examples/kea4/pgsql-reservations.json index ebd101b3f0..9f6d30141e 100644 --- a/doc/examples/kea4/pgsql-reservations.json +++ b/doc/examples/kea4/pgsql-reservations.json @@ -5,9 +5,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, @@ -61,9 +61,9 @@ "type": "postgresql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, - "name": "kea", - "user": "kea", - "password": "kea", + "name": "keatest", + "user": "keatest", + "password": "keatest", "host": "localhost" } ], @@ -77,7 +77,7 @@ { "pools": [ { "pool": "192.0.2.10 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX", + "interface": "eth0", "id": 1 } ], diff --git a/doc/examples/kea4/reservations.json b/doc/examples/kea4/reservations.json index 2e25c51c4e..c00a8e9c0c 100644 --- a/doc/examples/kea4/reservations.json +++ b/doc/examples/kea4/reservations.json @@ -4,9 +4,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of April @@ -155,7 +155,7 @@ // Note: flexible identifier requires flex_id hook library to be // loaded to work. { - "flex-id": "s0mEVaLue", + "flex-id": "'s0mEVaLue'", "ip-address": "192.0.2.206" } diff --git a/doc/examples/kea4/several-subnets.json b/doc/examples/kea4/several-subnets.json index bfa58e4e47..5fb0511264 100644 --- a/doc/examples/kea4/several-subnets.json +++ b/doc/examples/kea4/several-subnets.json @@ -5,9 +5,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of diff --git a/doc/examples/kea4/shared-network.json b/doc/examples/kea4/shared-network.json index a827262320..9f38ee8c87 100644 --- a/doc/examples/kea4/shared-network.json +++ b/doc/examples/kea4/shared-network.json @@ -11,7 +11,7 @@ // As with any other configuration, you need to tell Kea the interface // names, so it would listen to incoming traffic. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // You also need to tell where to store lease information. diff --git a/doc/examples/kea4/single-subnet.json b/doc/examples/kea4/single-subnet.json index 65a6e6c149..3fa6dfb1ee 100644 --- a/doc/examples/kea4/single-subnet.json +++ b/doc/examples/kea4/single-subnet.json @@ -5,9 +5,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -35,7 +35,7 @@ { "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea4/vendor-specific.json b/doc/examples/kea4/vendor-specific.json index 64b23b50a3..431c04ec29 100644 --- a/doc/examples/kea4/vendor-specific.json +++ b/doc/examples/kea4/vendor-specific.json @@ -70,9 +70,9 @@ ] } ], -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": ["ethX"] + "interfaces": ["eth0"] }, // We need to specify the database used to store leases. "lease-database": { @@ -82,7 +82,7 @@ // here. We tell Kea that it is directly available over local interface. "subnet4": [ { - "interface": "ethX", + "interface": "eth0", "pools": [ { "pool": "192.0.2.50-192.0.2.50" diff --git a/doc/examples/kea4/vivso.json b/doc/examples/kea4/vivso.json index 12adc95b25..fe1ccec2f5 100644 --- a/doc/examples/kea4/vivso.json +++ b/doc/examples/kea4/vivso.json @@ -62,10 +62,10 @@ ] } ], -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { "interfaces": [ - "ethX" + "eth0" ] }, // We need to specify the database used to store leases. @@ -76,7 +76,7 @@ // here. We tell Kea that it is directly available over local interface. "subnet4": [ { - "interface": "ethX", + "interface": "eth0", "pools": [ { "pool": "192.0.2.50-192.0.2.50" diff --git a/doc/examples/kea4/with-ddns.json b/doc/examples/kea4/with-ddns.json index 5460d6f5b0..ee47c62704 100644 --- a/doc/examples/kea4/with-ddns.json +++ b/doc/examples/kea4/with-ddns.json @@ -5,9 +5,9 @@ { "Dhcp4": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -35,7 +35,7 @@ { "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ], "subnet": "192.0.2.0/24", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/advanced.json b/doc/examples/kea6/advanced.json index 5d85adf41c..7704f8df2b 100644 --- a/doc/examples/kea6/advanced.json +++ b/doc/examples/kea6/advanced.json @@ -2,7 +2,7 @@ // It attempts to showcase some of the more advanced features. // Topology wise, it's a basic scenario with one IPv6 subnet configured. // It is assumed that one subnet (2001:db8:1::/64) is available directly -// over ethX interface. +// over eth0 interface. // // The following features are currently showcased here: // 1. Configuration of MAC/hardware address sources in DHCPv6 @@ -14,9 +14,9 @@ { "Dhcp6": { - // Kea is told to listen on ethX network interface only. + // Kea is told to listen on eth0 network interface only. "interfaces-config": { - "interfaces": [ "ethX" ], + "interfaces": [ "eth0" ], // This makes interfaces to be re-detected at each (re-)configuration. // By default it is true. @@ -132,8 +132,8 @@ "prefix": "2001:db8:abcd::", "prefix-len": 48, "delegated-len": 64, - "excluded-prefix": "2001:db8:abcd:1234::", - "excluded-prefix-len": 72, + "excluded-prefix": "2001:db8:abcd:0:1234::", + "excluded-prefix-len": 80, // Another user-context for this PD pool. Again, you can put // anything you want in there as long as it's valid JSON and @@ -145,7 +145,7 @@ ], // end of pools "subnet": "2001:db8:1::/64", - "interface": "ethX", + "interface": "eth0", // Sometimes the relay may use an odd IPv6 address that's not matching // the subnet. This is discouraged, but there are valid cases when it diff --git a/doc/examples/kea6/all-keys-netconf.json b/doc/examples/kea6/all-keys-netconf.json index 6712be2e11..cce7e8ec37 100644 --- a/doc/examples/kea6/all-keys-netconf.json +++ b/doc/examples/kea6/all-keys-netconf.json @@ -258,13 +258,13 @@ "hosts-databases": [ { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 3306, @@ -273,7 +273,7 @@ "type": "mysql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Read only mode. "readonly": false, @@ -293,13 +293,13 @@ }, { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 5432, @@ -308,7 +308,7 @@ "type": "postgresql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Connection reconnect wait time. // This parameter governs how long Kea waits before attempting @@ -349,7 +349,7 @@ // Specifies a list of interfaces on which the Kea DHCPv6 // server should listen to the DHCP requests. "interfaces": [ - "ethX" + "eth0" ], // Boolean flag indicating if the available interfaces should @@ -645,7 +645,7 @@ // Specifies that this shared network is selected for the // requests received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Specifies the content of the interface-id option used // by relays to identify the interface on the relay to @@ -771,7 +771,7 @@ // Specifies that this subnet is selected for the requests // received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Specifies the content of the interface-id option used // by relays to identify the interface on the relay to diff --git a/doc/examples/kea6/all-keys.json b/doc/examples/kea6/all-keys.json index c3437d0424..c9e251210d 100644 --- a/doc/examples/kea6/all-keys.json +++ b/doc/examples/kea6/all-keys.json @@ -258,13 +258,13 @@ "hosts-databases": [ { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 3306, @@ -273,7 +273,7 @@ "type": "mysql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Read only mode. "readonly": false, @@ -293,13 +293,13 @@ }, { // Name of the database to connect to. - "name": "kea", + "name": "keatest", // Host on which the database resides. "host": "localhost", // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 5432, @@ -308,11 +308,14 @@ "type": "postgresql", // User name to be used to access the database. - "user": "kea" + "user": "keatest" }, { + // Name of the database to connect to. + "name": "keatest", + // Database password. - "password": "kea", + "password": "keatest", // Port on which the database is available. "port": 9042, @@ -321,7 +324,7 @@ "type": "mysql", // User name to be used to access the database. - "user": "kea", + "user": "keatest", // Connection reconnect wait time. // This parameter governs how long Kea waits before attempting @@ -362,7 +365,7 @@ // Specifies a list of interfaces on which the Kea DHCPv6 // server should listen to the DHCP requests. "interfaces": [ - "ethX" + "eth0" ], // Boolean flag indicating if the available interfaces should @@ -658,7 +661,7 @@ // Specifies that this shared network is selected for the // requests received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Specifies the content of the interface-id option used // by relays to identify the interface on the relay to @@ -784,7 +787,7 @@ // Specifies that this subnet is selected for the requests // received on the particular interface. - "interface": "ethX", + "interface": "eth0", // Specifies the content of the interface-id option used // by relays to identify the interface on the relay to diff --git a/doc/examples/kea6/backends.json b/doc/examples/kea6/backends.json index 148a5834a4..7e16244877 100644 --- a/doc/examples/kea6/backends.json +++ b/doc/examples/kea6/backends.json @@ -8,9 +8,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify lease type. Exactly one lease-database section @@ -82,7 +82,7 @@ { "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/classify.json b/doc/examples/kea6/classify.json index 47e1e37ee8..a5fc2e98a0 100644 --- a/doc/examples/kea6/classify.json +++ b/doc/examples/kea6/classify.json @@ -4,9 +4,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Let's use the simplest backend: memfile and use some reasonable values @@ -24,10 +24,10 @@ // One packet can belong to zero or more classes. "client-classes": [ -// The first class attempts to match all packets coming in on ethX interface. +// The first class attempts to match all packets coming in on eth0 interface. { "name": "lab", - "test": "pkt.iface == 'ethX'", + "test": "pkt.iface == 'eth0'", "option-data": [{ "name": "dns-servers", "data": "2001:db8::1" @@ -59,7 +59,7 @@ "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", "client-class": "cable-modems", - "interface": "ethX" + "interface": "eth0" }, // The following subnet contains a class reservation for a client using @@ -73,7 +73,7 @@ "duid": "01:02:03:04:05:0A:0B:0C:0D:0E", "client-classes": [ "cable-modems" ] } ], - "interface": "ethX" + "interface": "eth0" }, // The following subnet contains a pool with a class constraint: only @@ -81,11 +81,11 @@ { "pools": [ { - "pool": "2001:db8:3::/80", + "pool": "2001:db8:4::/80", "client-class": "cable-modems" } ], "subnet": "2001:db8:4::/64", - "interface": "ethY" + "interface": "eth1" } ], diff --git a/doc/examples/kea6/classify2.json b/doc/examples/kea6/classify2.json index be3a071afd..474c3932b1 100644 --- a/doc/examples/kea6/classify2.json +++ b/doc/examples/kea6/classify2.json @@ -4,9 +4,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Let's use the simplest backend: memfile and use some reasonable values @@ -70,7 +70,7 @@ "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", "client-class": "cable-modems", - "interface": "ethX" + "interface": "eth0" }, // The following subnet contains a class reservation for a client using // DUID 01:02:03:04:05:0A:0B:0C:0D:0E. This client will always be assigned @@ -83,7 +83,7 @@ "duid": "01:02:03:04:05:0A:0B:0C:0D:0E", "client-classes": [ "cable-modems" ] } ], - "interface": "ethX", + "interface": "eth0", "require-client-classes": [ "second_subnet" ] }, // The following subnet contains a pool with a class constraint: only @@ -91,19 +91,19 @@ { "pools": [ { - "pool": "2001:db8:3::/80", + "pool": "2001:db8:4::/80", "client-class": "cable-modems" } ], "subnet": "2001:db8:4::/64", - "interface": "ethY" + "interface": "eth1" }, // This subnet is divided in two pools for unknown and known // (i.e. which have a reservation) clients. The built-in KNOWN and // UNKNOWN classes are set or not at host reservation lookup (KNOWN if // this returns something, UNKNOWN if this finds nothing) and client -//classes depending on it are evaluated. +// classes depending on it are evaluated. // This happens after subnet selection and before address allocation -//from pools. +// from pools. { "pools": [ { diff --git a/doc/examples/kea6/config-backend.json b/doc/examples/kea6/config-backend.json index 815fe582f7..eca306d924 100644 --- a/doc/examples/kea6/config-backend.json +++ b/doc/examples/kea6/config-backend.json @@ -11,9 +11,9 @@ // either "all" or "server2" will be used by this instance. "server-tag": "server2", - // Kea is told to listen on ethX interface only. + // Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Use memfile lease database backend. diff --git a/doc/examples/kea6/dhcpv4-over-dhcpv6.json b/doc/examples/kea6/dhcpv4-over-dhcpv6.json index c2e6ad3dfb..68d5675323 100644 --- a/doc/examples/kea6/dhcpv4-over-dhcpv6.json +++ b/doc/examples/kea6/dhcpv4-over-dhcpv6.json @@ -8,7 +8,7 @@ { "interfaces-config": { // Enable unicast - "interfaces": [ "eno33554984/2001:db8:1:1::1" ] + "interfaces": [ "eth0/2001:db8:1::1" ] }, "lease-database": { @@ -23,7 +23,7 @@ "subnet6": [ { "subnet": "2001:db8:1:1::/64", - "interface": "eno33554984", + "interface": "eth0", "pools": [ { "pool": "2001:db8:1:1::1:0/112" } ] } ], diff --git a/doc/examples/kea6/duid.json b/doc/examples/kea6/duid.json index 5265606a42..0c00c74e94 100644 --- a/doc/examples/kea6/duid.json +++ b/doc/examples/kea6/duid.json @@ -25,9 +25,9 @@ "htype": 1 }, -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -56,7 +56,7 @@ { "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/global-reservations.json b/doc/examples/kea6/global-reservations.json index db99beb48e..872a0e2ce5 100644 --- a/doc/examples/kea6/global-reservations.json +++ b/doc/examples/kea6/global-reservations.json @@ -9,9 +9,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -148,7 +148,7 @@ "delegated-len": 64 } ], - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/ha-hot-standby.json b/doc/examples/kea6/ha-hot-standby.json index 9675e6f7d5..a0752d5e4d 100644 --- a/doc/examples/kea6/ha-hot-standby.json +++ b/doc/examples/kea6/ha-hot-standby.json @@ -10,9 +10,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Control socket is required for communication between the Control @@ -113,7 +113,7 @@ } ], - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/hooks.json b/doc/examples/kea6/hooks.json index a930e2e9ba..60fc898235 100644 --- a/doc/examples/kea6/hooks.json +++ b/doc/examples/kea6/hooks.json @@ -5,9 +5,9 @@ {"Dhcp6": { -// Kea is told to listen on the ethX interface only. +// Kea is told to listen on the eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Set up the storage for leases. @@ -30,7 +30,7 @@ "user-context": { "charging": true } } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/iPXE.json b/doc/examples/kea6/iPXE.json index 9d38c4c4e0..601ad6f824 100644 --- a/doc/examples/kea6/iPXE.json +++ b/doc/examples/kea6/iPXE.json @@ -5,7 +5,7 @@ // Mandatory part of the config that list interfaces on which // Kea will listen for incoming traffic. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Two classes are migrated form ISC-DHCP example: diff --git a/doc/examples/kea6/leases-expiration.json b/doc/examples/kea6/leases-expiration.json index a20d5e126f..5a3eeb4290 100644 --- a/doc/examples/kea6/leases-expiration.json +++ b/doc/examples/kea6/leases-expiration.json @@ -5,9 +5,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -57,7 +57,7 @@ { "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/multiple-options.json b/doc/examples/kea6/multiple-options.json index a22559e67f..b6d8be857c 100644 --- a/doc/examples/kea6/multiple-options.json +++ b/doc/examples/kea6/multiple-options.json @@ -4,9 +4,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -159,7 +159,7 @@ } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/mysql-reservations.json b/doc/examples/kea6/mysql-reservations.json index 0553dad2e5..769c111a71 100644 --- a/doc/examples/kea6/mysql-reservations.json +++ b/doc/examples/kea6/mysql-reservations.json @@ -5,9 +5,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -46,9 +46,9 @@ "type": "mysql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, - "name": "kea", - "user": "kea", - "password": "kea", + "name": "keatest", + "user": "keatest", + "password": "keatest", "host": "localhost", "port": 3306, "readonly": true, @@ -76,7 +76,7 @@ "delegated-len": 64 } ], - "interface": "ethX", + "interface": "eth0", "id": 1 } ], diff --git a/doc/examples/kea6/pgsql-reservations.json b/doc/examples/kea6/pgsql-reservations.json index e27d4d5157..c7e204c390 100644 --- a/doc/examples/kea6/pgsql-reservations.json +++ b/doc/examples/kea6/pgsql-reservations.json @@ -5,9 +5,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -48,9 +48,9 @@ "type": "postgresql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, - "name": "kea", - "user": "kea", - "password": "kea", + "name": "keatest", + "user": "keatest", + "password": "keatest", "host": "localhost" } ], @@ -73,7 +73,7 @@ "delegated-len": 64 } ], - "interface": "ethX", + "interface": "eth0", "id": 1 } ], diff --git a/doc/examples/kea6/reservations.json b/doc/examples/kea6/reservations.json index 252b5410b5..f18ba62961 100644 --- a/doc/examples/kea6/reservations.json +++ b/doc/examples/kea6/reservations.json @@ -1,15 +1,15 @@ // This is an example configuration file for DHCPv6 server in Kea // that showcases how to do host reservations. It is // assumed that one subnet (2001:db8:1::/64) is available directly -// over ethX interface. A number of hosts have various combinations +// over eth0 interface. A number of hosts have various combinations // of addresses and prefixes reserved for them. { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -74,7 +74,7 @@ "delegated-len": 64 } ], - "interface": "ethX", + "interface": "eth0", // Host reservations. Define several reservations, note that // they are all within the range of the pool of the dynamically diff --git a/doc/examples/kea6/several-subnets.json b/doc/examples/kea6/several-subnets.json index 5891836f35..78bb066b80 100644 --- a/doc/examples/kea6/several-subnets.json +++ b/doc/examples/kea6/several-subnets.json @@ -5,9 +5,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of diff --git a/doc/examples/kea6/shared-network.json b/doc/examples/kea6/shared-network.json index 0dd5edc593..5666e014a5 100644 --- a/doc/examples/kea6/shared-network.json +++ b/doc/examples/kea6/shared-network.json @@ -8,9 +8,9 @@ // initial proposal was not best and way to migrate to something else. { "Dhcp6": { - // Kea is told to listen on ethX interface only. + // Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // You also need to tell where to store lease information. @@ -29,7 +29,7 @@ { "pools": [ { "pool": "2001:db8:2::/80" } ], "subnet": "2001:db8:2::/64", - "interface": "ethX" + "interface": "eth0" } ], @@ -114,7 +114,7 @@ // Ignored when reservations-in-subnet is false. "reservations-out-of-pool": false, "subnet": "2001:db8:1::/64", - "pools": [ { "pool": "2001:db8:1:abcd::/64" } ], + "pools": [ { "pool": "2001:db8:1:0:abcd::/80" } ], "valid-lifetime": 40 }, diff --git a/doc/examples/kea6/simple.json b/doc/examples/kea6/simple.json index 83953a112d..acd3499b65 100644 --- a/doc/examples/kea6/simple.json +++ b/doc/examples/kea6/simple.json @@ -1,14 +1,14 @@ // This is an example configuration file for DHCPv6 server in Kea. // It's a basic scenario with one IPv6 subnet configured. It is // assumed that one subnet (2001:db8:1::/64 is available directly -// over ethX interface. +// over eth0 interface. { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -37,7 +37,7 @@ { "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/doc/examples/kea6/softwire46.json b/doc/examples/kea6/softwire46.json index 4881b845d8..85d1d0cdde 100644 --- a/doc/examples/kea6/softwire46.json +++ b/doc/examples/kea6/softwire46.json @@ -5,9 +5,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // Let's use a Memfile backend to store leases. @@ -32,7 +32,7 @@ { "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", - "interface": "ethX", + "interface": "eth0", // Include MAP-E Container option for hosts connected to this subnet. "option-data": [ { diff --git a/doc/examples/kea6/stateless.json b/doc/examples/kea6/stateless.json index c71546d6a0..bbe1a84de4 100644 --- a/doc/examples/kea6/stateless.json +++ b/doc/examples/kea6/stateless.json @@ -8,7 +8,7 @@ { "Dhcp6": { "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // This is the list of options that will be granted to all clients that ask. diff --git a/doc/examples/kea6/tee-times.json b/doc/examples/kea6/tee-times.json index d3b969adc7..e6a21af256 100644 --- a/doc/examples/kea6/tee-times.json +++ b/doc/examples/kea6/tee-times.json @@ -5,9 +5,9 @@ { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of diff --git a/doc/examples/kea6/with-ddns.json b/doc/examples/kea6/with-ddns.json index e611d51123..04efb7d313 100644 --- a/doc/examples/kea6/with-ddns.json +++ b/doc/examples/kea6/with-ddns.json @@ -1,14 +1,14 @@ // This is an example configuration file for DHCPv6 server in Kea. // It's a basic scenario with one IPv6 subnet configured. It is // assumed that one subnet (2001:db8:1::/64 is available directly -// over ethX interface. +// over eth0 interface. { "Dhcp6": { -// Kea is told to listen on ethX interface only. +// Kea is told to listen on eth0 interface only. "interfaces-config": { - "interfaces": [ "ethX" ] + "interfaces": [ "eth0" ] }, // We need to specify the database used to store leases. As of @@ -37,7 +37,7 @@ { "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", - "interface": "ethX" + "interface": "eth0" } ], diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 6b62f0af02..bddf8ae9a5 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -198,7 +198,7 @@ ConstElementPtr ControlledDhcpv4Srv::commandShutdownHandler(const string&, ConstElementPtr args) { if (!ControlledDhcpv4Srv::getInstance()) { LOG_WARN(dhcp4_logger, DHCP4_NOT_RUNNING); - return(createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure.")); + return (createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure.")); } int exit_value = 0; diff --git a/src/bin/dhcp4/dhcp4_lexer.ll b/src/bin/dhcp4/dhcp4_lexer.ll index 688947f526..a2d9da3547 100644 --- a/src/bin/dhcp4/dhcp4_lexer.ll +++ b/src/bin/dhcp4/dhcp4_lexer.ll @@ -566,7 +566,7 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu] case isc::dhcp::Parser4Context::LEASE_DATABASE: return isc::dhcp::Dhcp4Parser::make_MAX_ROW_ERRORS(driver.loc_); default: - return isc::dhcp::Dhcp4Parser::make_STRING("max_row_errors", driver.loc_); + return isc::dhcp::Dhcp4Parser::make_STRING("max-row-errors", driver.loc_); } } diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 03e34025c2..4816fccc4a 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -538,8 +538,8 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); - db::DbAccessParser parser; for (auto it : hosts_databases->listValue()) { + db::DbAccessParser parser; std::string access_string; parser.parse(access_string, it); cfg_db_access->setHostDbAccessString(access_string); diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index b5e0924714..0497e5edf0 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ #include #include +#include #include @@ -47,6 +49,7 @@ using namespace isc; using namespace isc::dhcp; using namespace isc::data; using namespace isc::asiolink; +using namespace isc::cb; using namespace isc::config; using namespace isc::dhcp::test; using namespace isc::util; @@ -145,7 +148,6 @@ void checkStringInBuffer( const std::string& exp_string, const OptionBuffer& buf EXPECT_EQ(exp_string, std::string(buffer_string.c_str())); } - // This test verifies that the destination address of the response // message is set to giaddr, when giaddr is set to non-zero address // in the received message. @@ -354,7 +356,6 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataUseRouting) { // The local port is always DHCPv4 server port 67. EXPECT_EQ(DHCP4_SERVER_PORT, resp->getLocalPort()); - // No specific interface is selected as outbound interface and no specific // local address is provided. The IfaceMgr will figure out which interface to use. EXPECT_TRUE(resp->getLocalAddr().isV4Zero()); @@ -759,7 +760,6 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataBroadcast) { // query has been received. EXPECT_EQ("eth1", resp->getIface()); EXPECT_EQ(ETH1_INDEX, resp->getIndex()); - } // This test verifies that the destination address of the response message @@ -1066,7 +1066,6 @@ TEST_F(Dhcpv4SrvTest, sanityCheckDecline) { "Mandatory 'Requested IP address' option missing in DHCPDECLINE" " sent from [hwtype=1 00:fe:fe:fe:fe:fe], cid=[no info], tid=0x4d2"); - // Now let's add a requested address. This should not throw. OptionDefinitionPtr req_addr_def = LibDHCP::getOptionDef(DHCP4_OPTION_SPACE, DHO_DHCP_REQUESTED_ADDRESS); @@ -1437,7 +1436,6 @@ TEST_F(Dhcpv4SrvTest, DiscoverTimers) { (*test).exp_t1_, (*test).exp_t2_); } } - } // Check that option 58 and 59 are included when calculate-tee-times @@ -1579,7 +1577,6 @@ TEST_F(Dhcpv4SrvTest, calculateTeeTimers) { } } - // This test verifies that incoming DISCOVER can be handled properly, that an // OFFER is generated, that the response has an address and that address // really belongs to the configured pool. @@ -1898,7 +1895,6 @@ TEST_F(Dhcpv4SrvTest, requestEchoClientId) { checkClientId(ack, clientid); } - // This test verifies that incoming (positive) REQUEST/Renewing can be handled properly, that a // REPLY is generated, that the response has an address and that address // really belongs to the configured pool and that lease is actually renewed. @@ -2776,6 +2772,106 @@ Dhcpv4SrvTest::portsServerPort() { EXPECT_EQ(srv.server_port_, offer->getLocalPort()); } +void +Dhcpv4SrvTest::loadConfigFile(const string& path) { + CfgMgr::instance().clear(); + + LibDHCP::clearRuntimeOptionDefs(); + + IfaceMgrTestConfig test_config(true); + + // Do not use DHCP4_SERVER_PORT here as 0 means don't open sockets. + NakedDhcpv4Srv srv(0); + EXPECT_EQ(0, srv.server_port_); + + ConfigBackendDHCPv4Mgr::instance().registerBackendFactory("mysql", + [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv4Ptr { + return (ConfigBackendDHCPv4Ptr()); + }); + + ConfigBackendDHCPv4Mgr::instance().registerBackendFactory("postgresql", + [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv4Ptr { + return (ConfigBackendDHCPv4Ptr()); + }); + + // TimerMgr uses IO service to run asynchronous timers. + TimerMgr::instance()->setIOService(srv.getIOService()); + + // CommandMgr uses IO service to run asynchronous socket operations. + CommandMgr::instance().setIOService(srv.getIOService()); + + // LeaseMgr uses IO service to run asynchronous timers. + LeaseMgr::setIOService(srv.getIOService()); + + // HostMgr uses IO service to run asynchronous timers. + HostMgr::setIOService(srv.getIOService()); + + Parser4Context parser; + ConstElementPtr json; + ASSERT_NO_THROW(json = parser.parseFile(path, Parser4Context::PARSER_DHCP4)); + ASSERT_TRUE(json); + + // Check the logic next. + ConstElementPtr dhcp4 = json->get("Dhcp4"); + ASSERT_TRUE(dhcp4); + ElementPtr mutable_config = boost::const_pointer_cast(dhcp4); + mutable_config->set(string("hooks-libraries"), Element::createList()); + ASSERT_NO_THROW(Dhcpv4SrvTest::configure(dhcp4->str(), true, true, true, true)); + + LeaseMgrFactory::destroy(); + HostMgr::create(); + + TimerMgr::instance()->unregisterTimers(); + + // Close the command socket (if it exists). + CommandMgr::instance().closeCommandSocket(); + + // CommandMgr uses IO service to run asynchronous socket operations. + CommandMgr::instance().setIOService(IOServicePtr()); + + // LeaseMgr uses IO service to run asynchronous timers. + LeaseMgr::setIOService(IOServicePtr()); + + // HostMgr uses IO service to run asynchronous timers. + HostMgr::setIOService(IOServicePtr()); +} + +void +Dhcpv4SrvTest::checkConfigFiles() { + IfaceMgrTestConfig test_config(true); + string path = CFG_EXAMPLES; + + DIR* dir = opendir(path.c_str()); + if (!dir) { + return; + } + + // Set of sorted files by name. + std::set files; + + for (struct dirent* dent = readdir(dir); dent; dent = readdir(dir)) { + std::string name(dent->d_name); + // Skip current and parent directory and files with no extension. + if (name.size() < (sizeof(".json") - 1)) { + continue; + } + + // Skip non .json files. + if (name.substr(name.size() - (sizeof(".json") - 1)) != ".json") { + continue; + } + name = path + "/" + name; + files.emplace(name); + } + + for (const auto& file: files) { + string label("Checking configuration from file: "); + label += file; + SCOPED_TRACE(label); + loadConfigFile(file); + } +} + } // end of isc::dhcp::test namespace } // end of isc::dhcp namespace } // end of isc namespace @@ -2822,13 +2918,16 @@ TEST_F(Dhcpv4SrvTest, portsServerPortMultiTHreading) { portsServerPort(); } +TEST_F(Dhcpv4SrvTest, checkConfigFiles) { + checkConfigFiles(); +} + /// @todo Implement tests for subnetSelect See tests in dhcp6_srv_unittest.cc: /// selectSubnetAddr, selectSubnetIface, selectSubnetRelayLinkaddr, /// selectSubnetRelayInterfaceId. Note that the concept of interface-id is not /// present in the DHCPv4, so not everything is applicable directly. /// See ticket #3057 - // Checks whether the server uses default (0.0.0.0) siaddr value, unless // explicitly specified TEST_F(Dhcpv4SrvTest, siaddrDefault) { @@ -3823,7 +3922,6 @@ TEST_F(Dhcpv4SrvTest, privateOption) { query->addOption(opt2); query->getDeferredOptions().push_back(245); - // Create and add a PRL option to the query OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4, DHO_DHCP_PARAMETER_REQUEST_LIST)); @@ -3859,7 +3957,6 @@ TEST_F(Dhcpv4SrvTest, privateOption) { EXPECT_EQ(12345678, opt32->getValue()); } - // Checks effect of persistency (aka always-true) flag on the PRL TEST_F(Dhcpv4SrvTest, prlPersistency) { IfaceMgrTestConfig test_config(true); diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.cc b/src/bin/dhcp4/tests/dhcp4_test_utils.cc index 1f0a0b5714..6916da5e78 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.cc +++ b/src/bin/dhcp4/tests/dhcp4_test_utils.cc @@ -87,7 +87,6 @@ Dhcpv4SrvTest::Dhcpv4SrvTest() } Dhcpv4SrvTest::~Dhcpv4SrvTest() { - // Make sure that we revert to default value CfgMgr::instance().clear(); @@ -301,8 +300,8 @@ Dhcpv4SrvTest::basicOptionsPresent(const Pkt4Ptr& pkt) { "dhcp-lease-time " << errmsg.str())); } - return (::testing::AssertionSuccess()); + return (::testing::AssertionSuccess()); } ::testing::AssertionResult @@ -801,15 +800,19 @@ Dhcpv4SrvTest::buildCfgOptionTest(IOAddress expected_server_id, void Dhcpv4SrvTest::configure(const std::string& config, const bool commit, - const bool open_sockets) { - configure(config, srv_, commit, open_sockets); + const bool open_sockets, + const bool create_managers, + const bool test) { + configure(config, srv_, commit, open_sockets, create_managers, test); } void Dhcpv4SrvTest::configure(const std::string& config, NakedDhcpv4Srv& srv, const bool commit, - const bool open_sockets) { + const bool open_sockets, + const bool create_managers, + const bool test) { setenv("KEA_LFC_EXECUTABLE", KEA_LFC_EXECUTABLE, 1); MultiThreadingCriticalSection cs; ConstElementPtr json; @@ -818,8 +821,8 @@ Dhcpv4SrvTest::configure(const std::string& config, } catch (const std::exception& ex){ // Fatal failure on parsing error FAIL() << "parsing failure:" - << "config:" << config << std::endl - << "error: " << ex.what(); + << "config:" << config << std::endl + << "error: " << ex.what(); } ConstElementPtr status; @@ -831,18 +834,21 @@ Dhcpv4SrvTest::configure(const std::string& config, configureMultiThreading(multi_threading_, json); // Configure the server and make sure the config is accepted - EXPECT_NO_THROW(status = configureDhcp4Server(srv, json)); + EXPECT_NO_THROW(status = configureDhcp4Server(srv, json, test)); ASSERT_TRUE(status); int rcode; ConstElementPtr comment = config::parseAnswer(rcode, status); - ASSERT_EQ(0, rcode) << comment->stringValue(); + ASSERT_EQ(0, rcode) << "configuration failed, test is broken: " + << comment->str(); // Use specified lease database backend. - ASSERT_NO_THROW( { - CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess(); - cfg_db->setAppendedParameters("universe=4"); - cfg_db->createManagers(); - } ); + if (create_managers) { + ASSERT_NO_THROW( { + CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess(); + cfg_db->setAppendedParameters("universe=4"); + cfg_db->createManagers(); + } ); + } try { CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading()); diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.h b/src/bin/dhcp4/tests/dhcp4_test_utils.h index cb36bd8aeb..fc20cb066e 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.h +++ b/src/bin/dhcp4/tests/dhcp4_test_utils.h @@ -6,7 +6,7 @@ /// @file dhcp4_test_utils.h /// -/// @brief This file contains utility classes used for DHCPv4 server testing +/// @brief This file contains utility classes used for DHCPv4 server testing #ifndef DHCP4_TEST_UTILS_H #define DHCP4_TEST_UTILS_H @@ -554,11 +554,16 @@ public: /// @param config String holding server configuration in JSON format. /// @param commit A boolean flag indicating if the new configuration /// should be committed (if true), or not (if false). - /// @param open_sockets A boolean flag indicating if sockets should + /// @param open_sockets A boolean flag indicating if sockets should /// be opened (if true), or not (if false). + /// @param create_managers A boolean flag indicating if managers should be + /// recreated. + /// @param test A boolean flag which indicates if only testing config. void configure(const std::string& config, const bool commit = true, - const bool open_sockets = true); + const bool open_sockets = true, + const bool create_managers = true, + const bool test = false); /// @brief Configure specified DHCP server using JSON string. /// @@ -566,12 +571,17 @@ public: /// @param srv Instance of the server to be configured. /// @param commit A boolean flag indicating if the new configuration /// should be committed (if true), or not (if false). - /// @param open_sockets A boolean flag indicating if sockets should + /// @param open_sockets A boolean flag indicating if sockets should /// be opened (if true), or not (if false). + /// @param create_managers A boolean flag indicating if managers should be + /// recreated. + /// @param test A boolean flag which indicates if only testing config. void configure(const std::string& config, NakedDhcpv4Srv& srv, const bool commit = true, - const bool open_sockets = true); + const bool open_sockets = true, + const bool create_managers = true, + const bool test = false); /// @brief Configure specified DHCP server using JSON string. /// @@ -637,9 +647,17 @@ public: /// @brief Checks if client port can be overridden in packets being sent. void portsClientPort(); - /// @brief Checks if server port can be overridden in packets being sent. + /// @brief Checks if server port can be overridden in packets being sent. void portsServerPort(); + /// @breif Check if example files contain valid configuration. + void checkConfigFiles(); + + /// @brief Check if the server configuration stored in file is valid. + /// + /// @param path The path to the configuration file. + void loadConfigFile(const std::string& path); + /// @brief This function cleans up after the test. virtual void TearDown(); diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 28c59ec21e..f144f37a3b 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -201,7 +201,7 @@ ConstElementPtr ControlledDhcpv6Srv::commandShutdownHandler(const string&, ConstElementPtr args) { if (!ControlledDhcpv6Srv::getInstance()) { LOG_WARN(dhcp6_logger, DHCP6_NOT_RUNNING); - return(createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure.")); + return (createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure.")); } int exit_value = 0; diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll index d9128c3a40..48408aade1 100644 --- a/src/bin/dhcp6/dhcp6_lexer.ll +++ b/src/bin/dhcp6/dhcp6_lexer.ll @@ -764,7 +764,7 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu] case isc::dhcp::Parser6Context::LEASE_DATABASE: return isc::dhcp::Dhcp6Parser::make_MAX_ROW_ERRORS(driver.loc_); default: - return isc::dhcp::Dhcp6Parser::make_STRING("max_row_errors", driver.loc_); + return isc::dhcp::Dhcp6Parser::make_STRING("max-row-errors", driver.loc_); } } diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index 778c9a8e10..07c975d4b1 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -664,8 +664,8 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set, if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); - db::DbAccessParser parser; for (auto it : hosts_databases->listValue()) { + db::DbAccessParser parser; std::string access_string; parser.parse(access_string, it); cfg_db_access->setHostDbAccessString(access_string); diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index f6d0eeef81..5c9c3e48c0 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -7,6 +7,9 @@ #include #include +#include +#include +#include #include #include #include @@ -17,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +35,6 @@ #include #include #include -#include #include #include @@ -41,10 +43,13 @@ #include #include #include +#include using namespace isc; -using namespace isc::data; using namespace isc::asiolink; +using namespace isc::cb; +using namespace isc::config; +using namespace isc::data; using namespace isc::dhcp; using namespace isc::dhcp::test; using namespace isc::util; @@ -145,6 +150,118 @@ const char* CONFIGS[] = { "}" }; +} // namespace + +namespace isc { +namespace dhcp { +namespace test { + +void +Dhcpv6SrvTest::loadConfigFile(const string& path) { + CfgMgr::instance().clear(); + + LibDHCP::clearRuntimeOptionDefs(); + + IfaceMgrTestConfig test_config(true); + + // Do not use DHCP6_SERVER_PORT here as 0 means don't open sockets. + NakedDhcpv6Srv srv(0); + EXPECT_EQ(0, srv.server_port_); + + ConfigBackendDHCPv6Mgr::instance().registerBackendFactory("mysql", + [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv6Ptr { + return (ConfigBackendDHCPv6Ptr()); + }); + + ConfigBackendDHCPv6Mgr::instance().registerBackendFactory("postgresql", + [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv6Ptr { + return (ConfigBackendDHCPv6Ptr()); + }); + + // TimerMgr uses IO service to run asynchronous timers. + TimerMgr::instance()->setIOService(srv.getIOService()); + + // CommandMgr uses IO service to run asynchronous socket operations. + CommandMgr::instance().setIOService(srv.getIOService()); + + // LeaseMgr uses IO service to run asynchronous timers. + LeaseMgr::setIOService(srv.getIOService()); + + // HostMgr uses IO service to run asynchronous timers. + HostMgr::setIOService(srv.getIOService()); + + Parser6Context parser; + ConstElementPtr json; + ASSERT_NO_THROW(json = parser.parseFile(path, Parser6Context::PARSER_DHCP6)); + ASSERT_TRUE(json); + + // Check the logic next. + ConstElementPtr dhcp6 = json->get("Dhcp6"); + ASSERT_TRUE(dhcp6); + ElementPtr mutable_config = boost::const_pointer_cast(dhcp6); + mutable_config->set(string("hooks-libraries"), Element::createList()); + ASSERT_NO_THROW(Dhcpv6SrvTest::configure(dhcp6->str(), true, true, true, true)); + + LeaseMgrFactory::destroy(); + HostMgr::create(); + + TimerMgr::instance()->unregisterTimers(); + + // Close the command socket (if it exists). + CommandMgr::instance().closeCommandSocket(); + + // CommandMgr uses IO service to run asynchronous socket operations. + CommandMgr::instance().setIOService(IOServicePtr()); + + // LeaseMgr uses IO service to run asynchronous timers. + LeaseMgr::setIOService(IOServicePtr()); + + // HostMgr uses IO service to run asynchronous timers. + HostMgr::setIOService(IOServicePtr()); +} + +void +Dhcpv6SrvTest::checkConfigFiles() { + IfaceMgrTestConfig test_config(true); + string path = CFG_EXAMPLES; + + DIR* dir = opendir(path.c_str()); + if (!dir) { + return; + } + + // Set of sorted files by name. + std::set files; + + for (struct dirent* dent = readdir(dir); dent; dent = readdir(dir)) { + std::string name(dent->d_name); + // Skip current and parent directory and files with no extension. + if (name.size() < (sizeof(".json") - 1)) { + continue; + } + + // Skip non .json files. + if (name.substr(name.size() - (sizeof(".json") - 1)) != ".json") { + continue; + } + name = path + "/" + name; + files.emplace(name); + } + + for (const auto& file: files) { + string label("Checking configuration from file: "); + label += file; + SCOPED_TRACE(label); + loadConfigFile(file); + } +} + +} // end of isc::dhcp::test namespace +} // end of isc::dhcp namespace +} // end of isc namespace + +namespace { + // This test verifies that incoming SOLICIT can be handled properly when // there are no subnets configured. // @@ -454,7 +571,6 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) { // more checks to be implemented } - // There are no dedicated tests for Dhcpv6Srv::handleIA_NA and Dhcpv6Srv::assignLeases // as they are indirectly tested in Solicit and Request tests. @@ -522,7 +638,6 @@ TEST_F(Dhcpv6SrvTest, SolicitBasic) { // - server-id // - IA that includes IAPREFIX TEST_F(Dhcpv6SrvTest, pdSolicitBasic) { - NakedDhcpv6Srv srv(0); Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234)); @@ -1241,7 +1356,6 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) { // - server-id // - IA that includes IAPREFIX TEST_F(Dhcpv6SrvTest, pdRequestBasic) { - NakedDhcpv6Srv srv(0); // Let's create a REQUEST @@ -2017,9 +2131,9 @@ TEST_F(Dhcpv6SrvTest, sanityCheckServerId) { // Check that the server is testing if server identifier received in the // query, matches server identifier used by the server. TEST_F(Dhcpv6SrvTest, testServerID) { - NakedDhcpv6Srv srv(0); + NakedDhcpv6Srv srv(0); - Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234)); + Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234)); std::vector bin; // duid_llt constructed with: time = 0, macaddress = 00:00:00:00:00:00 @@ -2093,8 +2207,6 @@ TEST_F(Dhcpv6SrvTest, testUnicast) { << static_cast(allowed_unicast[i]) << "being sent to unicast address"; } - - } // This test verifies if selectSubnet() selects proper subnet for a given @@ -2413,7 +2525,6 @@ TEST_F(Dhcpv6SrvTest, selectSubnetRelayInterfaceId) { // Checks if server responses are sent to the proper port. TEST_F(Dhcpv6SrvTest, portsClientPort) { - NakedDhcpv6Srv srv(0); // Enforce a specific client port value. @@ -2442,7 +2553,6 @@ TEST_F(Dhcpv6SrvTest, portsClientPort) { // Checks if server responses are sent to the proper port. TEST_F(Dhcpv6SrvTest, portsServerPort) { - // Create the test server in test mode. NakedDhcpv6Srv srv(0); @@ -2472,7 +2582,6 @@ TEST_F(Dhcpv6SrvTest, portsServerPort) { // Checks if server responses are sent to the proper port. TEST_F(Dhcpv6SrvTest, portsDirectTraffic) { - NakedDhcpv6Srv srv(0); // Let's create a simple SOLICIT @@ -2497,7 +2606,6 @@ TEST_F(Dhcpv6SrvTest, portsDirectTraffic) { // Checks if server responses are sent to the proper port. TEST_F(Dhcpv6SrvTest, portsRelayedTraffic) { - NakedDhcpv6Srv srv(0); // Let's create a simple SOLICIT @@ -2522,7 +2630,6 @@ TEST_F(Dhcpv6SrvTest, portsRelayedTraffic) { // Test that the server processes relay-source-port option correctly. TEST_F(Dhcpv6SrvTest, relaySourcePort) { - NakedDhcpv6Srv srv(0); string config = @@ -2700,7 +2807,6 @@ TEST_F(Dhcpv6SrvTest, prlPersistency) { // @todo Uncomment this test as part of #3180 work. // Kea code currently fails to handle docsis traffic. TEST_F(Dhcpv6SrvTest, docsisTraffic) { - NakedDhcpv6Srv srv(0); // Let's get a traffic capture from DOCSIS3.0 modem @@ -2720,7 +2826,6 @@ TEST_F(Dhcpv6SrvTest, docsisTraffic) { ASSERT_TRUE(adv); } - // Checks if relay IP address specified in the relay-info structure in // subnet6 is being used properly. TEST_F(Dhcpv6SrvTest, relayOverride) { @@ -3261,7 +3366,6 @@ TEST_F(Dhcpv6SrvTest, tooLongServerId) { // Checks if user-contexts are parsed properly. TEST_F(Dhcpv6SrvTest, userContext) { - IfaceMgrTestConfig test_config(true); NakedDhcpv6Srv srv(0); @@ -3474,6 +3578,10 @@ TEST_F(Dhcpv6SrvTest, calculateTeeTimers) { } } +TEST_F(Dhcpv6SrvTest, checkConfigFiles) { + checkConfigFiles(); +} + /// @todo: Add more negative tests for processX(), e.g. extend sanityCheck() test /// to call processX() methods. diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc index 670a65edbb..ce8dcf02ea 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc @@ -8,13 +8,13 @@ #include #include #include +#include +#include #include #include -#include #include -#include -#include #include +#include #include #include #include @@ -211,7 +211,6 @@ Dhcpv6SrvTest::checkPdLease(const DuidPtr& duid, const OptionPtr& ia_pd, return (lease); } - Pkt6Ptr Dhcpv6SrvTest::createMessage(uint8_t message_type, Lease::Type lease_type, const IOAddress& addr, const uint8_t prefix_len, @@ -812,12 +811,21 @@ Dhcpv6SrvTest::testReceiveStats(uint8_t pkt_type, const std::string& stat_name) } void -Dhcpv6SrvTest::configure(const std::string& config) { - configure(config, srv_); +Dhcpv6SrvTest::configure(const std::string& config, + const bool commit, + const bool open_sockets, + const bool create_managers, + const bool test) { + configure(config, srv_, commit, open_sockets, create_managers, test); } void -Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) { +Dhcpv6SrvTest::configure(const std::string& config, + NakedDhcpv6Srv& srv, + const bool commit, + const bool open_sockets, + const bool create_managers, + const bool test) { setenv("KEA_LFC_EXECUTABLE", KEA_LFC_EXECUTABLE, 1); MultiThreadingCriticalSection cs; ConstElementPtr json; @@ -825,7 +833,9 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) { json = parseJSON(config); } catch (const std::exception& ex) { // Fatal failure on parsing error - FAIL() << "config parsing failed, test is broken: " << ex.what(); + FAIL() << "parsing failure:" + << "config:" << config << std::endl + << "error: " << ex.what(); } ConstElementPtr status; @@ -837,13 +847,22 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) { configureMultiThreading(multi_threading_, json); // Configure the server and make sure the config is accepted - EXPECT_NO_THROW(status = configureDhcp6Server(srv, json)); + EXPECT_NO_THROW(status = configureDhcp6Server(srv, json, test)); ASSERT_TRUE(status); int rcode; ConstElementPtr comment = isc::config::parseAnswer(rcode, status); ASSERT_EQ(0, rcode) << "configuration failed, test is broken: " << comment->str(); + // Use specified lease database backend. + if (create_managers) { + ASSERT_NO_THROW( { + CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess(); + cfg_db->setAppendedParameters("universe=6"); + cfg_db->createManagers(); + } ); + } + try { CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading()); } catch (const std::exception& ex) { @@ -851,7 +870,14 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) { << ex.what(); } - CfgMgr::instance().commit(); + if (commit) { + CfgMgr::instance().commit(); + } + + // Opening sockets. + if (open_sockets) { + IfaceMgr::instance().openSockets6(); + } } NakedDhcpv6SrvTest::NakedDhcpv6SrvTest() diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h index 69a7021c0e..65481fef54 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.h +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h @@ -6,13 +6,15 @@ /// @file dhcp6_test_utils.h /// -/// @brief This file contains utility classes used for DHCPv6 server testing +/// @brief This file contains utility classes used for DHCPv6 server testing #ifndef DHCP6_TEST_UTILS_H #define DHCP6_TEST_UTILS_H #include +#include +#include #include #include #include @@ -26,8 +28,6 @@ #include #include #include -#include -#include #include #include @@ -68,7 +68,6 @@ struct SpecializedTypeWrapper { ValueType value_; }; - /// @brief Class representing strongly typed IAID. struct IAID : public SpecializedTypeWrapper { /// @brief Constructor @@ -80,7 +79,7 @@ struct IAID : public SpecializedTypeWrapper { /// @brief Class representing strongly typed value for strict IAID checks. /// -/// Strict IAID checks are used to verify that the particular address has been +/// Strict IAID checks are used to verify that the particular address has been /// assign to a specific IA. In many cases we don't check that because it may /// not be possible to predict to which IA the specific lease will be assigned. struct StrictIAIDChecking : public SpecializedTypeWrapper { @@ -106,7 +105,6 @@ struct StrictIAIDChecking : public SpecializedTypeWrapper { } }; - /// @brief Base class for DHCPv6 server testing. /// /// Currently it configures the test data path directory in @@ -128,7 +126,6 @@ private: /// @brief Holds the original data directory. std::string original_datadir_; - }; /// @brief "naked" Dhcpv6Srv class that exposes internal members @@ -360,7 +357,7 @@ public: /// @brief Generate binary data option /// /// Creates an Option in the V6 space with the given type and binary data - /// of the given number of bytes. The data is initialized to the values + /// of the given number of bytes. The data is initialized to the values /// 100 to 100 + n, where n is the desired number of bytes. /// /// @param type option type for the new option @@ -567,13 +564,36 @@ public: /// @brief Runs DHCPv6 configuration from the JSON string. /// /// @param config String holding server configuration in JSON format. - void configure(const std::string& config); + /// @param commit A boolean flag indicating if the new configuration + /// should be committed (if true), or not (if false). + /// @param open_sockets A boolean flag indicating if sockets should + /// be opened (if true), or not (if false). + /// @param create_managers A boolean flag indicating if managers should be + /// recreated. + /// @param test A boolean flag which indicates if only testing config. + void configure(const std::string& config, + const bool commit = true, + const bool open_sockets = false, + const bool create_managers = true, + const bool test = false); /// @brief Configure the DHCPv6 server using the JSON string. /// /// @param config String holding server configuration in JSON format. /// @param srv Server to be configured. - void configure(const std::string& config, NakedDhcpv6Srv& srv); + /// @param commit A boolean flag indicating if the new configuration + /// should be committed (if true), or not (if false). + /// @param open_sockets A boolean flag indicating if sockets should + /// be opened (if true), or not (if false). + /// @param create_managers A boolean flag indicating if managers should be + /// recreated. + /// @param test A boolean flag which indicates if only testing config. + void configure(const std::string& config, + NakedDhcpv6Srv& srv, + const bool commit = true, + const bool open_sockets = false, + const bool create_managers = true, + const bool test = false); /// @brief Checks that server response (ADVERTISE or REPLY) contains proper /// IA_NA option @@ -599,7 +619,6 @@ public: checkIA_PD(const isc::dhcp::Pkt6Ptr& rsp, uint32_t expected_iaid, uint32_t expected_t1, uint32_t expected_t2); - // Check that generated IAADDR option contains expected address // and lifetime values match the configured subnet /// @param expected_pref check that lease preferedlifetime has the not-zero @@ -612,7 +631,6 @@ public: uint32_t expected_pref = 0, uint32_t expected_valid = 0) { - // Check that the assigned address is indeed from the configured pool. // Note that when comparing addresses, we compare the textual // representation. IOAddress does not support being streamed to @@ -800,7 +818,7 @@ public: /// @brief Performs negative RELEASE test /// /// See releaseReject and pdReleaseReject tests for detailed - /// explanation. In essence the test attempts to perform couple + /// explanation. In essence the test attempts to perform couple /// failed RELEASE scenarios. /// /// This method does not throw, but uses gtest macros to signify failures. @@ -822,6 +840,14 @@ public: multi_threading_ = enabled; } + /// @breif Check if example files contain valid configuration. + void checkConfigFiles(); + + /// @brief Check if the server configuration stored in file is valid. + /// + /// @param path The path to the configuration file. + void loadConfigFile(const std::string& path); + /// A subnet used in most tests. isc::dhcp::Subnet6Ptr subnet_; diff --git a/src/bin/dhcp6/tests/shared_network_unittest.cc b/src/bin/dhcp6/tests/shared_network_unittest.cc index c93464ab78..714102f44b 100644 --- a/src/bin/dhcp6/tests/shared_network_unittest.cc +++ b/src/bin/dhcp6/tests/shared_network_unittest.cc @@ -1754,7 +1754,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationInSharedNetwork) { // Reconfigure the server. Now, the first client get's second client's // reservation and vice versa. - ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[5], *client1.getServer())); + ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[5], *client1.getServer(), true, true, false)); // The first client is trying to renew the lease but should get a different lease // because its lease is now reserved for some other client. The client won't be diff --git a/src/share/api/lease6-del.json b/src/share/api/lease6-del.json index 0fdf425fb5..8164aa52ac 100644 --- a/src/share/api/lease6-del.json +++ b/src/share/api/lease6-del.json @@ -11,7 +11,7 @@ "{", " \"command\": \"lease6-del\",", " \"arguments\": {", - " \"ip-address\": \"192.0.2.202\"", + " \"ip-address\": \"2001:db8::3\"", " }", "}" ],