dhcp6_test_utils.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. // Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. /// @file dhcp6_test_utils.h
  15. ///
  16. /// @brief This file contains utility classes used for DHCPv6 server testing
  17. #ifndef DHCP6_TEST_UTILS_H
  18. #define DHCP6_TEST_UTILS_H
  19. #include <gtest/gtest.h>
  20. #include <dhcp/pkt6.h>
  21. #include <dhcp/option6_ia.h>
  22. #include <dhcp/option6_iaaddr.h>
  23. #include <dhcp/option6_iaprefix.h>
  24. #include <dhcp/option_int_array.h>
  25. #include <dhcp/option_custom.h>
  26. #include <dhcp/option.h>
  27. #include <dhcp/iface_mgr.h>
  28. #include <dhcpsrv/cfgmgr.h>
  29. #include <dhcpsrv/lease_mgr.h>
  30. #include <dhcpsrv/lease_mgr_factory.h>
  31. #include <dhcp6/dhcp6_srv.h>
  32. #include <hooks/hooks_manager.h>
  33. #include <list>
  34. namespace isc {
  35. namespace test {
  36. /// @brief "naked" Dhcpv6Srv class that exposes internal members
  37. class NakedDhcpv6Srv: public isc::dhcp::Dhcpv6Srv {
  38. public:
  39. NakedDhcpv6Srv(uint16_t port) : isc::dhcp::Dhcpv6Srv(port) {
  40. // Open the "memfile" database for leases
  41. std::string memfile = "type=memfile universe=6 persist=false";
  42. isc::dhcp::LeaseMgrFactory::create(memfile);
  43. }
  44. /// @brief fakes packet reception
  45. /// @param timeout ignored
  46. ///
  47. /// The method receives all packets queued in receive
  48. /// queue, one after another. Once the queue is empty,
  49. /// it initiates the shutdown procedure.
  50. ///
  51. /// See fake_received_ field for description
  52. virtual isc::dhcp::Pkt6Ptr receivePacket(int /*timeout*/) {
  53. // If there is anything prepared as fake incoming
  54. // traffic, use it
  55. if (!fake_received_.empty()) {
  56. isc::dhcp::Pkt6Ptr pkt = fake_received_.front();
  57. fake_received_.pop_front();
  58. return (pkt);
  59. }
  60. // If not, just trigger shutdown and
  61. // return immediately
  62. shutdown();
  63. return (isc::dhcp::Pkt6Ptr());
  64. }
  65. /// @brief fake packet sending
  66. ///
  67. /// Pretend to send a packet, but instead just store
  68. /// it in fake_send_ list where test can later inspect
  69. /// server's response.
  70. virtual void sendPacket(const isc::dhcp::Pkt6Ptr& pkt) {
  71. fake_sent_.push_back(pkt);
  72. }
  73. /// @brief adds a packet to fake receive queue
  74. ///
  75. /// See fake_received_ field for description
  76. void fakeReceive(const isc::dhcp::Pkt6Ptr& pkt) {
  77. fake_received_.push_back(pkt);
  78. }
  79. virtual ~NakedDhcpv6Srv() {
  80. // Close the lease database
  81. isc::dhcp::LeaseMgrFactory::destroy();
  82. }
  83. using Dhcpv6Srv::processSolicit;
  84. using Dhcpv6Srv::processRequest;
  85. using Dhcpv6Srv::processRenew;
  86. using Dhcpv6Srv::processRelease;
  87. using Dhcpv6Srv::processClientFqdn;
  88. using Dhcpv6Srv::createNameChangeRequests;
  89. using Dhcpv6Srv::createRemovalNameChangeRequest;
  90. using Dhcpv6Srv::createStatusCode;
  91. using Dhcpv6Srv::selectSubnet;
  92. using Dhcpv6Srv::testServerID;
  93. using Dhcpv6Srv::testUnicast;
  94. using Dhcpv6Srv::sanityCheck;
  95. using Dhcpv6Srv::classifyPacket;
  96. using Dhcpv6Srv::loadServerID;
  97. using Dhcpv6Srv::writeServerID;
  98. using Dhcpv6Srv::unpackOptions;
  99. using Dhcpv6Srv::shutdown_;
  100. using Dhcpv6Srv::name_change_reqs_;
  101. using Dhcpv6Srv::VENDOR_CLASS_PREFIX;
  102. using Dhcpv6Srv::createContext;
  103. /// @brief packets we pretend to receive
  104. ///
  105. /// Instead of setting up sockets on interfaces that change between
  106. /// OSes, it is much easier to fake packet reception. This is a list
  107. /// of packets that we pretend to have received. You can schedule
  108. /// new packets to be received using fakeReceive() and
  109. /// NakedDhcpv6Srv::receivePacket() methods.
  110. std::list<isc::dhcp::Pkt6Ptr> fake_received_;
  111. std::list<isc::dhcp::Pkt6Ptr> fake_sent_;
  112. };
  113. static const char* DUID_FILE = "server-id-test.txt";
  114. // test fixture for any tests requiring blank/empty configuration
  115. // serves as base class for additional tests
  116. class NakedDhcpv6SrvTest : public ::testing::Test {
  117. public:
  118. NakedDhcpv6SrvTest() : rcode_(-1) {
  119. // it's ok if that fails. There should not be such a file anyway
  120. unlink(DUID_FILE);
  121. const isc::dhcp::IfaceMgr::IfaceCollection& ifaces =
  122. isc::dhcp::IfaceMgr::instance().getIfaces();
  123. // There must be some interface detected
  124. if (ifaces.empty()) {
  125. // We can't use ASSERT in constructor
  126. ADD_FAILURE() << "No interfaces detected.";
  127. }
  128. valid_iface_ = (*ifaces.begin())->getName();
  129. }
  130. // Generate IA_NA or IA_PD option with specified parameters
  131. boost::shared_ptr<isc::dhcp::Option6IA> generateIA
  132. (uint16_t type, uint32_t iaid, uint32_t t1, uint32_t t2);
  133. /// @brief generates interface-id option, based on text
  134. ///
  135. /// @param iface_id textual representation of the interface-id content
  136. ///
  137. /// @return pointer to the option object
  138. isc::dhcp::OptionPtr generateInterfaceId(const std::string& iface_id) {
  139. isc::dhcp::OptionBuffer tmp(iface_id.begin(), iface_id.end());
  140. return (isc::dhcp::OptionPtr
  141. (new isc::dhcp::Option(isc::dhcp::Option::V6,
  142. D6O_INTERFACE_ID, tmp)));
  143. }
  144. // Generate client-id option
  145. isc::dhcp::OptionPtr generateClientId(size_t duid_size = 32) {
  146. isc::dhcp::OptionBuffer clnt_duid(duid_size);
  147. for (int i = 0; i < duid_size; i++) {
  148. clnt_duid[i] = 100 + i;
  149. }
  150. duid_ = isc::dhcp::DuidPtr(new isc::dhcp::DUID(clnt_duid));
  151. return (isc::dhcp::OptionPtr
  152. (new isc::dhcp::Option(isc::dhcp::Option::V6, D6O_CLIENTID,
  153. clnt_duid.begin(),
  154. clnt_duid.begin() + duid_size)));
  155. }
  156. // Checks if server response (ADVERTISE or REPLY) includes proper
  157. // server-id.
  158. void checkServerId(const isc::dhcp::Pkt6Ptr& rsp,
  159. const isc::dhcp::OptionPtr& expected_srvid)
  160. {
  161. // check that server included its server-id
  162. isc::dhcp::OptionPtr tmp = rsp->getOption(D6O_SERVERID);
  163. EXPECT_EQ(tmp->getType(), expected_srvid->getType() );
  164. ASSERT_EQ(tmp->len(), expected_srvid->len() );
  165. EXPECT_TRUE(tmp->getData() == expected_srvid->getData());
  166. }
  167. // Checks if server response (ADVERTISE or REPLY) includes proper
  168. // client-id.
  169. void checkClientId(const isc::dhcp::Pkt6Ptr& rsp,
  170. const isc::dhcp::OptionPtr& expected_clientid)
  171. {
  172. // check that server included our own client-id
  173. isc::dhcp::OptionPtr tmp = rsp->getOption(D6O_CLIENTID);
  174. ASSERT_TRUE(tmp);
  175. EXPECT_EQ(expected_clientid->getType(), tmp->getType());
  176. ASSERT_EQ(expected_clientid->len(), tmp->len());
  177. // check that returned client-id is valid
  178. EXPECT_TRUE(expected_clientid->getData() == tmp->getData());
  179. }
  180. // Checks if server response is a NAK
  181. void checkNakResponse(const isc::dhcp::Pkt6Ptr& rsp,
  182. uint8_t expected_message_type,
  183. uint32_t expected_transid,
  184. uint16_t expected_status_code,
  185. uint32_t expected_t1, uint32_t expected_t2)
  186. {
  187. // Check if we get response at all
  188. checkResponse(rsp, expected_message_type, expected_transid);
  189. // Check that IA_NA was returned
  190. isc::dhcp::OptionPtr option_ia_na = rsp->getOption(D6O_IA_NA);
  191. ASSERT_TRUE(option_ia_na);
  192. // check that the status is no address available
  193. boost::shared_ptr<isc::dhcp::Option6IA> ia =
  194. boost::dynamic_pointer_cast<isc::dhcp::Option6IA>(option_ia_na);
  195. ASSERT_TRUE(ia);
  196. checkIA_NAStatusCode(ia, expected_status_code, expected_t1,
  197. expected_t2);
  198. }
  199. /// @brief Checks that the server inserted expected status code in IA_NA
  200. ///
  201. /// Check that the server used status code as expected, i.e. that it has
  202. /// no addresses (if status code is non-zero) and that expected status
  203. /// code really appears there. In some limited cases (reply to RELEASE)
  204. /// it may be used to verify positive case, where IA_NA response is
  205. /// expected to not include address.
  206. ///
  207. /// Status code indicates type of error encountered (in theory it can also
  208. /// indicate success, but servers typically don't send success status
  209. /// as this is the default result and it saves bandwidth)
  210. /// @param ia IA_NA container to be checked
  211. /// @param expected_status_code expected value in status-code option
  212. /// @param expected_t1 expected T1 in IA_NA option
  213. /// @param expected_t2 expected T2 in IA_NA option
  214. /// @param check_addr whether to check for address with 0 lifetimes
  215. void checkIA_NAStatusCode
  216. (const boost::shared_ptr<isc::dhcp::Option6IA>& ia,
  217. uint16_t expected_status_code, uint32_t expected_t1,
  218. uint32_t expected_t2, bool check_addr = true);
  219. void checkMsgStatusCode(const isc::dhcp::Pkt6Ptr& msg,
  220. uint16_t expected_status)
  221. {
  222. isc::dhcp::OptionCustomPtr status =
  223. boost::dynamic_pointer_cast<isc::dhcp::OptionCustom>
  224. (msg->getOption(D6O_STATUS_CODE));
  225. // It is ok to not include status success as this is the default
  226. // behavior
  227. if (expected_status == STATUS_Success && !status) {
  228. return;
  229. }
  230. EXPECT_TRUE(status);
  231. if (status) {
  232. // We don't have dedicated class for status code, so let's
  233. // just interpret first 2 bytes as status. Remainder of the
  234. // status code option content is just a text explanation
  235. // what went wrong.
  236. EXPECT_EQ(static_cast<uint16_t>(expected_status),
  237. status->readInteger<uint16_t>(0));
  238. }
  239. }
  240. // Basic checks for generated response (message type and transaction-id).
  241. void checkResponse(const isc::dhcp::Pkt6Ptr& rsp,
  242. uint8_t expected_message_type,
  243. uint32_t expected_transid) {
  244. ASSERT_TRUE(rsp);
  245. EXPECT_EQ(expected_message_type, rsp->getType());
  246. EXPECT_EQ(expected_transid, rsp->getTransid());
  247. }
  248. virtual ~NakedDhcpv6SrvTest() {
  249. // Let's clean up if there is such a file.
  250. unlink(DUID_FILE);
  251. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  252. .deregisterAllCallouts("buffer6_receive");
  253. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  254. .deregisterAllCallouts("buffer6_send");
  255. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  256. .deregisterAllCallouts("lease6_renew");
  257. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  258. .deregisterAllCallouts("lease6_release");
  259. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  260. .deregisterAllCallouts("pkt6_receive");
  261. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  262. .deregisterAllCallouts("pkt6_send");
  263. isc::hooks::HooksManager::preCalloutsLibraryHandle()
  264. .deregisterAllCallouts("subnet6_select");
  265. };
  266. // A DUID used in most tests (typically as client-id)
  267. isc::dhcp::DuidPtr duid_;
  268. int rcode_;
  269. isc::data::ConstElementPtr comment_;
  270. // Name of a valid network interface
  271. std::string valid_iface_;
  272. };
  273. // Provides suport for tests against a preconfigured subnet6
  274. // extends upon NakedDhcp6SrvTest
  275. class Dhcpv6SrvTest : public NakedDhcpv6SrvTest {
  276. public:
  277. /// Name of the server-id file (used in server-id tests)
  278. /// @brief Constructor that initalizes a simple default configuration
  279. ///
  280. /// Sets up a single subnet6 with one pool for addresses and second
  281. /// pool for prefixes.
  282. Dhcpv6SrvTest();
  283. /// @brief destructor
  284. ///
  285. /// Removes existing configuration.
  286. ~Dhcpv6SrvTest() {
  287. isc::dhcp::CfgMgr::instance().clear();
  288. };
  289. /// @brief Runs DHCPv6 configuration from the JSON string.
  290. ///
  291. /// @param config String holding server configuration in JSON format.
  292. void configure(const std::string& config);
  293. /// @brief Configure the DHCPv6 server using the JSON string.
  294. ///
  295. /// @param config String holding server configuration in JSON format.
  296. /// @param srv Server to be configured.
  297. void configure(const std::string& config, NakedDhcpv6Srv& srv);
  298. /// @brief Checks that server response (ADVERTISE or REPLY) contains proper
  299. /// IA_NA option
  300. ///
  301. /// @param rsp server's response
  302. /// @param expected_iaid expected IAID value
  303. /// @param expected_t1 expected T1 value
  304. /// @param expected_t2 expected T2 value
  305. /// @return IAADDR option for easy chaining with checkIAAddr method
  306. boost::shared_ptr<isc::dhcp::Option6IAAddr>
  307. checkIA_NA(const isc::dhcp::Pkt6Ptr& rsp, uint32_t expected_iaid,
  308. uint32_t expected_t1, uint32_t expected_t2);
  309. /// @brief Checks that server response (ADVERTISE or REPLY) contains proper
  310. /// IA_PD option
  311. ///
  312. /// @param rsp server's response
  313. /// @param expected_iaid expected IAID value
  314. /// @param expected_t1 expected T1 value
  315. /// @param expected_t2 expected T2 value
  316. /// @return IAPREFIX option for easy chaining with checkIAAddr method
  317. boost::shared_ptr<isc::dhcp::Option6IAPrefix>
  318. checkIA_PD(const isc::dhcp::Pkt6Ptr& rsp, uint32_t expected_iaid,
  319. uint32_t expected_t1, uint32_t expected_t2);
  320. // Check that generated IAADDR option contains expected address
  321. // and lifetime values match the configured subnet
  322. void checkIAAddr(const boost::shared_ptr<isc::dhcp::Option6IAAddr>& addr,
  323. const isc::asiolink::IOAddress& expected_addr,
  324. isc::dhcp::Lease::Type type) {
  325. // Check that the assigned address is indeed from the configured pool.
  326. // Note that when comparing addresses, we compare the textual
  327. // representation. IOAddress does not support being streamed to
  328. // an ostream, which means it can't be used in EXPECT_EQ.
  329. EXPECT_TRUE(subnet_->inPool(type, addr->getAddress()));
  330. EXPECT_EQ(expected_addr.toText(), addr->getAddress().toText());
  331. EXPECT_EQ(subnet_->getPreferred(), addr->getPreferred());
  332. EXPECT_EQ(subnet_->getValid(), addr->getValid());
  333. }
  334. // Checks if the lease sent to client is present in the database
  335. // and is valid when checked against the configured subnet
  336. isc::dhcp::Lease6Ptr checkLease
  337. (const isc::dhcp::DuidPtr& duid, const isc::dhcp::OptionPtr& ia_na,
  338. boost::shared_ptr<isc::dhcp::Option6IAAddr> addr);
  339. /// @brief Check if the specified lease is present in the data base.
  340. ///
  341. /// @param lease Lease to be searched in the database.
  342. /// @return Pointer to the lease in the database.
  343. isc::dhcp::Lease6Ptr checkLease(const isc::dhcp::Lease6& lease);
  344. /// @brief Verifies received IAPrefix option
  345. ///
  346. /// Verifies if the received IAPrefix option matches the lease in the
  347. /// database.
  348. ///
  349. /// @param duid client's DUID
  350. /// @param ia_pd IA_PD option that contains the IAPRefix option
  351. /// @param prefix pointer to the IAPREFIX option
  352. /// @return corresponding IPv6 lease (if found)
  353. isc::dhcp::Lease6Ptr checkPdLease
  354. (const isc::dhcp::DuidPtr& duid, const isc::dhcp::OptionPtr& ia_pd,
  355. boost::shared_ptr<isc::dhcp::Option6IAPrefix> prefix);
  356. /// @brief Creates a message with specified IA
  357. ///
  358. /// A utility function that creates a message of the specified type with
  359. /// a specified container (IA_NA or IA_PD) and an address or prefix
  360. /// inside it.
  361. ///
  362. /// @param message_type type of the message (e.g. DHCPV6_SOLICIT)
  363. /// @param lease_type type of a lease (TYPE_NA or TYPE_PD)
  364. /// @param addr address or prefix to use in IADDRESS or IAPREFIX options
  365. /// @param prefix_len length of the prefix (used for prefixes only)
  366. /// @param iaid IA identifier (used in IA_XX option)
  367. /// @return created message
  368. isc::dhcp::Pkt6Ptr
  369. createMessage(uint8_t message_type, isc::dhcp::Lease::Type lease_type,
  370. const isc::asiolink::IOAddress& addr,
  371. const uint8_t prefix_len, const uint32_t iaid);
  372. /// @brief Creates instance of IA option holding single address or prefix.
  373. ///
  374. /// Utility function that creates an IA option instance with a single
  375. /// IPv6 address or prefix. This function is internally called by the
  376. /// @c createMessage function. It may be also used to add additional
  377. /// IA options to the message generated by @c createMessage (which adds
  378. /// a single IA option by itself.).
  379. ///
  380. /// @param lease_type type of the lease (TYPE_NA or TYPE_PD).
  381. /// @param addr address or prefix to use in IADDRESS or IAPREFIX options.
  382. /// @param prefix_len length of the prefix (used for PD, ignored for NA).
  383. /// @param iaid IA identifier.
  384. ///
  385. /// @return Created instance of the IA option.
  386. isc::dhcp::Option6IAPtr
  387. createIA(isc::dhcp::Lease::Type lease_type,
  388. const isc::asiolink::IOAddress& addr,
  389. const uint8_t prefix_len, const uint32_t iaid);
  390. /// @brief Compare options
  391. ///
  392. /// This method compares whether options content is identical. It writes
  393. /// both options to a buffer and then compares the buffers. Comparing
  394. /// two different instances of an option that has identical content
  395. /// will return true.
  396. ///
  397. /// It is safe to pass NULL pointers. Two NULL pointers are equal.
  398. /// NULL pointer and non-NULL pointers are obviously non-equal.
  399. ///
  400. /// @param option1 pointer to the first option
  401. /// @param option2
  402. /// @return true, if content is identical
  403. bool compareOptions(const isc::dhcp::OptionPtr& option1,
  404. const isc::dhcp::OptionPtr& option2);
  405. /// @brief Performs basic (positive) RENEW test
  406. ///
  407. /// See renewBasic and pdRenewBasic tests for detailed explanation.
  408. /// In essence the test attempts to perform a successful RENEW scenario.
  409. ///
  410. /// This method does not throw, but uses gtest macros to signify failures.
  411. ///
  412. /// @param type type (TYPE_NA or TYPE_PD)
  413. /// @param existing_addr address to be preinserted into the database
  414. /// @param renew_addr address being sent in RENEW
  415. /// @param prefix_len length of the prefix (128 for addresses)
  416. /// @param insert_before_renew should the lease be inserted into the database
  417. /// before we try renewal?
  418. void
  419. testRenewBasic(isc::dhcp::Lease::Type type,
  420. const std::string& existing_addr,
  421. const std::string& renew_addr, const uint8_t prefix_len,
  422. bool insert_before_renew = true);
  423. /// @brief Checks if RENEW with invalid IAID is processed correctly.
  424. ///
  425. /// @param type lease type (currently only IA_NA is supported)
  426. /// @param addr address to be renewed
  427. void
  428. testRenewWrongIAID(isc::dhcp::Lease::Type type,
  429. const asiolink::IOAddress& addr);
  430. /// @brief Checks if client A can renew address used by client B
  431. ///
  432. /// @param type lease type (currently only IA_NA is supported)
  433. /// @param addr address to be renewed
  434. void
  435. testRenewSomeoneElsesLease(isc::dhcp::Lease::Type type,
  436. const asiolink::IOAddress& addr);
  437. /// @brief Performs negative RENEW test
  438. ///
  439. /// See renewReject and pdRenewReject tests for detailed explanation.
  440. /// In essence the test attempts to perform couple failed RENEW scenarios.
  441. ///
  442. /// This method does not throw, but uses gtest macros to signify failures.
  443. ///
  444. /// @param type type (TYPE_NA or TYPE_PD)
  445. /// @param addr address being sent in RENEW
  446. void
  447. testRenewReject(isc::dhcp::Lease::Type type,
  448. const isc::asiolink::IOAddress& addr);
  449. /// @brief Performs basic (positive) RELEASE test
  450. ///
  451. /// See releaseBasic and pdReleaseBasic tests for detailed explanation.
  452. /// In essence the test attempts to perform a successful RELEASE scenario.
  453. ///
  454. /// This method does not throw, but uses gtest macros to signify failures.
  455. ///
  456. /// @param type type (TYPE_NA or TYPE_PD)
  457. /// @param existing address to be preinserted into the database
  458. /// @param release_addr address being sent in RELEASE
  459. void
  460. testReleaseBasic(isc::dhcp::Lease::Type type,
  461. const isc::asiolink::IOAddress& existing,
  462. const isc::asiolink::IOAddress& release_addr);
  463. /// @brief Performs negative RELEASE test
  464. ///
  465. /// See releaseReject and pdReleaseReject tests for detailed
  466. /// explanation. In essence the test attempts to perform couple
  467. /// failed RELEASE scenarios.
  468. ///
  469. /// This method does not throw, but uses gtest macros to signify failures.
  470. ///
  471. /// @param type type (TYPE_NA or TYPE_PD)
  472. /// @param addr address being sent in RELEASE
  473. void
  474. testReleaseReject(isc::dhcp::Lease::Type type,
  475. const isc::asiolink::IOAddress& addr);
  476. /// A subnet used in most tests
  477. isc::dhcp::Subnet6Ptr subnet_;
  478. /// A normal, non-temporary pool used in most tests
  479. isc::dhcp::Pool6Ptr pool_;
  480. /// A prefix pool used in most tests
  481. isc::dhcp::Pool6Ptr pd_pool_;
  482. /// @brief Server object under test.
  483. NakedDhcpv6Srv srv_;
  484. };
  485. }; // end of isc::test namespace
  486. }; // end of isc namespace
  487. #endif // DHCP6_TEST_UTILS_H