From: Francis Dupont Date: Wed, 3 Jun 2015 17:49:58 +0000 (+0200) Subject: [3504b] Rewrote ReleaseNoSubnet unit test X-Git-Tag: trac3889_base~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d4fa4ed17f54c5a34fecd5c09dbf4f4f9dc0c4e;p=thirdparty%2Fkea.git [3504b] Rewrote ReleaseNoSubnet unit test --- diff --git a/src/bin/dhcp4/tests/release_unittest.cc b/src/bin/dhcp4/tests/release_unittest.cc index f0e904b98f..0271e4be48 100644 --- a/src/bin/dhcp4/tests/release_unittest.cc +++ b/src/bin/dhcp4/tests/release_unittest.cc @@ -259,4 +259,27 @@ TEST_F(ReleaseTest, releaseNonMatchingIPAddress) { ASSERT_TRUE(lease); } +// This test verifies that incoming RELEASE from a bad location +// is correctly dropped. +TEST_F(ReleaseTest, ReleaseNoSubnet) { + Dhcp4Client client(Dhcp4Client::SELECTING); + // Configure DHCP server. + configure(RELEASE_CONFIGS[0], *client.getServer()); + // Perform 4-way exchange to obtain a new lease. + acquireLease(client); + + // Remember the acquired address. + IOAddress leased_address = client.config_.lease_.addr_; + + // Release is as it was relayed + client.useRelay(true); + + // Send the release + ASSERT_NO_THROW(client.doRelease()); + + // Check that the lease was not removed (due to no subnet) + Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(leased_address); + EXPECT_TRUE(lease); +} + } // end of anonymous namespace