From 00af3a4ed4664a8e47b6719098980bf0a139b871 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Thu, 26 Apr 2018 16:47:05 +0200 Subject: [PATCH] [5458a] Improved tests (with the plan for next steps) --- src/bin/dhcp6/tests/hooks_unittest.cc | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc index 81721fb38c..3b0c29c7ce 100644 --- a/src/bin/dhcp6/tests/hooks_unittest.cc +++ b/src/bin/dhcp6/tests/hooks_unittest.cc @@ -1969,8 +1969,35 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedRequest) { EXPECT_EQ("2001:db8:1::", lease->addr_.toText()); ASSERT_TRUE(callback_deleted_leases6_); EXPECT_TRUE(callback_deleted_leases6_->empty()); + + // Pkt passed to a callout must be configured to copy retrieved options. + EXPECT_TRUE(callback_qry_options_copy_); + + resetCalloutBuffers(); + + // Request a prefix: this should lead to an error as no prefix pool + // is configured. + client.requestPrefix(0x1122, 64, IOAddress("2001:db8:1000::")); + + ASSERT_NO_THROW(client.doRequest()); + + // Make sure that we received a response + ASSERT_TRUE(client.getContext().response_); + + // Check the error. + EXPECT_EQ(STATUS_NoPrefixAvail, client.getStatusCode(0x1122)); + + // Check that the callback called is indeed the one we installed + EXPECT_EQ("leases6_committed", callback_name_); + + ASSERT_TRUE(callback_new_leases6_); + EXPECT_EQ(3, callback_new_leases6_->size()); + ASSERT_TRUE(callback_deleted_leases6_); + EXPECT_TRUE(callback_deleted_leases6_->empty()); } +//// same with prefix + // This test verifies that it is possible to park a packet as a result of // the leases6_committed callouts. TEST_F(HooksDhcpv6SrvTest, leases6CommittedParkRequests) { @@ -2070,6 +2097,8 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedParkRequests) { EXPECT_TRUE(client2.hasLeaseForAddress(IOAddress("2001:db8:1::29"))); } +//// same with prefix + // This test verifies that incoming (positive) RENEW can be handled properly, // and the lease6_renew callouts are triggered. TEST_F(HooksDhcpv6SrvTest, basicLease6Renew) { @@ -2468,8 +2497,35 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedRenew) { EXPECT_EQ("2001:db8:1::", lease->addr_.toText()); ASSERT_TRUE(callback_deleted_leases6_); EXPECT_TRUE(callback_deleted_leases6_->empty()); + + // Pkt passed to a callout must be configured to copy retrieved options. + EXPECT_TRUE(callback_qry_options_copy_); + + resetCalloutBuffers(); + + // Renew a prefix: this should lead to an error as no prefix pool + // is configured. + client.requestPrefix(0x1122, 64, IOAddress("2001:db8:1000::")); + + ASSERT_NO_THROW(client.doRenew()); + + // Make sure that we received a response + ASSERT_TRUE(client.getContext().response_); + + // Check the error. + EXPECT_EQ(STATUS_NoPrefixAvail, client.getStatusCode(0x1122)); + + // Check that the callback called is indeed the one we installed + EXPECT_EQ("leases6_committed", callback_name_); + + ASSERT_TRUE(callback_new_leases6_); + EXPECT_EQ(3, callback_new_leases6_->size()); + ASSERT_TRUE(callback_deleted_leases6_); + EXPECT_TRUE(callback_deleted_leases6_->empty()); } +//// same with prefix + // This test verifies that incoming (positive) RELEASE can be handled properly, // that a REPLY is generated, that the response has status code and that the // lease is indeed removed from the database. @@ -2822,6 +2878,9 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedRelease) { EXPECT_TRUE(callback_qry_options_copy_); } +//// same with prefix +//// same with addresses and prefixes (2+2) + // This test verifies that incoming (positive) REBIND can be handled properly, // and the lease6_rebind callouts are triggered. TEST_F(HooksDhcpv6SrvTest, basicLease6Rebind) { @@ -3208,8 +3267,35 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedRebind) { EXPECT_EQ("2001:db8:1::", lease->addr_.toText()); ASSERT_TRUE(callback_deleted_leases6_); EXPECT_TRUE(callback_deleted_leases6_->empty()); + + // Pkt passed to a callout must be configured to copy retrieved options. + EXPECT_TRUE(callback_qry_options_copy_); + + resetCalloutBuffers(); + + // Rebind a prefix: this should lead to an error as no prefix pool + // is configured. + client.requestPrefix(0x1122, 64, IOAddress("2001:db8:1000::")); + + ASSERT_NO_THROW(client.doRebind()); + + // Make sure that we received a response + ASSERT_TRUE(client.getContext().response_); + + // Check the error. + EXPECT_EQ(STATUS_NoPrefixAvail, client.getStatusCode(0x1122)); + + // Check that the callback called is indeed the one we installed + EXPECT_EQ("leases6_committed", callback_name_); + + ASSERT_TRUE(callback_new_leases6_); + EXPECT_EQ(3, callback_new_leases6_->size()); + ASSERT_TRUE(callback_deleted_leases6_); + EXPECT_TRUE(callback_deleted_leases6_->empty()); } +//// same with prefix + // This test checks that the basic decline hook (lease6_decline) is // triggered properly. TEST_F(HooksDhcpv6SrvTest, basicLease6Decline) { @@ -3413,6 +3499,9 @@ TEST_F(HooksDhcpv6SrvTest, leases6CommittedDecline) { EXPECT_TRUE(callback_qry_options_copy_); } +//// same with 2 IA_NA +//// same with an IA_NA with 2 addresses (if I can get an example) + // Checks if callout installed on host6_identifier can generate an // identifier and whether that identifier is actually used. TEST_F(HooksDhcpv6SrvTest, host6Identifier) { -- 2.47.2