From: Razvan Becheriu Date: Mon, 2 Feb 2026 13:15:26 +0000 (+0200) Subject: [#4280] remove lease-expires-on from ncr X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13ccf56d7e3c2be6b116a74858764c3ac05cfd3f;p=thirdparty%2Fkea.git [#4280] remove lease-expires-on from ncr --- diff --git a/src/bin/d2/tests/check_exists_add_unittests.cc b/src/bin/d2/tests/check_exists_add_unittests.cc index e5bbdf2ce5..be158e9c37 100644 --- a/src/bin/d2/tests/check_exists_add_unittests.cc +++ b/src/bin/d2/tests/check_exists_add_unittests.cc @@ -270,7 +270,6 @@ TEST(CheckExistsAddTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-exists-with-dhcid\"" "}"; @@ -287,14 +286,51 @@ TEST(CheckExistsAddTransaction, construction) { // Verify that construction with wrong change type fails. EXPECT_THROW(CheckExistsAddTransaction(io_service, ncr, - forward_domain, reverse_domain, cfg_mgr), - CheckExistsAddTransactionError); + forward_domain, reverse_domain, cfg_mgr), + CheckExistsAddTransactionError); // Verify that a valid construction attempt works. ncr->setChangeType(isc::dhcp_ddns::CHG_ADD); EXPECT_NO_THROW(CheckExistsAddTransaction(io_service, ncr, - forward_domain, reverse_domain, - cfg_mgr)); + forward_domain, reverse_domain, + cfg_mgr)); +} + +/// @brief Tests CheckExistsAddTransaction construction. +/// This test verifies that valid construction functions properly if extra +/// parameters are present. +TEST(CheckExistsAddTransaction, constructionWithExtra) { + asiolink::IOServicePtr io_service(new isc::asiolink::IOService()); + D2CfgMgrPtr cfg_mgr(new D2CfgMgr()); + + const char* msg_str = + "{" + " \"change-type\" : 1 , " + " \"forward-change\" : true , " + " \"reverse-change\" : true , " + " \"fqdn\" : \"example.com.\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"0102030405060708\" , " + " \"extra\" : \"19700101000000\" , " + " \"lease-length\" : 1300, " + " \"conflict-resolution-mode\" : \"check-exists-with-dhcid\"" + "}"; + + dhcp_ddns::NameChangeRequestPtr ncr; + DnsServerInfoStoragePtr servers; + DdnsDomainPtr forward_domain; + DdnsDomainPtr reverse_domain; + DdnsDomainPtr empty_domain; + + ASSERT_NO_THROW(ncr = dhcp_ddns::NameChangeRequest::fromJSON(msg_str)); + ASSERT_NO_THROW(forward_domain.reset(new DdnsDomain("*", servers))); + ASSERT_NO_THROW(reverse_domain.reset(new DdnsDomain("*", servers))); + + // Verify that a valid construction attempt works. + ncr->setChangeType(isc::dhcp_ddns::CHG_ADD); + EXPECT_NO_THROW(CheckExistsAddTransaction(io_service, ncr, + forward_domain, reverse_domain, + cfg_mgr)); } /// @brief Tests event and state dictionary construction and verification. diff --git a/src/bin/d2/tests/check_exists_remove_unittests.cc b/src/bin/d2/tests/check_exists_remove_unittests.cc index c764cb2ba5..086f29ec7f 100644 --- a/src/bin/d2/tests/check_exists_remove_unittests.cc +++ b/src/bin/d2/tests/check_exists_remove_unittests.cc @@ -273,7 +273,6 @@ TEST(CheckExistsRemoveTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-exists-with-dhcid\"" "}"; @@ -290,14 +289,51 @@ TEST(CheckExistsRemoveTransaction, construction) { // Verify that construction with wrong change type fails. EXPECT_THROW(CheckExistsRemoveTransaction(io_service, ncr, - forward_domain, reverse_domain, cfg_mgr), - CheckExistsRemoveTransactionError); + forward_domain, reverse_domain, cfg_mgr), + CheckExistsRemoveTransactionError); // Verify that a valid construction attempt works. ncr->setChangeType(isc::dhcp_ddns::CHG_REMOVE); EXPECT_NO_THROW(CheckExistsRemoveTransaction(io_service, ncr, - forward_domain, reverse_domain, - cfg_mgr)); + forward_domain, reverse_domain, + cfg_mgr)); +} + +/// @brief Tests CheckExistsRemoveTransaction construction. +/// This test verifies that valid construction functions properly if extra +/// parameters are present. +TEST(CheckExistsRemoveTransaction, constructionWithExtra) { + asiolink::IOServicePtr io_service(new isc::asiolink::IOService()); + D2CfgMgrPtr cfg_mgr(new D2CfgMgr()); + + const char* msg_str = + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : true , " + " \"fqdn\" : \"example.com.\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"0102030405060708\" , " + " \"extra\" : \"19700101000000\" , " + " \"lease-length\" : 1300, " + " \"conflict-resolution-mode\" : \"check-exists-with-dhcid\"" + "}"; + + dhcp_ddns::NameChangeRequestPtr ncr; + DnsServerInfoStoragePtr servers; + DdnsDomainPtr forward_domain; + DdnsDomainPtr reverse_domain; + DdnsDomainPtr empty_domain; + + ASSERT_NO_THROW(ncr = dhcp_ddns::NameChangeRequest::fromJSON(msg_str)); + ASSERT_NO_THROW(forward_domain.reset(new DdnsDomain("*", servers))); + ASSERT_NO_THROW(reverse_domain.reset(new DdnsDomain("*", servers))); + + // Verify that a valid construction attempt works. + ncr->setChangeType(isc::dhcp_ddns::CHG_REMOVE); + EXPECT_NO_THROW(CheckExistsRemoveTransaction(io_service, ncr, + forward_domain, reverse_domain, + cfg_mgr)); } /// @brief Tests event and state dictionary construction and verification. diff --git a/src/bin/d2/tests/d2_process_unittests.cc b/src/bin/d2/tests/d2_process_unittests.cc index e82f3eae08..2a51e84575 100644 --- a/src/bin/d2/tests/d2_process_unittests.cc +++ b/src/bin/d2/tests/d2_process_unittests.cc @@ -321,7 +321,6 @@ TEST_F(D2ProcessTest, queueFullRecovery) { " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; @@ -549,7 +548,6 @@ TEST_F(D2ProcessTest, canShutdown) { " \"fqdn\" : \"fish.example.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; diff --git a/src/bin/d2/tests/d2_queue_mgr_unittests.cc b/src/bin/d2/tests/d2_queue_mgr_unittests.cc index 7a1c5d00aa..79a3e32be2 100644 --- a/src/bin/d2/tests/d2_queue_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_queue_mgr_unittests.cc @@ -36,7 +36,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}", @@ -48,7 +47,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}", @@ -60,7 +58,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}" diff --git a/src/bin/d2/tests/d2_update_mgr_unittests.cc b/src/bin/d2/tests/d2_update_mgr_unittests.cc index 111f5359f6..1b706bf7b4 100644 --- a/src/bin/d2/tests/d2_update_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_update_mgr_unittests.cc @@ -101,7 +101,6 @@ public: " \"fqdn\" : \"my.example.com.\" , " " \"ip-address\" : \"192.168.1.2\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; diff --git a/src/bin/d2/tests/nc_add_unittests.cc b/src/bin/d2/tests/nc_add_unittests.cc index 378150680e..0fec191f76 100644 --- a/src/bin/d2/tests/nc_add_unittests.cc +++ b/src/bin/d2/tests/nc_add_unittests.cc @@ -270,7 +270,6 @@ TEST(NameAddTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; @@ -297,6 +296,43 @@ TEST(NameAddTransaction, construction) { cfg_mgr)); } +/// @brief Tests NameAddTransaction construction. +/// This test verifies that valid construction functions properly if extra +/// parameters are present. +TEST(NameAddTransaction, constructionWithExtra) { + asiolink::IOServicePtr io_service(new isc::asiolink::IOService()); + D2CfgMgrPtr cfg_mgr(new D2CfgMgr()); + + const char* msg_str = + "{" + " \"change-type\" : 1 , " + " \"forward-change\" : true , " + " \"reverse-change\" : true , " + " \"fqdn\" : \"example.com.\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"0102030405060708\" , " + " \"extra\" : \"19700101000000\" , " + " \"lease-length\" : 1300, " + " \"conflict-resolution-mode\" : \"check-with-dhcid\"" + "}"; + + dhcp_ddns::NameChangeRequestPtr ncr; + DnsServerInfoStoragePtr servers; + DdnsDomainPtr forward_domain; + DdnsDomainPtr reverse_domain; + DdnsDomainPtr empty_domain; + + ASSERT_NO_THROW(ncr = dhcp_ddns::NameChangeRequest::fromJSON(msg_str)); + ASSERT_NO_THROW(forward_domain.reset(new DdnsDomain("*", servers))); + ASSERT_NO_THROW(reverse_domain.reset(new DdnsDomain("*", servers))); + + // Verify that a valid construction attempt works. + ncr->setChangeType(isc::dhcp_ddns::CHG_ADD); + EXPECT_NO_THROW(NameAddTransaction(io_service, ncr, + forward_domain, reverse_domain, + cfg_mgr)); +} + /// @brief Tests event and state dictionary construction and verification. TEST_F(NameAddTransactionTest, dictionaryCheck) { NameAddStubPtr name_add; diff --git a/src/bin/d2/tests/nc_remove_unittests.cc b/src/bin/d2/tests/nc_remove_unittests.cc index 7d24de4409..f42098156e 100644 --- a/src/bin/d2/tests/nc_remove_unittests.cc +++ b/src/bin/d2/tests/nc_remove_unittests.cc @@ -273,7 +273,6 @@ TEST(NameRemoveTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; @@ -300,6 +299,43 @@ TEST(NameRemoveTransaction, construction) { cfg_mgr)); } +/// @brief Tests NameRemoveTransaction construction. +/// This test verifies that valid construction functions properly if extra +/// parameters are present. +TEST(NameRemoveTransaction, constructionWithExtra) { + asiolink::IOServicePtr io_service(new isc::asiolink::IOService()); + D2CfgMgrPtr cfg_mgr(new D2CfgMgr()); + + const char* msg_str = + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : true , " + " \"fqdn\" : \"example.com.\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"0102030405060708\" , " + " \"extra\" : \"19700101000000\" , " + " \"lease-length\" : 1300, " + " \"conflict-resolution-mode\" : \"check-with-dhcid\"" + "}"; + + dhcp_ddns::NameChangeRequestPtr ncr; + DnsServerInfoStoragePtr servers; + DdnsDomainPtr forward_domain; + DdnsDomainPtr reverse_domain; + DdnsDomainPtr empty_domain; + + ASSERT_NO_THROW(ncr = dhcp_ddns::NameChangeRequest::fromJSON(msg_str)); + ASSERT_NO_THROW(forward_domain.reset(new DdnsDomain("*", servers))); + ASSERT_NO_THROW(reverse_domain.reset(new DdnsDomain("*", servers))); + + // Verify that a valid construction attempt works. + ncr->setChangeType(isc::dhcp_ddns::CHG_REMOVE); + EXPECT_NO_THROW(NameRemoveTransaction(io_service, ncr, + forward_domain, reverse_domain, + cfg_mgr)); +} + /// @brief Tests event and state dictionary construction and verification. TEST_F(NameRemoveTransactionTest, dictionaryCheck) { NameRemoveStubPtr name_remove; diff --git a/src/bin/d2/tests/simple_add_unittests.cc b/src/bin/d2/tests/simple_add_unittests.cc index 944d650a3a..02dd5153d2 100644 --- a/src/bin/d2/tests/simple_add_unittests.cc +++ b/src/bin/d2/tests/simple_add_unittests.cc @@ -268,7 +268,6 @@ TEST(SimpleAddTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"no-check-with-dhcid\"" "}"; diff --git a/src/bin/d2/tests/simple_add_without_dhcid_unittests.cc b/src/bin/d2/tests/simple_add_without_dhcid_unittests.cc index b1dfc58823..065f4b72d2 100644 --- a/src/bin/d2/tests/simple_add_without_dhcid_unittests.cc +++ b/src/bin/d2/tests/simple_add_without_dhcid_unittests.cc @@ -268,7 +268,6 @@ TEST(SimpleAddWithoutDHCIDTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"no-check-without-dhcid\"" "}"; diff --git a/src/bin/d2/tests/simple_remove_unittests.cc b/src/bin/d2/tests/simple_remove_unittests.cc index 50e488a793..b976f21066 100644 --- a/src/bin/d2/tests/simple_remove_unittests.cc +++ b/src/bin/d2/tests/simple_remove_unittests.cc @@ -270,7 +270,6 @@ TEST(SimpleRemoveTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"no-check-with-dhcid\"" "}"; diff --git a/src/bin/d2/tests/simple_remove_without_dhcid_unittests.cc b/src/bin/d2/tests/simple_remove_without_dhcid_unittests.cc index c031afe057..80fbea1b94 100644 --- a/src/bin/d2/tests/simple_remove_without_dhcid_unittests.cc +++ b/src/bin/d2/tests/simple_remove_without_dhcid_unittests.cc @@ -270,7 +270,6 @@ TEST(SimpleRemoveWithoutDHCIDTransaction, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"use-conflict-resolution\" : true " "}"; diff --git a/src/bin/dhcp4/tests/d2_unittest.cc b/src/bin/dhcp4/tests/d2_unittest.cc index 7679167c49..770515e123 100644 --- a/src/bin/dhcp4/tests/d2_unittest.cc +++ b/src/bin/dhcp4/tests/d2_unittest.cc @@ -60,7 +60,6 @@ Dhcp4SrvD2Test::buildTestNcr(uint32_t dhcid_id_num) { << std::hex << std::setfill('0') << std::setw(16) << dhcid_id_num << "\" , " - " \"lease-expires-on\" : \"20140121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; diff --git a/src/bin/dhcp4/tests/fqdn_unittest.cc b/src/bin/dhcp4/tests/fqdn_unittest.cc index 18e4c6d4b9..d3f9b249de 100644 --- a/src/bin/dhcp4/tests/fqdn_unittest.cc +++ b/src/bin/dhcp4/tests/fqdn_unittest.cc @@ -854,7 +854,7 @@ public: verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, resp->getYiaddr().toText(), "client1.example.com.", "", - time(NULL), lease->valid_lft_, true, + lease->valid_lft_, CHECK_WITH_DHCID, ddns_ttl_percent, ddns_ttl, @@ -876,13 +876,8 @@ public: /// @param fqdn - expected FQDN in the NCR /// @param dhcid - expected DHCID in the NCR (comparison is performed only /// if the value supplied is not empty):w - /// @param cltt - cltt value from the lease the NCR for which the NCR - /// was generated expected value for /// @param lifetime - lease's valid lifetime from which NCR ttl was /// generated - /// @param not_strict_expire_check - when true the comparison of the NCR - /// lease expiration time is conducted as greater than or equal to rather - /// equal to CLTT plus lease ttl . /// @param exp_conflict_resolution_mode expected value of conflict resolution mode /// @param ddns_ttl_percent expected configured value for ddns-ttl-percent /// @param ddns_ttl expected configured value for ddns-ttl @@ -893,11 +888,8 @@ public: const std::string& addr, const std::string& fqdn, const std::string& dhcid, - const time_t cltt, const uint16_t valid_lft, - const bool not_strict_expire_check = false, - const ConflictResolutionMode - exp_conflict_resolution_mode = CHECK_WITH_DHCID, + const ConflictResolutionMode exp_conflict_resolution_mode = CHECK_WITH_DHCID, Optional ddns_ttl_percent = Optional(), Optional ddns_ttl = Optional(), Optional ddns_ttl_min = Optional(), @@ -917,21 +909,9 @@ public: EXPECT_EQ(dhcid, ncr->getDhcid().toStr()); } - // In some cases, the test doesn't have access to the last transmission - // time for the particular client. In such cases, the test can use the - // current time as cltt but the it may not check the lease expiration - // time for equality but rather check that the lease expiration time - // is not greater than the current time + lease lifetime. - uint32_t ttl = calculateDdnsTtl(valid_lft, ddns_ttl_percent, ddns_ttl, ddns_ttl_min, ddns_ttl_max); - if (not_strict_expire_check) { - EXPECT_GE(cltt + ttl, ncr->getLeaseExpiresOn()); - } else { - EXPECT_EQ(cltt + ttl, ncr->getLeaseExpiresOn()); - } - EXPECT_EQ(ttl, ncr->getLeaseLength()); EXPECT_EQ(isc::dhcp_ddns::ST_NEW, ncr->getStatus()); EXPECT_EQ(exp_conflict_resolution_mode, ncr->getConflictResolutionMode()); @@ -984,8 +964,7 @@ public: reply->getYiaddr().toText(), "myhost.example.com.", "", // empty DHCID means don't check it - time(NULL) + subnet_->getValid(), - subnet_->getValid(), true); + subnet_->getValid()); } } } @@ -1235,7 +1214,7 @@ TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsNewLease) { "192.0.2.3", "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436965" "B68B6D438D98E680BF10B09F3BCF", - lease->cltt_, 100); + 100); } // Verify that conflict resolution is disabled in the NCR when it is @@ -1255,7 +1234,7 @@ TEST_F(NameDhcpv4SrvTest, noConflictResolution) { "192.0.2.3", "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436965" "B68B6D438D98E680BF10B09F3BCF", - lease->cltt_, 100, false, NO_CHECK_WITH_DHCID); + 100, NO_CHECK_WITH_DHCID); } // Verifies that createNameChange request only generates requests @@ -1345,8 +1324,8 @@ TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsUpdateOnRenew) { // Verify NCR content verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true, scenario.old_lease_->addr_.toText(), - scenario.old_lease_->hostname_, "", time(NULL), - scenario.old_lease_->valid_lft_, true); + scenario.old_lease_->hostname_, "", + scenario.old_lease_->valid_lft_); } // If we expect an add, check it. @@ -1354,8 +1333,8 @@ TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsUpdateOnRenew) { // Verify NCR content verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, scenario.new_lease_->addr_.toText(), - scenario.new_lease_->hostname_, "", time(NULL), - scenario.new_lease_->valid_lft_, true); + scenario.new_lease_->hostname_, "", + scenario.new_lease_->valid_lft_); } } } @@ -1403,8 +1382,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestFqdnEmptyDomainName) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, reply->getYiaddr().toText(), hostname, "", // empty DHCID forces that it is not checked - time(NULL) + subnet_->getValid(), - subnet_->getValid(), true); + subnet_->getValid()); req = generatePktWithFqdn(DHCPREQUEST, Option4ClientFqdn::FLAG_S | Option4ClientFqdn::FLAG_E, @@ -1471,7 +1449,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestTopLevelHostname) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, reply->getYiaddr().toText(), hostname, "", // empty DHCID forces that it is not checked - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // Test that client may send two requests, each carrying FQDN option with @@ -1498,7 +1476,7 @@ TEST_F(NameDhcpv4SrvTest, processTwoRequestsFqdn) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); // Create another Request message but with a different FQDN. Server // should generate two NameChangeRequests: one to remove existing entry, @@ -1519,14 +1497,14 @@ TEST_F(NameDhcpv4SrvTest, processTwoRequestsFqdn) { "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, reply->getYiaddr().toText(), "otherhost.example.com.", "000101A5AEEA7498BD5AD9D3BF600E49FF39A7E3" "AFDCE8C3D0E53F35CC584DD63C89CA", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // Test that client may send two requests, each carrying Hostname option with @@ -1556,7 +1534,7 @@ TEST_F(NameDhcpv4SrvTest, processTwoRequestsHostname) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); // Create another Request message but with a different Hostname. Server // should generate two NameChangeRequests: one to remove existing entry, @@ -1579,14 +1557,14 @@ TEST_F(NameDhcpv4SrvTest, processTwoRequestsHostname) { "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, reply->getYiaddr().toText(), "otherhost.example.com.", "000101A5AEEA7498BD5AD9D3BF600E49FF39A7E3" "AFDCE8C3D0E53F35CC584DD63C89CA", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // Test that client may send two requests, each carrying the same FQDN option. @@ -1612,7 +1590,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestRenewFqdn) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); // Create another Request message with the same FQDN. Case changes in the // hostname should be ignored. Server should generate no NameChangeRequests. @@ -1654,7 +1632,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestRenewHostname) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); // Create another Request message with the same Hostname. Case changes in the // hostname should be ignored. Server should generate no NameChangeRequests. @@ -1701,7 +1679,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestRelease) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); // Create and process the Release message. Pkt4Ptr rel = Pkt4Ptr(new Pkt4(DHCPRELEASE, 1234)); @@ -1718,7 +1696,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestRelease) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // Test that when a release message is sent for a previously acquired lease, @@ -1746,7 +1724,7 @@ TEST_F(NameDhcpv4SrvTest, processRequestReleaseNoDelete) { reply->getYiaddr().toText(), "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436" "965B68B6D438D98E680BF10B09F3BCF", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); // Create and process the Release message. Pkt4Ptr rel = Pkt4Ptr(new Pkt4(DHCPRELEASE, 1234)); @@ -1849,7 +1827,7 @@ TEST_F(NameDhcpv4SrvTest, fqdnReservation) { "unique-host.example.com.", "000001B6547DCC62E44C4D1A42D0A05B149EA1168" "01A9481A98E3A876A9E0D261F8326", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // And that this FQDN has been stored in the lease database. @@ -1893,7 +1871,7 @@ TEST_F(NameDhcpv4SrvTest, fqdnReservation) { "unique-host.example.com.", "000001B6547DCC62E44C4D1A42D0A05B149EA1168" "01A9481A98E3A876A9E0D261F8326", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } { @@ -1905,7 +1883,7 @@ TEST_F(NameDhcpv4SrvTest, fqdnReservation) { "foobar.fake-suffix.isc.org.", "0000017C29B3C236344924E448E247F3FD56C7E9" "167B3397B1305FB664C160B967CE1F", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } } @@ -1966,7 +1944,7 @@ TEST_F(NameDhcpv4SrvTest, hostnameReservation) { "unique-host.example.com.", "000001B6547DCC62E44C4D1A42D0A05B149EA1168" "01A9481A98E3A876A9E0D261F8326", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // Reconfigure DHCP server to use a different hostname for the client. @@ -2004,7 +1982,7 @@ TEST_F(NameDhcpv4SrvTest, hostnameReservation) { "unique-host.example.com.", "000001B6547DCC62E44C4D1A42D0A05B149EA1168" "01A9481A98E3A876A9E0D261F8326", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } { @@ -2016,7 +1994,7 @@ TEST_F(NameDhcpv4SrvTest, hostnameReservation) { "foobar.fake-suffix.isc.org.", "0000017C29B3C236344924E448E247F3FD56C7E9" "167B3397B1305FB664C160B967CE1F", - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } } @@ -2612,7 +2590,7 @@ TEST_F(NameDhcpv4SrvTest, ddnsScopeTest) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, resp->getYiaddr().toText(), "two.example.com.", "", - time(NULL), 7200, true); + 7200); } // Verifies that when reusing an expired lease, whether or not it is given to its @@ -2709,7 +2687,7 @@ TEST_F(NameDhcpv4SrvTest, processReuseExpired) { true, true, resp->getYiaddr().toText(), scenario.hostname1_, scenario.dhcid1_, - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } // Expire the lease @@ -2748,7 +2726,7 @@ TEST_F(NameDhcpv4SrvTest, processReuseExpired) { true, true, resp->getYiaddr().toText(), scenario.hostname1_, scenario.dhcid1_, - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } if (scenario.expect_add_) { @@ -2756,7 +2734,7 @@ TEST_F(NameDhcpv4SrvTest, processReuseExpired) { true, true, resp->getYiaddr().toText(), scenario.hostname2_, scenario.dhcid2_, - time(NULL), subnet_->getValid(), true); + subnet_->getValid()); } bool deleted = false; @@ -2804,7 +2782,7 @@ TEST_F(NameDhcpv4SrvTest, ddnsSharedNetworkTest) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, resp->getYiaddr().toText(), "client1.one.example.com.", "", - time(NULL), 7200, true); + 7200); // Now let's try with a second client. The first subnet is full so we should // end up on the second subnet. @@ -2829,7 +2807,7 @@ TEST_F(NameDhcpv4SrvTest, ddnsSharedNetworkTest) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, resp->getYiaddr().toText(), "client2.two.example.com.", "", - time(NULL), 7200, true); + 7200); // Make sure the lease is in the database and hostname is correct. lease = LeaseMgrFactory::instance().getLease4(IOAddress("10.0.0.10")); @@ -2923,7 +2901,7 @@ TEST_F(NameDhcpv4SrvTest, withOfferLifetime) { "client-name.example.com.", "0000011E5D6FA61FCBAC969FF4EF0EBCA3FDE554E" "B020A13F44859F30A108793564A97", - time(NULL), subnet->getValid(), true); + subnet->getValid()); // And that this FQDN has been stored in the lease database. lease = LeaseMgrFactory::instance().getLease4(client.config_.lease_.addr_); @@ -2975,7 +2953,7 @@ TEST_F(NameDhcpv4SrvTest, withDdnsTtlPercent) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, resp->getYiaddr().toText(), "client1.example.com.", "", - time(NULL), lease->valid_lft_, true, + lease->valid_lft_, CHECK_WITH_DHCID, Optional(.25)); } @@ -2995,7 +2973,7 @@ TEST_F(NameDhcpv4SrvTest, checkWithDHCIDConflictResolutionMode) { "192.0.2.3", "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436965" "B68B6D438D98E680BF10B09F3BCF", - lease->cltt_, 100, false, CHECK_WITH_DHCID); + 100, CHECK_WITH_DHCID); } // Verify that conflict resolution mode is set to "no-check-with-dhcid" in the NCR @@ -3015,7 +2993,7 @@ TEST_F(NameDhcpv4SrvTest, noCheckWithDHCIDConflictResolutionMode) { "192.0.2.3", "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436965" "B68B6D438D98E680BF10B09F3BCF", - lease->cltt_, 100, false, NO_CHECK_WITH_DHCID); + 100, NO_CHECK_WITH_DHCID); } // Verify that conflict resolution mode is set to "no-check-without-dhcid" in the NCR @@ -3035,7 +3013,7 @@ TEST_F(NameDhcpv4SrvTest, noCheckWithoutDHCIDConflictResolutionMode) { "192.0.2.3", "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436965" "B68B6D438D98E680BF10B09F3BCF", - lease->cltt_, 100, false, NO_CHECK_WITHOUT_DHCID); + 100, NO_CHECK_WITHOUT_DHCID); } // Verify that conflict resolution mode is set to "check-exists-with-dhcid" in the NCR @@ -3055,7 +3033,7 @@ TEST_F(NameDhcpv4SrvTest, checkExistsDHCIDConflictResolutionMode) { "192.0.2.3", "myhost.example.com.", "00010132E91AA355CFBB753C0F0497A5A940436965" "B68B6D438D98E680BF10B09F3BCF", - lease->cltt_, 100, false, CHECK_EXISTS_WITH_DHCID); + 100, CHECK_EXISTS_WITH_DHCID); } // Verify the ddns-ttl-percent is used when specified. @@ -3197,7 +3175,7 @@ TEST_F(NameDhcpv4SrvTest, poolDdnsParametersTest) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, resp->getYiaddr().toText(), (scenario.expected_hostname_ + "."), "", - time(NULL), lease->valid_lft_, true, + lease->valid_lft_, CHECK_WITH_DHCID); } } diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 4b24c3a147..7c9cebcc29 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -2608,11 +2608,8 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer, // Get the IP address from the lease. NameChangeRequestPtr ncr; auto cr_mode = StringToConflictResolutionMode(ctx.getDdnsParams()->getConflictResolutionMode()); - ncr.reset(new NameChangeRequest(isc::dhcp_ddns::CHG_ADD, - do_fwd, do_rev, - opt_fqdn->getDomainName(), - iaaddr->getAddress().toText(), - dhcid, 0, + ncr.reset(new NameChangeRequest(isc::dhcp_ddns::CHG_ADD, do_fwd, do_rev, opt_fqdn->getDomainName(), + iaaddr->getAddress().toText(), dhcid, calculateDdnsTtl(iaaddr->getValid(), ctx.getDdnsParams()->getTtlPercent(), ctx.getDdnsParams()->getTtl(), diff --git a/src/bin/dhcp6/tests/d2_unittest.cc b/src/bin/dhcp6/tests/d2_unittest.cc index 23da4c244d..ff10c34c54 100644 --- a/src/bin/dhcp6/tests/d2_unittest.cc +++ b/src/bin/dhcp6/tests/d2_unittest.cc @@ -61,7 +61,6 @@ Dhcp6SrvD2Test::buildTestNcr(uint32_t dhcid_id_num) { << std::hex << std::setfill('0') << std::setw(16) << dhcid_id_num << "\" , " - " \"lease-expires-on\" : \"20140121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\" " "}"; diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index 7891c1f5e6..005e0dd431 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/src/bin/dhcp6/tests/fqdn_unittest.cc @@ -625,12 +625,10 @@ public: const bool reverse, const bool forward, const std::string& addr, const std::string& dhcid, - const uint64_t expires, const uint16_t valid_lft, const std::string& fqdn = "", const ConflictResolutionMode exp_cr_mode = CHECK_WITH_DHCID, - util::Optional exp_ddns_ttl_percent - = util::Optional(), + util::Optional exp_ddns_ttl_percent = util::Optional(), Optional exp_ddns_ttl = Optional(), Optional exp_ddns_ttl_min = Optional(), Optional exp_ddns_ttl_max = Optional()) { @@ -648,9 +646,6 @@ public: uint32_t ttl = calculateDdnsTtl(valid_lft, exp_ddns_ttl_percent, exp_ddns_ttl, exp_ddns_ttl_min, exp_ddns_ttl_max); - if (expires != 0) { - EXPECT_EQ(expires + ttl, ncr->getLeaseExpiresOn()); - } EXPECT_EQ(ttl, ncr->getLeaseLength()); @@ -749,7 +744,7 @@ public: "2001:db8:1::1", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, valid_lft, "", NO_CHECK_WITH_DHCID, + valid_lft, "", NO_CHECK_WITH_DHCID, ddns_ttl_percent, ddns_ttl, ddns_ttl_min, @@ -925,7 +920,7 @@ TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequests) { "2001:db8:1::1", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 500); + 500); } // Verify that conflict resolution is turned off when the @@ -959,7 +954,7 @@ TEST_F(FqdnDhcpv6SrvTest, noConflictResolution) { "2001:db8:1::1", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 500, "", NO_CHECK_WITH_DHCID); + 500, "", NO_CHECK_WITH_DHCID); } // Checks that NameChangeRequests to add entries are not @@ -1007,7 +1002,7 @@ TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestFwdRev) { "2001:db8:1::1", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); } // Checks that calling queueNCR would not result in error if DDNS updates are @@ -1045,7 +1040,7 @@ TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestRev) { "2001:db8:1::1", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); } // Test that NameChangeRequest to remove DNS records is not generated when @@ -1117,7 +1112,7 @@ TEST_F(FqdnDhcpv6SrvTest, processTwoRequestsDiffFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); // Client may send another request message with a new domain-name. In this // case the same lease will be returned. The existing DNS entry needs to @@ -1133,12 +1128,12 @@ TEST_F(FqdnDhcpv6SrvTest, processTwoRequestsDiffFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:1:1::dead:beef", "000201D422AA463306223D269B6CB7AFE7AAD265FC" "EA97F93623019B2E0D14E5323D5A", - 0, lease_->valid_lft_); + lease_->valid_lft_); } // Test that client may send two requests, each carrying FQDN option with @@ -1162,7 +1157,7 @@ TEST_F(FqdnDhcpv6SrvTest, processTwoRequestsSameFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); // Client may send another request message with a same domain-name. In this // case the same lease will be returned. The existing DNS entry should be @@ -1189,7 +1184,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestSolicit) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); // When the returning client sends Solicit the code should never generate // NameChangeRequest and preserve existing DNS entries for the client. @@ -1223,7 +1218,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenewDiffFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); // Client may send Renew message with a new domain-name. In this // case the same lease will be returned. The existing DNS entry needs to @@ -1239,12 +1234,12 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenewDiffFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:1:1::dead:beef", "000201D422AA463306223D269B6CB7AFE7AAD265FC" "EA97F93623019B2E0D14E5323D5A", - 0, lease_->valid_lft_); + lease_->valid_lft_); } // Test that client may send Request followed by the Renew, both holding @@ -1264,7 +1259,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenewSameFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); ASSERT_EQ(0, d2_mgr_.getQueueSize()); @@ -1303,7 +1298,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenewFqdnFlags) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); // Renew again with the same flags, this should not generate any NCRs. testProcessMessage(DHCPV6_RENEW, "myhost.example.com", @@ -1329,13 +1324,13 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenewFqdnFlags) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, lease_->valid_lft_); + lease_->valid_lft_); // Lastly, we renew with the N flag = 1 (which means no updates) so we // should have a dual direction remove NCR but NO add NCR. @@ -1347,7 +1342,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenewFqdnFlags) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); } TEST_F(FqdnDhcpv6SrvTest, processRequestRelease) { @@ -1371,7 +1366,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRelease) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, lease_->valid_lft_); + lease_->valid_lft_); // Client may send Release message. In this case the lease should be // removed and all existing DNS entries for this lease should also @@ -1384,7 +1379,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRelease) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - lease_->cltt_, lease_->valid_lft_); + lease_->valid_lft_); } TEST_F(FqdnDhcpv6SrvTest, processRequestReleaseNoDelete) { @@ -1405,7 +1400,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestReleaseNoDelete) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, lease_->valid_lft_); + lease_->valid_lft_); // Client may send Release message. In this case the lease should be // expired and no NameChangeRequest to remove DNS entries is generated. @@ -1428,7 +1423,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestWithoutFqdn) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); } // Checks that FQDN is generated from an ip address, when client sends an empty @@ -1443,7 +1438,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestEmptyFqdn) { "2001:db8:1:1::dead:beef", "000201C905E54BE12DE6AF92ADE72752B9F362" "13B5A8BC9D217548CD739B4CF31AFB1B", - 0, 4000); + 4000); } // Checks that when the server reuses expired lease, the NameChangeRequest @@ -1484,7 +1479,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestReuseExpiredLease) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, lease_->valid_lft_); + lease_->valid_lft_); // One of the following: IAID, DUID or subnet identifier has to be changed // because otherwise the allocation engine will treat the lease as // being renewed by the same client. If we at least change subnet identifier @@ -1514,13 +1509,13 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestReuseExpiredLease) { "2001:db8:1:1::dead:beef", "000201D422AA463306223D269B6CB7AFE7AAD2" "65FCEA97F93623019B2E0D14E5323D5A", - lease->cltt_, lease->valid_lft_); + lease->valid_lft_); // The second name change request should add a DNS mapping for // a new lease. verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" - "FAAAA3EBD29826B5C907B2C9268A6F52", 0, 4); + "FAAAA3EBD29826B5C907B2C9268A6F52", 4); } TEST_F(FqdnDhcpv6SrvTest, processClientDelegation) { @@ -1531,7 +1526,7 @@ TEST_F(FqdnDhcpv6SrvTest, processClientDelegation) { "2001:db8:1:1::dead:beef", "000201415AA33D1187D148275136FA30300478" "FAAAA3EBD29826B5C907B2C9268A6F52", - 0, 4000); + 4000); } // Verify that the host reservation is found and used. Lease host name and @@ -1585,7 +1580,7 @@ TEST_F(FqdnDhcpv6SrvTest, hostnameReservationSuffix) { "2001:db8:1:1::babe", "000201E2EB74FB53A5778E74AFD43870ECA5" "4150B1F52B0CFED434802DA1259D6D3CA4", - 0, 4000, "alice.example.com."); + 4000, "alice.example.com."); } // Verify that the host reservation is found and used, rather than dynamic @@ -1638,7 +1633,7 @@ TEST_F(FqdnDhcpv6SrvTest, hostnameReservationNoSuffix) { "2001:db8:1:1::babe", "000201E2EB74FB53A5778E74AFD43870ECA5" "4150B1F52B0CFED434802DA1259D6D3CA4", - 0, 4000, "alice.example.com."); + 4000, "alice.example.com."); } TEST_F(FqdnDhcpv6SrvTest, hostnameReservationDdnsDisabled) { @@ -1829,7 +1824,7 @@ TEST_F(FqdnDhcpv6SrvTest, ddnsScopeTest) { // ddns-send-updates for subnet 2 are enabled, verify the NCR is correct. ASSERT_EQ(1, CfgMgr::instance().getD2ClientMgr().getQueueSize()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:2::1", - "", 0, 4000); + "", 4000); } // Verifies that the DDNS parameters used for a lease in subnet in @@ -1904,7 +1899,7 @@ TEST_F(FqdnDhcpv6SrvTest, ddnsSharedNetworkTest) { // ddns-send-updates for subnet 1 are enabled, verify the NCR is correct. ASSERT_EQ(1, CfgMgr::instance().getD2ClientMgr().getQueueSize()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:1::1", - "", 0, 4000, "client1.one.example.com."); + "", 4000, "client1.one.example.com."); // Make sure the lease hostname and fqdn flags are correct. Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, @@ -1938,7 +1933,7 @@ TEST_F(FqdnDhcpv6SrvTest, ddnsSharedNetworkTest) { // ddns-send-updates for subnet 2 are enabled, verify the NCR is correct. ASSERT_EQ(1, CfgMgr::instance().getD2ClientMgr().getQueueSize()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:2::1", - "", 0, 4000, "client2.two.example.com."); + "", 4000, "client2.two.example.com."); // Make sure the lease hostname and fqdn flags are correct. lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, IOAddress("2001:db8:2::1")); @@ -2061,7 +2056,7 @@ TEST_F(FqdnDhcpv6SrvTest, ddnsSharedNetworkTest2) { // ddns-send-updates for subnet 1 are enabled, verify the NCR is correct. ASSERT_EQ(1, CfgMgr::instance().getD2ClientMgr().getQueueSize()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, "2001:db8:1::1", - "", 0, 4000, "client1.one.example.com."); + "", 4000, "client1.one.example.com."); // Make sure the lease hostname and fdqn flags are correct. Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, @@ -2185,7 +2180,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenew) { ASSERT_EQ(1, d2_mgr_.getQueueSize()); verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, old_lease->addr_.toText(), "", - 0, old_lease->valid_lft_, + old_lease->valid_lft_, old_lease->hostname_); } @@ -2205,7 +2200,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenew) { // Verify NCR content verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true, old_lease->addr_.toText(), "", - 0, old_lease->valid_lft_, + old_lease->valid_lft_, old_lease->hostname_); } @@ -2214,7 +2209,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenew) { // Verify NCR content verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, new_lease->addr_.toText(), "", - 0, new_lease->valid_lft_, + new_lease->valid_lft_, new_lease->hostname_); } @@ -2419,7 +2414,7 @@ TEST_F(FqdnDhcpv6SrvTest, poolDdnsParametersTest) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true, scenario.expected_address_.toText(), scenario.expected_dhcid_, - 0, 4000, + 4000, scenario.expected_fqdn_); } } diff --git a/src/bin/dhcp6/tests/http_control_socket_unittest.cc b/src/bin/dhcp6/tests/http_control_socket_unittest.cc index 03e3480d53..adec66d88c 100644 --- a/src/bin/dhcp6/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp6/tests/http_control_socket_unittest.cc @@ -133,8 +133,8 @@ public: /// @brief Pointer to the tested server object boost::shared_ptr server_; - /// @brief Flag which indicates if the server has stopped the IOService and - /// the client needs to handle it's own IO events. + /// @brief Flag which indicates if the server has stopped the IO service and + /// the client needs to handle its own IO events. bool handle_stop_; /// @brief Default constructor diff --git a/src/lib/d2srv/tests/nc_trans_unittests.cc b/src/lib/d2srv/tests/nc_trans_unittests.cc index 465ab44cbf..e5cf2b9e83 100644 --- a/src/lib/d2srv/tests/nc_trans_unittests.cc +++ b/src/lib/d2srv/tests/nc_trans_unittests.cc @@ -380,7 +380,6 @@ TEST_F(NameChangeTransactionTest, construction) { " \"fqdn\" : \"example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"use-conflict-resolution\" : true " "}"; diff --git a/src/lib/d2srv/testutils/nc_test_utils.cc b/src/lib/d2srv/testutils/nc_test_utils.cc index 076d6fccd0..8cf58ae402 100644 --- a/src/lib/d2srv/testutils/nc_test_utils.cc +++ b/src/lib/d2srv/testutils/nc_test_utils.cc @@ -273,7 +273,6 @@ TransactionTest::setupForIPv4Transaction(dhcp_ddns::NameChangeType chg_type, " \"fqdn\" : \"my.forward.example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; @@ -332,7 +331,6 @@ TransactionTest::setupForIPv6Transaction(dhcp_ddns::NameChangeType chg_type, " \"fqdn\" : \"my6.forward.example.com.\" , " " \"ip-address\" : \"2001:1::100\" , " " \"dhcid\" : \"0102030405060708\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; diff --git a/src/lib/d2srv/testutils/nc_test_utils.h b/src/lib/d2srv/testutils/nc_test_utils.h index 269fb9001c..21c3fed5e7 100644 --- a/src/lib/d2srv/testutils/nc_test_utils.h +++ b/src/lib/d2srv/testutils/nc_test_utils.h @@ -332,7 +332,6 @@ extern dns::RRsetPtr getRRFromSection(const D2UpdateMessagePtr& request, /// " \"fqdn\" : \"my.example.com.\" , " /// " \"ip-address\" : \"192.168.2.1\" , " /// " \"dhcid\" : \"0102030405060708\" , " -/// " \"lease-expires-on\" : \"20130121132405\" , " /// " \"lease-length\" : 1300 " /// "}"; /// diff --git a/src/lib/dhcp_ddns/libdhcp_ddns.dox b/src/lib/dhcp_ddns/libdhcp_ddns.dox index c285fd8f6c..727dd950e4 100644 --- a/src/lib/dhcp_ddns/libdhcp_ddns.dox +++ b/src/lib/dhcp_ddns/libdhcp_ddns.dox @@ -23,7 +23,6 @@ out DHCP-driven DNS updates. Each request contains the following information: given FQDN - dhcid - DHCID (a form of identification) of the client to whom the IP address is leased - - lease-expires-on - timestamp containing the date/time the lease expires - lease-length - duration in seconds for which the lease is valid. These requests are implemented in this library by the class, diff --git a/src/lib/dhcp_ddns/ncr_msg.cc b/src/lib/dhcp_ddns/ncr_msg.cc index 011bd19781..29a618147d 100644 --- a/src/lib/dhcp_ddns/ncr_msg.cc +++ b/src/lib/dhcp_ddns/ncr_msg.cc @@ -18,11 +18,9 @@ #include #include - namespace isc { namespace dhcp_ddns { - NameChangeFormat stringToNcrFormat(const std::string& fmt_str) { if (boost::iequals(fmt_str, "JSON")) { return FMT_JSON; @@ -31,14 +29,13 @@ NameChangeFormat stringToNcrFormat(const std::string& fmt_str) { isc_throw(BadValue, "Invalid NameChangeRequest format: " << fmt_str); } - std::string ncrFormatToString(NameChangeFormat format) { if (format == FMT_JSON) { return ("JSON"); } std::ostringstream stream; - stream << "UNKNOWN(" << format << ")"; + stream << "UNKNOWN(" << format << ")"; return (stream.str()); } @@ -78,7 +75,7 @@ ConflictResolutionModeToString(const ConflictResolutionMode& mode) { } std::ostringstream stream; - stream << "unknown(" << mode << ")"; + stream << "unknown(" << mode << ")"; return (stream.str()); } @@ -120,7 +117,6 @@ D2Dhcid::D2Dhcid(const isc::dhcp::DUID& duid, fromDUID(duid, wire_fqdn); } - void D2Dhcid::fromStr(const std::string& data) { bytes_.clear(); @@ -186,7 +182,6 @@ D2Dhcid::fromHWAddr(const isc::dhcp::HWAddrPtr& hwaddr, createDigest(DHCID_ID_HWADDR, hwaddr_data, wire_fqdn); } - void D2Dhcid::fromDUID(const isc::dhcp::DUID& duid, const std::vector& wire_fqdn) { @@ -258,29 +253,21 @@ operator<<(std::ostream& os, const D2Dhcid& dhcid) { return (os); } - - /**************************** NameChangeRequest ******************************/ - NameChangeRequest::NameChangeRequest() - : change_type_(CHG_ADD), forward_change_(false), - reverse_change_(false), fqdn_(""), ip_io_address_("0.0.0.0"), - dhcid_(), lease_expires_on_(), lease_length_(0), - conflict_resolution_mode_(CHECK_WITH_DHCID), - status_(ST_NEW) { + : change_type_(CHG_ADD), forward_change_(false), reverse_change_(false), + fqdn_(""), ip_io_address_("0.0.0.0"), dhcid_(), lease_length_(0), + conflict_resolution_mode_(CHECK_WITH_DHCID), status_(ST_NEW) { } NameChangeRequest::NameChangeRequest(const NameChangeType change_type, const bool forward_change, const bool reverse_change, const std::string& fqdn, const std::string& ip_address, - const D2Dhcid& dhcid, - const uint64_t lease_expires_on, - const uint32_t lease_length, + const D2Dhcid& dhcid, const uint32_t lease_length, const ConflictResolutionMode conflict_resolution_mode) : change_type_(change_type), forward_change_(forward_change), reverse_change_(reverse_change), fqdn_(fqdn), ip_io_address_("0.0.0.0"), - dhcid_(dhcid), lease_expires_on_(lease_expires_on), - lease_length_(lease_length), + dhcid_(dhcid), lease_length_(lease_length), conflict_resolution_mode_(conflict_resolution_mode), status_(ST_NEW) { @@ -405,9 +392,6 @@ NameChangeRequest::fromJSON(const std::string& json) { element = ncr->getElement("dhcid", element_map); ncr->setDhcid(element); - element = ncr->getElement("lease-expires-on", element_map); - ncr->setLeaseExpiresOn(element); - element = ncr->getElement("lease-length", element_map); ncr->setLeaseLength(element); @@ -436,7 +420,7 @@ NameChangeRequest::fromJSON(const std::string& json) { } std::string -NameChangeRequest::toJSON() const { +NameChangeRequest::toJSON() const { // Create a JSON string of this request's contents. Note that this method // does NOT use the isc::data library as generating the output is straight // forward. @@ -450,7 +434,6 @@ NameChangeRequest::toJSON() const { << "\"fqdn\":\"" << getFqdn() << "\"," << "\"ip-address\":\"" << getIpAddress() << "\"," << "\"dhcid\":\"" << getDhcid().toStr() << "\"," - << "\"lease-expires-on\":\"" << getLeaseExpiresOnStr() << "\"," << "\"lease-length\":" << getLeaseLength() << "," << "\"conflict-resolution-mode\":" << "\"" <stringValue()); @@ -600,7 +580,6 @@ NameChangeRequest::setIpAddress(isc::data::ConstElementPtr element) { setIpAddress(element->stringValue()); } - void NameChangeRequest::setDhcid(const std::string& value) { dhcid_.fromStr(value); @@ -611,28 +590,6 @@ NameChangeRequest::setDhcid(isc::data::ConstElementPtr element) { setDhcid(element->stringValue()); } -std::string -NameChangeRequest::getLeaseExpiresOnStr() const { - return (isc::util::timeToText64(lease_expires_on_)); -} - -void -NameChangeRequest::setLeaseExpiresOn(const std::string& value) { - try { - lease_expires_on_ = isc::util::timeFromText64(value); - } catch (...) { - // We were given an invalid string, so throw. - isc_throw(NcrMessageError, - "Invalid date-time string: [" << value << "]"); - } - -} - -void NameChangeRequest::setLeaseExpiresOn(isc::data::ConstElementPtr element) { - // Pull out the string value and pass it into the string setter. - setLeaseExpiresOn(element->stringValue()); -} - void NameChangeRequest::setLeaseLength(const uint32_t value) { lease_length_ = value; @@ -657,7 +614,7 @@ NameChangeRequest::setLeaseLength(isc::data::ConstElementPtr element) { } if (value < 0) { isc_throw(NcrMessageError, "lease_length value " << value << - "is negative. It must greater than or equal to zero "); + "is negative. It must greater than or equal to zero "); } // Good to go, make the assignment. @@ -723,7 +680,6 @@ NameChangeRequest::toText() const { << "FQDN: [" << fqdn_ << "]" << std::endl << "IP Address: [" << ip_io_address_ << "]" << std::endl << "DHCID: [" << dhcid_.toStr() << "]" << std::endl - << "Lease Expires On: " << getLeaseExpiresOnStr() << std::endl << "Lease Length: " << lease_length_ << std::endl << "Conflict Resolution Mode: " << ConflictResolutionModeToString(getConflictResolutionMode()) @@ -740,7 +696,6 @@ NameChangeRequest::operator == (const NameChangeRequest& other) const { (fqdn_ == other.fqdn_) && (ip_io_address_ == other.ip_io_address_) && (dhcid_ == other.dhcid_) && - (lease_expires_on_ == other.lease_expires_on_) && (lease_length_ == other.lease_length_) && (conflict_resolution_mode_ == other.conflict_resolution_mode_)); } @@ -750,6 +705,5 @@ NameChangeRequest::operator != (const NameChangeRequest& other) const { return (!(*this == other)); } - } // end of isc::dhcp namespace } // end of isc namespace diff --git a/src/lib/dhcp_ddns/ncr_msg.h b/src/lib/dhcp_ddns/ncr_msg.h index b6ace7985a..9a6810bc9c 100644 --- a/src/lib/dhcp_ddns/ncr_msg.h +++ b/src/lib/dhcp_ddns/ncr_msg.h @@ -287,7 +287,6 @@ public: const bool forward_change, const bool reverse_change, const std::string& fqdn, const std::string& ip_address, const D2Dhcid& dhcid, - const uint64_t lease_expires_on, const uint32_t lease_length, const ConflictResolutionMode conflict_resolution_mode = CHECK_WITH_DHCID); @@ -307,7 +306,7 @@ public: /// (NOTE currently only JSON is supported.) /// /// @param format indicates the data format to use - /// @param buffer is the input buffer containing the marshalled request + /// @param buffer is the input buffer containing the marshaled request /// /// @return a pointer to the new NameChangeRequest /// @@ -352,7 +351,6 @@ public: /// "fqdn" : "", /// "ip-address" : "
", /// "dhcid" : "", - /// "lease-expires-on" : "", /// "lease-length" : , /// "use-conflict-resolution": /// } @@ -380,14 +378,6 @@ public: /// been leased. The value is a string containing an even number of /// hexadecimal digits without delimiters such as "2C010203040A7F8E3D" /// (case insensitive). - /// - lease-expires-on - the date and time on which the lease expires. - /// The value is a string of the form "yyyymmddHHMMSS" where: - /// - yyyy - four digit year - /// - mm - month of year (1-12), - /// - dd - day of the month (1-31), - /// - HH - hour of the day (0-23) - /// - MM - minutes of the hour (0-59) - /// - SS - seconds of the minute (0-59) /// - lease-length - the length of the lease in seconds. This is an /// integer and may range between 1 and 4294967295 (2^32 - 1) inclusive. /// - use-conflict-resolution - when true, follow RFC 4703 which uses @@ -405,7 +395,6 @@ public: /// "fqdn" : "myhost.example.com.", /// "ip-address" : "192.168.2.1" , /// "dhcid" : "010203040A7F8E3D" , - /// "lease-expires-on" : "20130121132405", /// "lease-length" : 1300, /// "use-conflict-resolution": true /// } @@ -421,7 +410,6 @@ public: /// "fqdn" : "someother.example.com.", /// "ip-address" : "2001::db8:1::2", /// "dhcid" : "010203040A7F8E3D" , " - /// "lease-expires-on" : "20130121132405", /// "lease-length" : 27400, /// "use-conflict-resolution": true /// } @@ -625,47 +613,6 @@ public: return (dhcid_.toStr()); } - /// @brief Fetches the request lease expiration - /// - /// @return the lease expiration as the number of seconds since - /// the (00:00:00 January 1, 1970) - uint64_t getLeaseExpiresOn() const { - return (lease_expires_on_); - } - - /// @brief Fetches the request lease expiration as string. - /// - /// The format of the string returned is: - /// - /// YYYYMMDDHHmmSS - /// - /// Example: 18:54:54 June 26, 2013 would be: 20130626185455 - /// NOTE This is always UTC time. - /// - /// @return a ISO date-time string of the lease expiration. - std::string getLeaseExpiresOnStr() const; - - /// @brief Sets the lease expiration based on the given string. - /// - /// @param value is an date-time string from which to set the - /// lease expiration. The format of the input is: - /// - /// YYYYMMDDHHmmSS - /// - /// Example: 18:54:54 June 26, 2013 would be: 20130626185455 - /// NOTE This is always UTC time. - /// - /// @throw NcrMessageError if the ISO string is invalid. - void setLeaseExpiresOn(const std::string& value); - - /// @brief Sets the lease expiration based on the given Element. - /// - /// @param element is string Element containing a date-time string. - /// - /// @throw NcrMessageError if the element is not a string - /// Element, or if the element value is an invalid date-time string. - void setLeaseExpiresOn(isc::data::ConstElementPtr element); - /// @brief Fetches the request lease length. /// /// @return an integer containing the lease length @@ -782,9 +729,6 @@ private: /// dns::DHCID which provides additional validation. D2Dhcid dhcid_; - /// @brief The date-time the lease expires. - uint64_t lease_expires_on_; - /// @brief The amount of time in seconds for which the lease is valid (TTL). uint32_t lease_length_; diff --git a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc index 927c651004..b9bdff2bf2 100644 --- a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc @@ -38,7 +38,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -50,7 +49,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"no-check-with-dhcid\"" "}", @@ -62,7 +60,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}" @@ -230,8 +227,6 @@ public: ncr_buffer.getLength()), listener_endpoint); } - - /// @brief Handler invoked when test timeout is hit /// /// This callback stops all running (hanging) tasks on IO service. @@ -1353,7 +1348,6 @@ TEST_F(NameChangeUDPSenderBasicTest, watchClosedAfterSendRequestMultiThreading) EXPECT_EQ(1, sender.getQueueSize()); } - // Tests error handling of a failure to clear the watch socket during // completion handling. TEST_F(NameChangeUDPSenderBasicTest, watchSocketBadRead) { diff --git a/src/lib/dhcp_ddns/tests/ncr_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_unittests.cc index 9bcd320c28..ad50fcd93a 100644 --- a/src/lib/dhcp_ddns/tests/ncr_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_unittests.cc @@ -33,7 +33,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -45,7 +44,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -57,7 +55,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -69,7 +66,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300 " "}", // Has use-conflict-resolution instead of mode @@ -80,7 +76,6 @@ const char *valid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"use-conflict-resolution\": true" "}" @@ -98,7 +93,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -110,7 +104,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -122,7 +115,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -134,7 +126,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -146,7 +137,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -158,7 +148,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \".bad_name\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -170,7 +159,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"xxxxxx\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300 " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -182,7 +170,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -194,7 +181,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -206,19 +192,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"THIS IS BOGUS!!!\" , " - " \"lease-expires-on\" : \"20130121132405\" , " - " \"lease-length\" : 1300, " - " \"conflict-resolution-mode\": \"check-with-dhcid\"" - "}", - // Invalid lease expiration string - "{" - " \"change-type\" : 0 , " - " \"forward-change\" : true , " - " \"reverse-change\" : false , " - " \"fqdn\" : \"walah.walah.com\" , " - " \"ip-address\" : \"192.168.2.1\" , " - " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"Wed Jun 26 13:46:46 EDT 2013\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", @@ -230,11 +203,10 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : \"BOGUS\", " " \"conflict-resolution-mode\": \"check-with-dhcid\"" "}", - // Invalid conflict-resolution-mode + // Invalid conflict-resolution-mode. "{" " \"change-type\" : 0 , " " \"forward-change\" : true , " @@ -242,11 +214,10 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\": \"bogus\"" "}" - // Invalid use-conflict-resolution + // Invalid use-conflict-resolution. "{" " \"change-type\" : 0 , " " \"forward-change\" : true , " @@ -254,7 +225,6 @@ const char *invalid_msgs[] = " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300, " " \"use-conflict-resolution\": \"bogus\"" "}" @@ -275,31 +245,30 @@ TEST(NameChangeRequestTest, constructionTests) { EXPECT_TRUE(ncr); // Verify that full constructor works. - uint64_t expiry = isc::util::detail::getTimeWrapper(); D2Dhcid dhcid("010203040A7F8E3D"); EXPECT_NO_THROW(ncr.reset(new NameChangeRequest( CHG_ADD, true, true, "walah.walah.com", - "192.168.1.101", dhcid, expiry, 1300))); + "192.168.1.101", dhcid, 1300))); EXPECT_TRUE(ncr); ncr.reset(); // Verify blank FQDN is detected. EXPECT_THROW(NameChangeRequest(CHG_ADD, true, true, "", - "192.168.1.101", dhcid, expiry, 1300), NcrMessageError); + "192.168.1.101", dhcid, 1300), NcrMessageError); // Verify that an invalid IP address is detected. EXPECT_THROW(NameChangeRequest(CHG_ADD, true, true, "valid.fqdn", - "xxx.168.1.101", dhcid, expiry, 1300), NcrMessageError); + "xxx.168.1.101", dhcid, 1300), NcrMessageError); // Verify that a blank DHCID is detected. D2Dhcid blank_dhcid; EXPECT_THROW(NameChangeRequest(CHG_ADD, true, true, "walah.walah.com", - "192.168.1.101", blank_dhcid, expiry, 1300), NcrMessageError); + "192.168.1.101", blank_dhcid, 1300), NcrMessageError); // Verify that one or both of direction flags must be true. EXPECT_THROW(NameChangeRequest(CHG_ADD, false, false, "valid.fqdn", - "192.168.1.101", dhcid, expiry, 1300), NcrMessageError); + "192.168.1.101", dhcid, 1300), NcrMessageError); } @@ -475,8 +444,6 @@ TEST_F(DhcidTest, fromClientId) { clientid.clear(); EXPECT_THROW(dhcid.fromClientId(clientid, wire_fqdn_), isc::dhcp_ddns::DhcidRdataComputeError); - - } // This test verifies that DHCID is properly computed from a buffer holding @@ -574,7 +541,6 @@ TEST(NameChangeRequestTest, basicJsonTest) { "\"fqdn\":\"walah.walah.com.\"," "\"ip-address\":\"192.168.2.1\"," "\"dhcid\":\"010203040A7F8E3D\"," - "\"lease-expires-on\":\"20130121132405\"," "\"lease-length\":1300," "\"conflict-resolution-mode\":\"check-with-dhcid\"" "}"; @@ -604,14 +570,15 @@ TEST(NameChangeRequestTest, basicJsonTest) { /// 2. Invalid forward change /// 3. Invalid reverse change /// 4. Forward and reverse change both false -/// 5. Invalid forward change -/// 6. Blank FQDN +/// 5. Blank FQDN +/// 6. Malformed FQDN /// 7. Bad IP address /// 8. Blank DHCID /// 9. Odd number of digits in DHCID /// 10. Text in DHCID -/// 11. Invalid lease expiration string -/// 12. Non-integer for lease length. +/// 11. Non-integer for lease length. +/// 12. Invalid conflict-resolution-mode. +/// 13. Invalid use-conflict-resolution. /// If more permutations arise they can easily be added to the list. TEST(NameChangeRequestTest, invalidMsgChecks) { // Iterate over the list of JSON strings, attempting to create a @@ -660,7 +627,6 @@ TEST(NameChangeRequestTest, toFromBufferTest) { "\"fqdn\":\"walah.walah.com.\"," "\"ip-address\":\"192.168.2.1\"," "\"dhcid\":\"010203040A7F8E3D\"," - "\"lease-expires-on\":\"20130121132405\"," "\"lease-length\":1300," "\"conflict-resolution-mode\":\"check-with-dhcid\"" "}"; @@ -690,6 +656,59 @@ TEST(NameChangeRequestTest, toFromBufferTest) { ASSERT_EQ(final_str, msg_str); } +/// @brief Tests converting to and from JSON via isc::util buffer classes. +/// This test verifies that a InputBuffer containing a valid JSON request rendition +/// but with extra parameter can be used to create a NameChangeRequest. +TEST(NameChangeRequestTest, toFromBufferTestWithExtra) { + // Define a string containing a valid JSON NameChangeRequest rendition. + std::string msg_str = "{" + "\"change-type\":1," + "\"forward-change\":true," + "\"reverse-change\":false," + "\"fqdn\":\"walah.walah.com.\"," + "\"ip-address\":\"192.168.2.1\"," + "\"dhcid\":\"010203040A7F8E3D\"," + "\"extra\":\"19700101000000\"," + "\"lease-length\":1300," + "\"conflict-resolution-mode\":\"check-with-dhcid\"" + "}"; + + // Create a request from JSON directly. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(msg_str)); + + // Verify that we output the request as JSON text to a buffer + // without error. + isc::util::OutputBuffer output_buffer(1024); + ASSERT_NO_THROW(ncr->toFormat(FMT_JSON, output_buffer)); + + // Make an InputBuffer from the OutputBuffer. + isc::util::InputBuffer input_buffer(output_buffer.getData(), + output_buffer.getLength()); + + // Verify that we can create a new request from the InputBuffer. + NameChangeRequestPtr ncr2; + ASSERT_NO_THROW(ncr2 = + NameChangeRequest::fromFormat(FMT_JSON, input_buffer)); + + // Convert the new request to JSON directly. + std::string final_str = ncr2->toJSON(); + + std::string exp_msg_str = "{" + "\"change-type\":1," + "\"forward-change\":true," + "\"reverse-change\":false," + "\"fqdn\":\"walah.walah.com.\"," + "\"ip-address\":\"192.168.2.1\"," + "\"dhcid\":\"010203040A7F8E3D\"," + "\"lease-length\":1300," + "\"conflict-resolution-mode\":\"check-with-dhcid\"" + "}"; + + // Verify that the final string matches the original. + ASSERT_EQ(final_str, exp_msg_str); +} + /// @brief Tests ip address modification and validation TEST(NameChangeRequestTest, ipAddresses) { NameChangeRequest ncr; @@ -742,7 +761,6 @@ TEST(NameChangeRequestTest, useConflictResolutionParsing) { " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300 "; std::string its_true(base_json + ",\"use-conflict-resolution\": true}"); @@ -771,7 +789,6 @@ TEST(NameChangeRequestTest, ConflictResolutionModeParsing) { " \"fqdn\" : \"walah.walah.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20130121132405\" , " " \"lease-length\" : 1300 "; std::string its_check_with_dhcid(base_json + ",\"conflict-resolution-mode\": \"check-with-dhcid\"}"); diff --git a/src/lib/dhcpsrv/ncr_generator.cc b/src/lib/dhcpsrv/ncr_generator.cc index 659ab1832a..267e32d93e 100644 --- a/src/lib/dhcpsrv/ncr_generator.cc +++ b/src/lib/dhcpsrv/ncr_generator.cc @@ -87,8 +87,7 @@ void queueNCRCommon(const NameChangeType& chg_type, const LeasePtrType& lease, NameChangeRequestPtr ncr (new NameChangeRequest(chg_type, lease->fqdn_fwd_, lease->fqdn_rev_, lease->hostname_, lease->addr_.toText(), - dhcid, lease->cltt_ + ttl, - ttl, conflict_resolution_mode)); + dhcid, ttl, conflict_resolution_mode)); LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL_DATA, DHCPSRV_QUEUE_NCR) .arg(label) diff --git a/src/lib/dhcpsrv/tests/d2_udp_unittest.cc b/src/lib/dhcpsrv/tests/d2_udp_unittest.cc index 163082e1fd..1e7378b4e8 100644 --- a/src/lib/dhcpsrv/tests/d2_udp_unittest.cc +++ b/src/lib/dhcpsrv/tests/d2_udp_unittest.cc @@ -183,7 +183,6 @@ public: " \"fqdn\" : \"myhost.example.com.\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " - " \"lease-expires-on\" : \"20140121132405\" , " " \"lease-length\" : 1300, " " \"conflict-resolution-mode\" : \"check-with-dhcid\"" "}"; diff --git a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc index a908d6e3db..8ccc772b16 100644 --- a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc +++ b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc @@ -132,8 +132,6 @@ public: /// these values programmatically and place them here. Should the /// underlying implementation of createDigest() change these test values /// will likely need to be updated as well. - /// @param expires A timestamp when the lease associated with the - /// NameChangeRequest expires. /// @param len A valid lifetime of the lease associated with the /// NameChangeRequest. /// @param fqdn The expected string value of the FQDN, if blank the @@ -144,7 +142,6 @@ public: const bool reverse, const bool forward, const std::string& addr, const std::string& dhcid, - const uint64_t expires, const uint16_t len, const std::string& fqdn="", const ConflictResolutionMode @@ -158,7 +155,6 @@ public: EXPECT_EQ(reverse, ncr->isReverseChange()); EXPECT_EQ(addr, ncr->getIpAddress()); EXPECT_EQ(dhcid, ncr->getDhcid().toStr()); - EXPECT_EQ(expires, ncr->getLeaseExpiresOn()); EXPECT_EQ(len, ncr->getLeaseLength()); EXPECT_EQ(isc::dhcp_ddns::ST_NEW, ncr->getStatus()); EXPECT_EQ(conflict_resolution_mode, ncr->getConflictResolutionMode()); @@ -249,7 +245,7 @@ public: // Check the details of the NCR. verifyNameChangeRequest(chg_type, rev, fwd, lease_->addr_.toText(), exp_dhcid, - lease_->cltt_ + ttl, ttl, fqdn, exp_cr_mode); + ttl, fqdn, exp_cr_mode); } /// @brief Test that calling queueNCR for NULL lease doesn't cause @@ -657,8 +653,7 @@ TEST_F(NCRGenerator4Test, useClientId) { verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true, "192.0.2.1", "000101C7AA5420483BDA99C437636EA7DA2FE18" - "31C9679FEB031C360CA571298F3D1FA", - lease_->cltt_ + ttl, ttl); + "31C9679FEB031C360CA571298F3D1FA", ttl); { SCOPED_TRACE("case CHG_REMOVE"); testNCR(CHG_REMOVE, true, true, "myhost.example.com.",