-// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
ASSERT_NO_FATAL_FAILURE(verifyAssignedStats());
}
+ /// @brief Check precedence.
+ ///
+ /// @param config the configuration.
+ /// @param ns_address expected name server address.
+ void testPrecedence(const std::string& config, const std::string& ns_address) {
+ // Create client and set MAC address to the one that has a reservation.
+ Dhcp4Client client(Dhcp4Client::SELECTING);
+ client.setIfaceName("eth1");
+ client.setHWAddress("aa:bb:cc:dd:ee:ff");
+ // Request domain-name-servers.
+ client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
+
+ // Create server configuration.
+ configure(config, *client.getServer());
+
+ // Perform a DORA.
+ doDORA(client, "192.0.2.28", "192.0.2.28");
+
+ // Check response.
+ Pkt4Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+ EXPECT_EQ(DHCPACK, resp->getType());
+ EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
+
+ // Check domain-name-servers option.
+ OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
+ ASSERT_TRUE(opt);
+ Option4AddrLstPtr servers =
+ boost::dynamic_pointer_cast<Option4AddrLst>(opt);
+ ASSERT_TRUE(servers);
+ auto addrs = servers->getAddresses();
+ ASSERT_EQ(1, addrs.size());
+ EXPECT_EQ(ns_address, addrs[0].toText());
+ }
+
/// @brief Destructor.
virtual ~Dhcpv4SharedNetworkTest() {
StatsMgr::instance().removeAll();
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("192.0.2.1", addrs[0].toText());
+ testPrecedence(config, "192.0.2.1");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("192.0.2.2", addrs[0].toText());
+ testPrecedence(config, "192.0.2.2");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
// Class order is the insert order
- EXPECT_EQ("192.0.2.2", addrs[0].toText());
+ testPrecedence(config, "192.0.2.2");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("192.0.2.3", addrs[0].toText());
+ testPrecedence(config, "192.0.2.3");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("192.0.2.4", addrs[0].toText());
+ testPrecedence(config, "192.0.2.4");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("192.0.2.5", addrs[0].toText());
+ testPrecedence(config, "192.0.2.5");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set MAC address to the one that has a reservation.
- Dhcp4Client client(Dhcp4Client::SELECTING);
- client.setIfaceName("eth1");
- client.setHWAddress("aa:bb:cc:dd:ee:ff");
- // Request domain-name-servers
- client.requestOptions(DHO_DOMAIN_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform a DORA
- doDORA(client, "192.0.2.28", "192.0.2.28");
-
- // Check response
- Pkt4Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
- EXPECT_EQ(DHCPACK, resp->getType());
- EXPECT_EQ("192.0.2.28", resp->getYiaddr().toText());
-
- // Check domain-name-servers option
- OptionPtr opt = resp->getOption(DHO_DOMAIN_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option4AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option4AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("192.0.2.6", addrs[0].toText());
+ testPrecedence(config, "192.0.2.6");
}
} // end of anonymous namespace
"\"subnet6\": [ "
"{ \"subnet\": \"2001:db8::/32\", "
" \"interface\": \"eth1\","
- " \"pools\": [ "
- " { \"pool\": \"2001:db8:1::/48\","
+ " \"pd-pools\": [ "
+ " { \"prefix\": \"2001:db8:1::\","
+ " \"prefix-len\": 48, \"delegated-len\": 64,"
" \"client-class\": \"server1_and_telephones\" },"
- " { \"pool\": \"2001:db8:2::/48\","
+ " { \"prefix\": \"2001:db8:2::\","
+ " \"prefix-len\": 48, \"delegated-len\": 64,"
" \"client-class\": \"server1_and_computers\" },"
- " { \"pool\": \"2001:db8:3::/48\","
+ " { \"prefix\": \"2001:db8:3::\","
+ " \"prefix-len\": 48, \"delegated-len\": 64,"
" \"client-class\": \"server2_and_telephones\" },"
- " { \"pool\": \"2001:db8:4::/48\","
+ " { \"prefix\": \"2001:db8:4::\","
+ " \"prefix-len\": 48, \"delegated-len\": 64,"
" \"client-class\": \"server2_and_computers\" } ]"
" } ],"
"\"valid-lifetime\": 4000 }"
EXPECT_EQ("2001:db8:1:1::", lease_client.addr_.toText());
}
+// This test checks the complex membership from HA with server1 computer.
+TEST_F(ClassifyTest, server1Computer) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestAddress(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "bar"));
+ client.addExtraOption(hostname);
+
+ // Add server1
+ client.addClass("server1");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[1], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The address is from the second pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:1:2::", lease_client.addr_.toText());
+}
+
+// This test checks the complex membership from HA with server2 telephone.
+TEST_F(ClassifyTest, server2Telephone) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestAddress(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "foo"));
+ client.addExtraOption(hostname);
+
+ // Add server2
+ client.addClass("server2");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[1], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The address is from the third pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:1:3::", lease_client.addr_.toText());
+}
+
+// This test checks the complex membership from HA with server2 computer.
+TEST_F(ClassifyTest, server2Computer) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestAddress(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "bar"));
+ client.addExtraOption(hostname);
+
+ // Add server2
+ client.addClass("server2");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[1], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The address is from the forth pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:1:4::", lease_client.addr_.toText());
+}
+
+// This test checks the complex membership from HA with server1 telephone
+// with prefixes.
+TEST_F(ClassifyTest, pDserver1Telephone) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestPrefix(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "foo"));
+ client.addExtraOption(hostname);
+
+ // Add server1
+ client.addClass("server1");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[2], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The prefix is from the first pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:1::", lease_client.addr_.toText());
+}
+
+// This test checks the complex membership from HA with server1 computer
+// with prefix.
+TEST_F(ClassifyTest, pDserver1Computer) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestPrefix(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "bar"));
+ client.addExtraOption(hostname);
+
+ // Add server1
+ client.addClass("server1");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[2], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The prefix is from the second pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:2::", lease_client.addr_.toText());
+}
+
+// This test checks the complex membership from HA with server2 telephone
+// with prefixes.
+TEST_F(ClassifyTest, pDserver2Telephone) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestPrefix(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "foo"));
+ client.addExtraOption(hostname);
+
+ // Add server2
+ client.addClass("server2");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[2], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The prefix is from the third pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:3::", lease_client.addr_.toText());
+}
+
+// This test checks the complex membership from HA with server2 computer
+// with prefix.
+TEST_F(ClassifyTest, pDserver2Computer) {
+ // Create a client.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ ASSERT_NO_THROW(client.requestPrefix(0xabca0));
+
+ // Add option.
+ OptionStringPtr hostname(new OptionString(Option::V6, 1234, "bar"));
+ client.addExtraOption(hostname);
+
+ // Add server2
+ client.addClass("server2");
+
+ // Load the config and perform a SARR
+ configure(CONFIGS[2], *client.getServer());
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // The prefix is from the forth pool.
+ ASSERT_EQ(1, client.getLeaseNum());
+ Lease6 lease_client = client.getLease(0);
+ EXPECT_EQ("2001:db8:4::", lease_client.addr_.toText());
+}
+
} // end of anonymous namespace
-// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
}
}
+ /// @brief Check precedence.
+ ///
+ /// @param config the configuration.
+ /// @param ns_address expected name server address.
+ void testPrecedence(const std::string& config, const std::string& ns_address) {
+ // Create client and set DUID to the one that has a reservation.
+ Dhcp6Client client;
+ client.setInterface("eth1");
+ client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
+ client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
+ // Request dns-servers.
+ client.requestOption(D6O_NAME_SERVERS);
+
+ // Create server configuration.
+ configure(config, *client.getServer());
+
+ // Perform SARR.
+ ASSERT_NO_THROW(client.doSARR());
+
+ // Check response.
+ EXPECT_EQ(1, client.getLeaseNum());
+ Pkt6Ptr resp = client.getContext().response_;
+ ASSERT_TRUE(resp);
+
+ // Check dns-servers option.
+ OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
+ ASSERT_TRUE(opt);
+ Option6AddrLstPtr servers =
+ boost::dynamic_pointer_cast<Option6AddrLst>(opt);
+ ASSERT_TRUE(servers);
+ auto addrs = servers->getAddresses();
+ ASSERT_EQ(1, addrs.size());
+ EXPECT_EQ(ns_address, addrs[0].toText());
+ }
+
/// @brief Destructor.
virtual ~Dhcpv6SharedNetworkTest() {
StatsMgr::instance().removeAll();
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("2001:db8:1::1", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::1");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("2001:db8:1::2", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::2");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
// Class order is the insert order
- EXPECT_EQ("2001:db8:1::2", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::2");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("2001:db8:1::3", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::3");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("2001:db8:1::4", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::4");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("2001:db8:1::5", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::5");
}
// Verify option processing precedence
" ]"
"}";
- // Create client and set DUID to the one that has a reservation.
- Dhcp6Client client;
- client.setInterface("eth1");
- client.setDUID("00:03:00:01:aa:bb:cc:dd:ee:ff");
- client.requestAddress(0xabca, IOAddress("2001:db8:1::28"));
- // Request dns-servers
- client.requestOption(D6O_NAME_SERVERS);
-
- // Create server configuration
- configure(config, *client.getServer());
-
- // Perform SARR
- ASSERT_NO_THROW(client.doSARR());
-
- // Check response
- EXPECT_EQ(1, client.getLeaseNum());
- Pkt6Ptr resp = client.getContext().response_;
- ASSERT_TRUE(resp);
-
- // Check dns-servers option
- OptionPtr opt = resp->getOption(D6O_NAME_SERVERS);
- ASSERT_TRUE(opt);
- Option6AddrLstPtr servers =
- boost::dynamic_pointer_cast<Option6AddrLst>(opt);
- ASSERT_TRUE(servers);
- auto addrs = servers->getAddresses();
- ASSERT_EQ(1, addrs.size());
- EXPECT_EQ("2001:db8:1::6", addrs[0].toText());
+ testPrecedence(config, "2001:db8:1::6");
}
} // end of anonymous namespace
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
EXPECT_EQ("three", cclass->getName());
}
+// Verifies that not defined dependencies will not parse.
+TEST_F(ClientClassDefListParserTest, dependentNotDefined) {
+ std::string cfg_text =
+ "[ \n"
+ " { \n"
+ " \"name\": \"one\", \n"
+ " \"test\": \"member('foo')\" \n"
+ " } \n"
+ "] \n";
+
+ EXPECT_THROW(parseClientClassDefList(cfg_text, AF_INET6), DhcpConfigError);
+}
+
// Verifies that forward dependencies will not parse.
TEST_F(ClientClassDefListParserTest, dependentForwardError) {
std::string cfg_text =
" { \n"
" \"name\": \"one\", \n"
" \"test\": \"member('foo')\" \n"
+ " }, \n"
+ " { \n"
+ " \"name\": \"foo\" \n"
" } \n"
"] \n";
EXPECT_THROW(parseClientClassDefList(cfg_text, AF_INET6), DhcpConfigError);
}
+// Verifies that backward dependencies will parse.
+TEST_F(ClientClassDefListParserTest, dependentBackward) {
+ std::string cfg_text =
+ "[ \n"
+ " { \n"
+ " \"name\": \"foo\" \n"
+ " }, \n"
+ " { \n"
+ " \"name\": \"one\", \n"
+ " \"test\": \"member('foo')\" \n"
+ " } \n"
+ "] \n";
+
+ EXPECT_NO_THROW(parseClientClassDefList(cfg_text, AF_INET6));
+}
+
} // end of anonymous namespace