From: Razvan Becheriu Date: Wed, 29 Jul 2020 14:57:23 +0000 (+0300) Subject: [#1349] addressed comments X-Git-Tag: Kea-1.8.0~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acfe55903249eeeb6a6c83b591260cbfd600f27b;p=thirdparty%2Fkea.git [#1349] addressed comments --- diff --git a/src/hooks/dhcp/lease_cmds/lease_parser.cc b/src/hooks/dhcp/lease_cmds/lease_parser.cc index 76dcb104bf..40bad71216 100644 --- a/src/hooks/dhcp/lease_cmds/lease_parser.cc +++ b/src/hooks/dhcp/lease_cmds/lease_parser.cc @@ -331,9 +331,9 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, "values are: 0 (default), 1 (declined) and 2 (expired-reclaimed)"); } - if (state == Lease::STATE_DECLINED && type == Lease::TYPE_PD) { + if ((state == Lease::STATE_DECLINED) && (type == Lease::TYPE_PD)) { isc_throw(isc::InvalidOperation, - "Invalid PD address in declined state."); + "Invalid PD prefix in declined state."); } // Handle user context. 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 b47ee7e435..0f5f280cc4 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -1282,7 +1282,7 @@ TEST_F(LeaseCmdsTest, Lease6AddBadParams) { "2001:db8:1::1"; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); - // Invalid PD address in declined state. + // Invalid PD prefix in declined state. txt = "{\n" " \"command\": \"lease6-add\",\n" @@ -1291,12 +1291,12 @@ TEST_F(LeaseCmdsTest, Lease6AddBadParams) { " \"ip-address\": \"2001:db8:1::1\",\n" " \"prefix-len\": 48,\n" " \"type\": \"IA_PD\",\n" - " \"state\": 1," " \"duid\": \"1a:1b:1c:1d:1e:1f\",\n" - " \"iaid\": 1234\n" + " \"iaid\": 1234,\n" + " \"state\": 1" " }\n" "}"; - exp_rsp = "Invalid PD address in declined state."; + exp_rsp = "Invalid PD prefix in declined state."; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); } @@ -3676,7 +3676,7 @@ TEST_F(LeaseCmdsTest, Lease6UpdateBadParams) { "'{ \"comment\": \"in user context\" }'"; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); - // Invalid PD address in declined state. + // Invalid PD prefix in declined state. txt = "{\n" " \"command\": \"lease6-update\",\n" @@ -3685,12 +3685,12 @@ TEST_F(LeaseCmdsTest, Lease6UpdateBadParams) { " \"ip-address\": \"2001:db8:1::1\",\n" " \"prefix-len\": 48,\n" " \"type\": \"IA_PD\",\n" - " \"state\": 1," " \"duid\": \"1a:1b:1c:1d:1e:1f\",\n" - " \"iaid\": 1234\n" + " \"iaid\": 1234,\n" + " \"state\": 1" " }\n" "}"; - exp_rsp = "Invalid PD address in declined state."; + exp_rsp = "Invalid PD prefix in declined state."; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); } @@ -4706,14 +4706,14 @@ TEST_F(LeaseCmdsTest, Lease6BulkApplyAddsOnlyBadParam) { " \"ip-address\": \"2001:db8:1::123\",\n" " \"prefix-len\": 48,\n" " \"type\": \"IA_PD\",\n" - " \"state\": 1," " \"duid\": \"11:11:11:11:11:11\",\n" - " \"iaid\": 1234\n" + " \"iaid\": 1234,\n" + " \"state\": 1" " }" " ]" " }" "}"; - string exp_rsp = "Invalid PD address in declined state."; + string exp_rsp = "Invalid PD prefix in declined state."; testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); // Check that the lease was not inserted. @@ -4784,14 +4784,14 @@ TEST_F(LeaseCmdsTest, Lease6BulkApplyUpdatesOnlyBadParam) { " \"ip-address\": \"2001:db8:1234:ab::\",\n" " \"prefix-len\": 56,\n" " \"type\": \"IA_PD\",\n" - " \"state\": 1," " \"duid\": \"77:77:77:77:77:77\",\n" - " \"iaid\": 1234\n" + " \"iaid\": 1234,\n" + " \"state\": 1" " }" " ]" " }" "}"; - string exp_rsp = "Invalid PD address in declined state."; + string exp_rsp = "Invalid PD prefix in declined state."; testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); // Check that the lease we inserted is stored.