/// server id.
///
/// @param msg_type A type of the message to be created.
- /// @param srv An object representing the DHCPv6 server, which
- /// is used to generate the client identifier.
///
/// @return An object representing the created message.
- Pkt6Ptr generateMessageWithIds(const uint8_t msg_type,
- NakedDhcpv6Srv& srv) {
+ Pkt6Ptr generateMessageWithIds(const uint8_t msg_type) {
Pkt6Ptr pkt = Pkt6Ptr(new Pkt6(msg_type, 1234));
// Generate client-id.
OptionPtr opt_clientid = generateClientId();
if (msg_type != DHCPV6_SOLICIT) {
// Generate server-id.
- pkt->addOption(srv.getServerID());
+ pkt->addOption(srv_->getServerID());
}
return (pkt);
const uint8_t exp_flags,
const std::string& exp_domain_name) {
-// NakedDhcpv6Srv srv(0);
-
Pkt6Ptr question = generateMessage(msg_type,
in_flags,
in_domain_name,
///
/// @param msg_type A type of the client's message.
/// @param hostname A domain name in the client's FQDN.
- /// @param srv A server object, used to process the message.
/// @param include_oro A boolean value which indicates whether the ORO
/// option should be included in the client's message (if true) or not
/// (if false). In the former case, the function will expect that server
void testProcessMessage(const uint8_t msg_type,
const std::string& hostname,
const std::string& exp_hostname,
- NakedDhcpv6Srv& srv,
const bool include_oro = true) {
// Create a message of a specified type, add server id and
// FQDN option.
- OptionPtr srvid = srv.getServerID();
+ OptionPtr srvid = srv_->getServerID();
// Set the appropriate FQDN type. It must be partial if hostname is
// empty.
Option6ClientFqdn::DomainNameType fqdn_type = (hostname.empty() ?
// functions to generate response.
Pkt6Ptr reply;
if (msg_type == DHCPV6_SOLICIT) {
- ASSERT_NO_THROW(reply = srv.processSolicit(req));
+ ASSERT_NO_THROW(reply = srv_->processSolicit(req));
} else if (msg_type == DHCPV6_REQUEST) {
- ASSERT_NO_THROW(reply = srv.processRequest(req));
+ ASSERT_NO_THROW(reply = srv_->processRequest(req));
} else if (msg_type == DHCPV6_RENEW) {
- ASSERT_NO_THROW(reply = srv.processRequest(req));
+ ASSERT_NO_THROW(reply = srv_->processRequest(req));
} else if (msg_type == DHCPV6_RELEASE) {
// For Release no lease will be acquired so we have to leave
// function here.
- ASSERT_NO_THROW(reply = srv.processRelease(req));
+ ASSERT_NO_THROW(reply = srv_->processRelease(req));
return;
} else {
// We are not interested in testing other message types.
/// queue and checks that it holds valid parameters. The NameChangeRequest
/// is removed from the queue.
///
- /// @param srv A server object holding a queue of NameChangeRequests.
/// @param type An expected type of the NameChangeRequest (Add or Remove).
/// @param reverse An expected setting of the reverse update flag.
/// @param forward An expected setting of the forward udpate flag.
/// NameChangeRequest expires.
/// @param len A valid lifetime of the lease associated with the
/// NameChangeRequest.
- void verifyNameChangeRequest(NakedDhcpv6Srv& srv,
- const isc::dhcp_ddns::NameChangeType type,
+ void verifyNameChangeRequest(const isc::dhcp_ddns::NameChangeType type,
const bool reverse, const bool forward,
const std::string& addr,
const std::string& dhcid,
// Test that exception is thrown if supplied NULL answer packet when
// creating NameChangeRequests.
TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequestsNoAnswer) {
- NakedDhcpv6Srv srv(0);
-
Pkt6Ptr answer;
- EXPECT_THROW(srv.createNameChangeRequests(answer),
+ EXPECT_THROW(srv_->createNameChangeRequests(answer),
isc::Unexpected);
}
// Test that exception is thrown if supplied answer from the server
// contains no DUID when creating NameChangeRequests.
TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequestsNoDUID) {
- NakedDhcpv6Srv srv(0);
-
Pkt6Ptr answer = Pkt6Ptr(new Pkt6(DHCPV6_REPLY, 1234));
Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
"myhost.example.com",
Option6ClientFqdn::FULL);
answer->addOption(fqdn);
- EXPECT_THROW(srv.createNameChangeRequests(answer), isc::Unexpected);
+ EXPECT_THROW(srv_->createNameChangeRequests(answer), isc::Unexpected);
}
// Test no NameChangeRequests if Client FQDN is not added to the server's
// response.
TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequestsNoFQDN) {
- NakedDhcpv6Srv srv(0);
-
// Create Reply message with Client Id and Server id.
- Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY, srv);
+ Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY);
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
+ ASSERT_NO_THROW(srv_->createNameChangeRequests(answer));
// There should be no new NameChangeRequests.
ASSERT_EQ(0, d2_mgr_.getQueueSize());
// Test that NameChangeRequests are not generated if an answer message
// contains no addresses.
TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequestsNoAddr) {
- NakedDhcpv6Srv srv(0);
-
// Create Reply message with Client Id and Server id.
- Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY, srv);
+ Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY);
// Add Client FQDN option.
Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
Option6ClientFqdn::FULL);
answer->addOption(fqdn);
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
+ ASSERT_NO_THROW(srv_->createNameChangeRequests(answer));
// We didn't add any IAs, so there should be no NameChangeRequests in th
// queue.
// Test that exactly one NameChangeRequest is created as a result of processing
// the answer message which holds 3 IAs and when FQDN is specified.
TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequests) {
- NakedDhcpv6Srv srv(0);
-
// Create Reply message with Client Id and Server id.
- Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY, srv);
+ Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY);
// Create three IAs, each having different address.
addIA(1234, IOAddress("2001:db8:1::1"), answer);
answer->addOption(fqdn);
// Create NameChangeRequest for the first allocated address.
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
+ ASSERT_NO_THROW(srv_->createNameChangeRequests(answer));
ASSERT_EQ(1, d2_mgr_.getQueueSize());
// Verify that NameChangeRequest is correct.
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1::1",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// Checks that NameChangeRequests to add entries are not
// created when ddns updates are disabled.
TEST_F(FqdnDhcpv6SrvTest, noAddRequestsWhenDisabled) {
- NakedDhcpv6Srv srv(0);
-
// Disable DDNS udpates.
disableD2();
// Create Reply message with Client Id and Server id.
- Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY, srv);
+ Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY);
// Create three IAs, each having different address.
addIA(1234, IOAddress("2001:db8:1::1"), answer);
answer->addOption(fqdn);
// An attempt to send a NCR would throw.
- ASSERT_NO_THROW(srv.createNameChangeRequests(answer));
+ ASSERT_NO_THROW(srv_->createNameChangeRequests(answer));
}
// Test creation of the NameChangeRequest to remove both forward and reverse
// mapping for the given lease.
TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestFwdRev) {
- NakedDhcpv6Srv srv(0);
-
lease_->fqdn_fwd_ = true;
lease_->fqdn_rev_ = true;
// Part of the domain name is in upper case, to test that it gets converted
// as if we typed domain-name in lower case.
lease_->hostname_ = "MYHOST.example.com.";
- ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
+ ASSERT_NO_THROW(srv_->createRemovalNameChangeRequest(lease_));
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true,
"2001:db8:1::1",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// Checks that NameChangeRequests to remove entries are not created
// when ddns updates are disabled.
TEST_F(FqdnDhcpv6SrvTest, noRemovalsWhenDisabled) {
- NakedDhcpv6Srv srv(0);
-
// Disable DDNS updates.
disableD2();
lease_->hostname_ = "MYHOST.example.com.";
// When DDNS is disabled an attempt to send a request will throw.
- ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
+ ASSERT_NO_THROW(srv_->createRemovalNameChangeRequest(lease_));
}
// Test creation of the NameChangeRequest to remove reverse mapping for the
// given lease.
TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestRev) {
- NakedDhcpv6Srv srv(0);
-
lease_->fqdn_fwd_ = false;
lease_->fqdn_rev_ = true;
lease_->hostname_ = "myhost.example.com.";
- ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
+ ASSERT_NO_THROW(srv_->createRemovalNameChangeRequest(lease_));
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, false,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, false,
"2001:db8:1::1",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// Test that NameChangeRequest to remove DNS records is not generated when
// neither forward nor reverse DNS update has been performed for a lease.
TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestNoUpdate) {
- NakedDhcpv6Srv srv(0);
-
lease_->fqdn_fwd_ = false;
lease_->fqdn_rev_ = false;
- ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
+ ASSERT_NO_THROW(srv_->createRemovalNameChangeRequest(lease_));
ASSERT_EQ(0, d2_mgr_.getQueueSize());
// Test that NameChangeRequest is not generated if the hostname hasn't been
// specified for a lease for which forward and reverse mapping has been set.
TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestNoHostname) {
- NakedDhcpv6Srv srv(0);
-
lease_->fqdn_fwd_ = true;
lease_->fqdn_rev_ = true;
lease_->hostname_ = "";
- ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
+ ASSERT_NO_THROW(srv_->createRemovalNameChangeRequest(lease_));
ASSERT_EQ(0, d2_mgr_.getQueueSize());
// been specified for a lease for which forward and reverse mapping has been
// set.
TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestWrongHostname) {
- NakedDhcpv6Srv srv(0);
-
lease_->fqdn_fwd_ = true;
lease_->fqdn_rev_ = true;
lease_->hostname_ = "myhost..example.com.";
- ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
+ ASSERT_NO_THROW(srv_->createRemovalNameChangeRequest(lease_));
ASSERT_EQ(0, d2_mgr_.getQueueSize());
// Test that Advertise message generated in a response to the Solicit will
// not result in generation if the NameChangeRequests.
TEST_F(FqdnDhcpv6SrvTest, processSolicit) {
- NakedDhcpv6Srv srv(0);
-
// Create a Solicit message with FQDN option and generate server's
// response using processSolicit function.
testProcessMessage(DHCPV6_SOLICIT, "myhost.example.com",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
ASSERT_EQ(0, d2_mgr_.getQueueSize());
}
// request but modify the DNS entries for the lease according to the contents
// of the FQDN sent in the second request.
TEST_F(FqdnDhcpv6SrvTest, processTwoRequests) {
- NakedDhcpv6Srv srv(0);
-
// Create a Request message with FQDN option and generate server's
// response using processRequest function. This will result in the
// creation of a new lease and the appropriate NameChangeRequest
// to add both reverse and forward mapping to DNS.
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// should be added. Therefore, we expect two NameChangeRequests. One to
// remove the existing entries, one to add new entries.
testProcessMessage(DHCPV6_REQUEST, "otherhost.example.com",
- "otherhost.example.com.", srv);
+ "otherhost.example.com.");
ASSERT_EQ(2, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
0, 4000);
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201D422AA463306223D269B6CB7AFE7AAD265FC"
"EA97F93623019B2E0D14E5323D5A",
// DNS if the Request was sent instead of Soicit. The code should differentiate
// behavior depending whether Solicit or Request is sent.
TEST_F(FqdnDhcpv6SrvTest, processRequestSolicit) {
- NakedDhcpv6Srv srv(0);
-
// Create a Request message with FQDN option and generate server's
// response using processRequest function. This will result in the
// creation of a new lease and the appropriate NameChangeRequest
// to add both reverse and forward mapping to DNS.
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// The NameChangeRequest should only be generated when a client sends
// Request or Renew.
testProcessMessage(DHCPV6_SOLICIT, "otherhost.example.com",
- "otherhost.example.com.", srv);
+ "otherhost.example.com.");
ASSERT_EQ(0, d2_mgr_.getQueueSize());
}
// DNS entry added previously when Request was processed, another one to
// add a new entry for the FQDN held in the Renew.
TEST_F(FqdnDhcpv6SrvTest, processRequestRenew) {
- NakedDhcpv6Srv srv(0);
-
// Create a Request message with FQDN option and generate server's
// response using processRequest function. This will result in the
// creation of a new lease and the appropriate NameChangeRequest
// to add both reverse and forward mapping to DNS.
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// should be added. Therefore, we expect two NameChangeRequests. One to
// remove the existing entries, one to add new entries.
testProcessMessage(DHCPV6_RENEW, "otherhost.example.com",
- "otherhost.example.com.", srv);
+ "otherhost.example.com.");
ASSERT_EQ(2, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
0, 4000);
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201D422AA463306223D269B6CB7AFE7AAD265FC"
"EA97F93623019B2E0D14E5323D5A",
}
TEST_F(FqdnDhcpv6SrvTest, processRequestRelease) {
- NakedDhcpv6Srv srv(0);
-
// Create a Request message with FQDN option and generate server's
// response using processRequest function. This will result in the
// creation of a new lease and the appropriate NameChangeRequest
// to add both reverse and forward mapping to DNS.
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// also removed. Therefore, we expect that single NameChangeRequest to
// remove DNS entries is generated.
testProcessMessage(DHCPV6_RELEASE, "otherhost.example.com",
- "otherhost.example.com.", srv);
+ "otherhost.example.com.");
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// Checks that the server include DHCPv6 Client FQDN option in its
// response even when client doesn't request this option using ORO.
TEST_F(FqdnDhcpv6SrvTest, processRequestWithoutFqdn) {
- NakedDhcpv6Srv srv(0);
-
// The last parameter disables use of the ORO to request FQDN option
// In this case, we expect that the FQDN option will not be included
// in the server's response. The testProcessMessage will check that.
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com",
- "myhost.example.com.", srv, false);
+ "myhost.example.com.", false);
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// Checks that FQDN is generated from an ip address, when client sends an empty
// FQDN.
TEST_F(FqdnDhcpv6SrvTest, processRequestEmptyFqdn) {
- NakedDhcpv6Srv srv(0);
-
testProcessMessage(DHCPV6_REQUEST, "",
- "myhost-2001-db8-1-1--dead-beef.example.com.",
- srv, false);
+ "myhost-2001-db8-1-1--dead-beef.example.com.", false);
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201C905E54BE12DE6AF92ADE72752B9F362"
"13B5A8BC9D217548CD739B4CF31AFB1B",
CfgMgr::instance().addSubnet6(subnet_);
// Allocate a lease.
- NakedDhcpv6Srv srv(0);
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
// Test that the appropriate NameChangeRequest has been generated.
ASSERT_EQ(1, d2_mgr_.getQueueSize());
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",
// lease database, it is guaranteed that the allocation engine will
// reuse this lease.
testProcessMessage(DHCPV6_REQUEST, "myhost.example.com.",
- "myhost.example.com.", srv);
+ "myhost.example.com.");
ASSERT_EQ(2, d2_mgr_.getQueueSize());
// The first name change request generated, should remove a DNS
// mapping for an expired lease.
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, true, true,
"2001:db8:1:1::dead:beef",
"000201D422AA463306223D269B6CB7AFE7AAD2"
"65FCEA97F93623019B2E0D14E5323D5A",
0, 5);
// The second name change request should add a DNS mapping for
// a new lease.
- verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ verifyNameChangeRequest(isc::dhcp_ddns::CHG_ADD, true, true,
"2001:db8:1:1::dead:beef",
"000201415AA33D1187D148275136FA30300478"
"FAAAA3EBD29826B5C907B2C9268A6F52",