#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/utils.h>
+#include <dhcpsrv/host_mgr.h>
#include <gtest/gtest.h>
#include <stats/stats_mgr.h>
#include <boost/scoped_ptr.hpp>
" \"valid-lifetime\": 4000,"
" \"interface\": \"eth0\" "
" } ],"
- "\"valid-lifetime\": 4000 }"
+ "\"valid-lifetime\": 4000 }",
+
+ // Configuration 1:
+ // - 1 subnet: 192.0.2.0/24
+ // - MySQL Host Data Source configured
+ "{ \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},"
+ "\"hosts-database\": {"
+ " \"type\": \"mysql\","
+ " \"name\": \"keatest\","
+ " \"user\": \"keatest\","
+ " \"password\": \"keatest\""
+ "},"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet4\": [ { "
+ " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
+ " \"subnet\": \"192.0.2.0/24\", "
+ " \"rebind-timer\": 2000, "
+ " \"renew-timer\": 1000, "
+ " \"valid-lifetime\": 4000,"
+ " \"interface\": \"eth0\" "
+ " } ],"
+ "\"valid-lifetime\": 4000 }"
};
// This test verifies that the destination address of the response
EXPECT_EQ(1, drop_stat->getInteger().first);
}
+#ifdef HAVE_MYSQL
+// Checks if the v4 server can be configured to use MySQL HostDataSource.
+TEST_F(Dhcpv4SrvTest, hostDataSourceMySQL) {
+ IfaceMgrTestConfig test_config(true);
+ IfaceMgr::instance().openSockets4();
+
+ NakedDhcpv4Srv srv(0);
+
+ EXPECT_NO_THROW(configure(CONFIGS[1]));
+
+ HostDataSourcePtr hds;
+ hds = HostMgr::instance().getHostDataSource();
+
+ /// @todo: Uncomment this once #3682 is merged.
+ /// EXPECT_TRUE(hds);
+}
+
+#endif
+
}; // end of anonymous namespace
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
+#include <dhcpsrv/host_mgr.h>
#include <dhcpsrv/utils.h>
#include <util/buffer.h>
#include <util/range_utilities.h>
namespace {
+const char* CONFIGS[] = {
+ // Configuration 0:
+ // - used in advertiseOptions
+ "{ \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},"
+ "\"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\", "
+ " \"interface\": \"eth0\", "
+ " \"option-data\": [ {"
+ " \"name\": \"dns-servers\","
+ " \"data\": \"2001:db8:1234:FFFF::1, 2001:db8:1234:FFFF::2\""
+ " },"
+ " {"
+ " \"name\": \"subscriber-id\","
+ " \"data\": \"1234\","
+ " \"csv-format\": False"
+ " } ]"
+ " } ],"
+ "\"valid-lifetime\": 4000 }",
+
+ // Configuration 1:
+ // - a single subnet
+ // - MySQL host data source
+ "{ \"interfaces-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "},"
+ "\"hosts-database\": {"
+ " \"type\": \"mysql\","
+ " \"name\": \"keatest\","
+ " \"user\": \"keatest\","
+ " \"password\": \"keatest\""
+ "},"
+ "\"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
+ " \"subnet\": \"2001:db8:1::/48\" "
+ " } ],"
+ "\"valid-lifetime\": 4000 }"
+};
+
// This test verifies that incoming SOLICIT can be handled properly when
// there are no subnets configured.
//
IfaceMgrTestConfig test_config(true);
ConstElementPtr x;
- string config = "{ \"interfaces-config\": {"
- " \"interfaces\": [ \"*\" ]"
- "},"
- "\"preferred-lifetime\": 3000,"
- "\"rebind-timer\": 2000, "
- "\"renew-timer\": 1000, "
- "\"subnet6\": [ { "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
- " \"subnet\": \"2001:db8:1::/48\", "
- " \"interface\": \"eth0\", "
- " \"option-data\": [ {"
- " \"name\": \"dns-servers\","
- " \"data\": \"2001:db8:1234:FFFF::1, 2001:db8:1234:FFFF::2\""
- " },"
- " {"
- " \"name\": \"subscriber-id\","
- " \"data\": \"1234\","
- " \"csv-format\": False"
- " } ]"
- " } ],"
- "\"valid-lifetime\": 4000 }";
- ASSERT_NO_THROW(configure(config));
+ ASSERT_NO_THROW(configure(CONFIGS[0]));
Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
sol->setRemoteAddr(IOAddress("fe80::abcd"));
EXPECT_EQ(1, recv_drop->getInteger().first);
}
-
/// @todo: Add more negative tests for processX(), e.g. extend sanityCheck() test
/// to call processX() methods.
+#ifdef HAVE_MYSQL
+// Checks if the v6 server can be configured to use MySQL HostDataSource.
+TEST_F(Dhcpv6SrvTest, hostDataSourceMySQL) {
+
+ Dhcp6Client client;
+
+ EXPECT_NO_THROW(configure(CONFIGS[1], *client.getServer()));
+
+ HostDataSourcePtr hds;
+ hds = HostMgr::instance().getHostDataSource();
+
+ /// @todo: Uncomment this once #3682 is merged.
+ /// EXPECT_TRUE(hds);
+}
+#endif
} // end of anonymous namespace