From fdcced6640750bf03c552c4c765675515050581e Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Tue, 5 Mar 2019 12:03:45 +0100 Subject: [PATCH] [#488,!259] Correct unit tests failing after recent code updates. --- src/bin/dhcp4/tests/get_config_unittest.cc | 5 +++-- src/bin/dhcp6/tests/get_config_unittest.cc | 9 ++++++--- src/lib/dhcpsrv/network.cc | 8 +++++--- src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc | 4 +--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index 9be8afaac4..355e8f71fc 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8286,7 +8286,8 @@ const char* UNPARSED_CONFIGS[] = { " \"subnet\": \"192.0.1.0/24\",\n" " \"valid-lifetime\": 7200\n" " }\n" -" ]\n" +" ],\n" +" \"valid-lifetime\": 7200\n" " }\n" " ],\n" " \"subnet4\": [ ]\n" diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc b/src/bin/dhcp6/tests/get_config_unittest.cc index 810576f275..561d4c183a 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc +++ b/src/bin/dhcp6/tests/get_config_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7477,11 +7477,13 @@ const char* UNPARSED_CONFIGS[] = { " \"comment\": \"A shared network\",\n" " \"name\": \"foo\",\n" " \"option-data\": [ ],\n" -" \"preferred-lifetime\": 0,\n" +" \"preferred-lifetime\": 3600,\n" " \"rapid-commit\": false,\n" +" \"rebind-timer\": 1800,\n" " \"relay\": {\n" " \"ip-addresses\": [ ]\n" " },\n" +" \"renew-timer\": 900,\n" " \"reservation-mode\": \"all\",\n" " \"subnet6\": [\n" " {\n" @@ -7536,7 +7538,8 @@ const char* UNPARSED_CONFIGS[] = { " \"subnet\": \"2001:db1::/48\",\n" " \"valid-lifetime\": 7200\n" " }\n" -" ]\n" +" ],\n" +" \"valid-lifetime\": 7200\n" " }\n" " ],\n" " \"subnet6\": [ ]\n" diff --git a/src/lib/dhcpsrv/network.cc b/src/lib/dhcpsrv/network.cc index af2e1262f1..ae57abdcef 100644 --- a/src/lib/dhcpsrv/network.cc +++ b/src/lib/dhcpsrv/network.cc @@ -230,9 +230,11 @@ Network6::toElement() const { ElementPtr map = Network::toElement(); // Set preferred-lifetime - map->set("preferred-lifetime", - Element::create(static_cast - (getPreferred().get()))); + if (!getPreferred().unspecified()) { + map->set("preferred-lifetime", + Element::create(static_cast + (getPreferred().get()))); + } // Set interface-id const OptionPtr& ifaceid = getInterfaceId(); diff --git a/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc index d71670c1d8..1e9a01eda3 100644 --- a/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -129,7 +129,6 @@ TEST(CfgSharedNetworks6Test, unparse) { " \"interface\": \"eth1\",\n" " \"name\": \"dog\",\n" " \"option-data\": [ ],\n" - " \"preferred-lifetime\": 0,\n" " \"rapid-commit\": false,\n" " \"rebind-timer\": 200,\n" " \"relay\": { \"ip-addresses\": [ ] },\n" @@ -142,7 +141,6 @@ TEST(CfgSharedNetworks6Test, unparse) { " \"interface\": \"eth0\",\n" " \"name\": \"frog\",\n" " \"option-data\": [ ],\n" - " \"preferred-lifetime\": 0,\n" " \"rapid-commit\": false,\n" " \"relay\": { \"ip-addresses\": [ \"2001:db8:1::1\", \"2001:db8:1::2\" ] },\n" " \"reservation-mode\": \"all\"," -- 2.47.2