From: Marcin Siodelski Date: Thu, 14 Sep 2017 11:10:34 +0000 (+0200) Subject: [5306] Added stub unit tests for shared networks in DHCPv4. X-Git-Tag: trac5363_base~21^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ef428aff6715fab68f819d27c2c77521c9f5c16;p=thirdparty%2Fkea.git [5306] Added stub unit tests for shared networks in DHCPv4. --- diff --git a/src/bin/dhcp4/tests/Makefile.am b/src/bin/dhcp4/tests/Makefile.am index 63955a0ab9..4a82bc66ae 100644 --- a/src/bin/dhcp4/tests/Makefile.am +++ b/src/bin/dhcp4/tests/Makefile.am @@ -96,6 +96,7 @@ dhcp4_unittests_SOURCES += kea_controller_unittest.cc dhcp4_unittests_SOURCES += dhcp4to6_ipc_unittest.cc dhcp4_unittests_SOURCES += simple_parser4_unittest.cc dhcp4_unittests_SOURCES += get_config_unittest.cc get_config_unittest.h +dhcp4_unittests_SOURCES += shared_network_unittest.cc nodist_dhcp4_unittests_SOURCES = marker_file.h test_libraries.h diff --git a/src/bin/dhcp4/tests/shared_network_unittest.cc b/src/bin/dhcp4/tests/shared_network_unittest.cc new file mode 100644 index 0000000000..6746f09dc4 --- /dev/null +++ b/src/bin/dhcp4/tests/shared_network_unittest.cc @@ -0,0 +1,135 @@ +// Copyright (C) 2017 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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include +#include +#include +#include +#include + +using namespace isc; +using namespace isc::asiolink; +using namespace isc::dhcp; +using namespace isc::dhcp::test; +using namespace isc::stats; + +namespace { + +const char* NETWORKS_CONFIG[] = { + "{" + " \"interfaces-config\": {" + " \"interfaces\": [ \"*\" ]" + "}," + "\"valid-lifetime\": 600," + "\"shared-networks\": [" + " {" + " \"name\": \"frog\"" + " \"subnet4\": [" + " {" + " \"subnet\": \"192.0.2.0/26\"," + " \"id\": 10," + " \"pools\": [" + " {" + " \"pool\": \"192.0.2.1 - 192.0.2.63\"" + " }" + " ]" + " }," + " {" + " \"subnet\": \"10.0.0.0/24\"," + " \"id\": 100," + " \"pools\": [" + " {" + " \"pool\": \10.0.0.1 - 10.0.0.254\"" + " }" + " ]" + " }" + " ]" + " }" + "]," + "\"subnet4\": [" + " \"subnet\": \"192.0.2.64/26\"," + " \"id\": 1000," + " \"pools\": [" + " {" + " \"pool\": \"192.0.2.65 - 192.0.2.127\"" + " }" + " ]" + "]" +}; + +/// @brief Test fixture class for DHCPv4 server using shared networks. +class Dhcpv4SharedNetworkTest : public Dhcpv4SrvTest { +public: + + /// @brief Constructor. + Dhcpv4SharedNetworkTest() + : Dhcpv4SrvTest(), + iface_mgr_test_config_(true) { + IfaceMgr::instance().openSockets4(); + StatsMgr::instance().removeAll(); + } + + /// @brief Destructor. + virtual ~Dhcpv4SharedNetworkTest() { + StatsMgr::instance().removeAll(); + } + + /// @brief Interface Manager's fake configuration control. + IfaceMgrTestConfig iface_mgr_test_config_; +}; + +// Selected subnet is out of shared network. +TEST_F(Dhcpv4SharedNetworkTest, outOfSharedNetworkAllocation) { +} + +// Shared network is selected based on giaddr value. +TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectedByRelay) { +} + +// Running out of addresses within a subnet in a shared network. +TEST_F(Dhcpv4SharedNetworkTest, poolInSharedNetworkShortage) { +} + +// Running out of addresses within entire shared network. +TEST_F(Dhcpv4SharedNetworkTest, addressShortageInNetwork) { +} + +// Providing a hint for any address belonging to a shared network. +TEST_F(Dhcpv4SharedNetworkTest, hintWithinSharedNetwork) { +} + +// Access to a subnet within shared network is restricted by client +// classification. +TEST_F(Dhcpv4SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { +} + +// IPv4 address reservation exists in one of the subnets within +// shared network. +TEST_F(Dhcpv4SharedNetworkTest, reservationInSharedNetwork) { +} + +// Reserved address can't be assigned until access to a subnet is +// restricted by classification. +TEST_F(Dhcpv4SharedNetworkTest, reservationAccessRestrictedByClass) { +} + +// Multiple subnets within a shared network contain reservations for +// the same client. +TEST_F(Dhcpv4SharedNetworkTest, reservationsInDifferentSubnets) { +} + +// Some options are specified on the shared subnet level, some on the +// subnets level. +TEST_F(Dhcpv4SharedNetworkTest, optionsDerivation) { +} + +// Host reservations include class specification. +TEST_F(Dhcpv4SharedNetworkTest, classesInReservations) { +} + + + +} // end of anonymous namespace