From: Tomek Mrugalski Date: Mon, 23 Oct 2017 14:56:05 +0000 (+0100) Subject: [5396] Changes after review: X-Git-Tag: Kea-1.3.0~2^2~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1604233053e5b84eca76de3a08696a4eb7dca0af;p=thirdparty%2Fkea.git [5396] Changes after review: - couple minor corrections in docs - one extra unit-test added --- diff --git a/doc/guide/hooks.xml b/doc/guide/hooks.xml index 02052ba3fe..f95795e2d7 100644 --- a/doc/guide/hooks.xml +++ b/doc/guide/hooks.xml @@ -891,7 +891,7 @@ Administrator deleted a lease for a device identified by: duid of 1a:1b:1c:1d:1e The section describes commands used to retrieve, update and delete leases using various identifiers, e.g. "hw-address", - "client-id". The lease_cmds library doesn't navtively support querying for + "client-id". The lease_cmds library doesn't natively support querying for leases by flexible identifier. However, when "replace-client-id" is set to true, it makes it possible to query for leases using a value derived from the flexible identifier. In the DHCPv4 case, the query will look similar to this: @@ -992,7 +992,7 @@ Requirements document.
reservation-add command - reservation-add allows insertion of a new host. It + reservation-add allows for the insertion of a new host. It takes a set of arguments that vary depending on the nature of the host reservation. Any parameters allowed in the configuration file that pertain to host reservation are permitted here. For details regarding @@ -1325,7 +1325,7 @@ An example deletion by (subnet-id, identifier-type, identifier) looks as follows lease4-add, lease6-add commands lease4-add and lease6-add - commands allow for creation of a new lease. Typically Kea creates a lease + commands allow for the creation of a new lease. Typically Kea creates a lease on its own, when it first sees a new device. However, sometimes it may be convenient to create the lease administratively. The lease4-add command requires at least three @@ -1479,7 +1479,7 @@ The commands can take a number of additional optional parameters: used when the address (either IPv4 or IPv6) is known, but the details of the lease aren't. One common use case of this type of query is to find out whether a given address is being used or not. The second - query uses identifiers. Currently supported identifiers for are: + query uses identifiers. Currently supported identifiers for leases are: "hw-address" (IPv4 only), "client-id" (IPv4 only) and "duid" (IPv6 only). @@ -1626,7 +1626,7 @@ An example IPv4 lease deletion by "hw-address" looks as follows: leaseX-del returns a result that indicates a outcome of the operation. It has one of the - following values: 0 (success), 1 (error) or 2 (empty). The + following values: 0 (success), 1 (error) or 3 (empty). The empty result means that a query has been completed properly, but the object (a lease in this case) has not been found. diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 1d0584b86e..ff0d3b9a44 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -1169,6 +1169,26 @@ TEST_F(LeaseCmdsTest, Lease4GetByClientId) { checkLease4(lease, "192.0.2.1", 44, "08:08:08:08:08:08", false); } +// Checks that lease6-get rejects queries by client-id. +TEST_F(LeaseCmdsTest, Lease6GetByClientIdInvalidType) { + + // Initialize lease manager (true = v6, true = add a lease) + initLeaseMgr(true, true); + + // client-id query is allowed in v4 only. + string cmd = + "{\n" + " \"command\": \"lease6-get\",\n" + " \"arguments\": {" + " \"identifier-type\": \"client-id\"," + " \"identifier\": \"01:02:03:04\"," + " \"subnet-id\": 44" + " }\n" + "}"; + string exp_rsp = "Query by client-id is not allowed in v6."; + ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); +} + // Checks that lease6-get(subnet-id, addr) can handle a situation when // the query is correctly formed, but the lease is not there. TEST_F(LeaseCmdsTest, Lease6GetByDuidNotFound) {