2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#2536] Updating Changelog and docs

This commit is contained in:
Piotrek Zadroga
2023-04-20 15:59:11 +02:00
parent 5f3e779760
commit 77e7200d4a
6 changed files with 66 additions and 58 deletions

View File

@@ -1,3 +1,10 @@
2130. [func] piotrek
Added support of DHCP Options for the Discovery of
Network-designated Resolvers (DNR) as per draft-ietf-add-dnr.
Kea can now handle DHCPv4 Option code #162 and DHCPv6 Option
code #144.
(Gitlab #2536)
2129. [func] andrei 2129. [func] andrei
New statistics were added to keep track of leases that have their New statistics were added to keep track of leases that have their
CLTT increased in memory and their expiration time left unchanged CLTT increased in memory and their expiration time left unchanged

View File

@@ -1986,6 +1986,8 @@ types are given in :ref:`dhcp-types`.
+----------------------------------------+------+---------------------------+-------------+-------------+ +----------------------------------------+------+---------------------------+-------------+-------------+
| v4-portparams | 159 | record (uint8, psid) | false | false | | v4-portparams | 159 | record (uint8, psid) | false | false |
+----------------------------------------+------+---------------------------+-------------+-------------+ +----------------------------------------+------+---------------------------+-------------+-------------+
| v4-dnr | 162 | binary | false | false |
+----------------------------------------+------+---------------------------+-------------+-------------+
| option-6rd | 212 | record (uint8, uint8, | true | false | | option-6rd | 212 | record (uint8, uint8, | true | false |
| | | ipv6-address, | | | | | | ipv6-address, | | |
| | | ipv4-address) | | | | | | ipv4-address) | | |

View File

@@ -1768,6 +1768,9 @@ types are given in :ref:`dhcp-types`.
+--------------------------+-----------------+-----------------+-----------------+ +--------------------------+-----------------+-----------------+-----------------+
| ipv6-address-andsf | 143 | ipv6-address | true | | ipv6-address-andsf | 143 | ipv6-address | true |
+--------------------------+-----------------+-----------------+-----------------+ +--------------------------+-----------------+-----------------+-----------------+
| v6-dnr | 144 | record (uint16, | false |
| | | uint16, binary) | |
+--------------------------+-----------------+-----------------+-----------------+
Options marked with (1) have option definitions, but the logic behind Options marked with (1) have option definitions, but the logic behind
them is not implemented. That means that, technically, Kea knows how to them is not implemented. That means that, technically, Kea knows how to

View File

@@ -134,7 +134,7 @@ DnrInstance::DnrInstance(Option::Universe universe,
} }
void void
DnrInstance::packAdn(util::OutputBuffer& buf) const { DnrInstance::packAdn(OutputBuffer& buf) const {
if (!adn_) { if (!adn_) {
// This should not happen since Encrypted DNS options are designed // This should not happen since Encrypted DNS options are designed
// to always include an authentication domain name. // to always include an authentication domain name.
@@ -150,7 +150,7 @@ DnrInstance::packAdn(util::OutputBuffer& buf) const {
} }
void void
DnrInstance::packAddresses(util::OutputBuffer& buf) const { DnrInstance::packAddresses(OutputBuffer& buf) const {
AddressContainer::const_iterator address = ip_addresses_.begin(); AddressContainer::const_iterator address = ip_addresses_.begin();
while (address != ip_addresses_.end()) { while (address != ip_addresses_.end()) {
buf.writeUint32(address->toUint32()); buf.writeUint32(address->toUint32());
@@ -159,7 +159,7 @@ DnrInstance::packAddresses(util::OutputBuffer& buf) const {
} }
void void
DnrInstance::packSvcParams(util::OutputBuffer& buf) const { DnrInstance::packSvcParams(OutputBuffer& buf) const {
if (svc_params_length_ > 0) { if (svc_params_length_ > 0) {
buf.writeData(&(*svc_params_.begin()), svc_params_length_); buf.writeData(&(*svc_params_.begin()), svc_params_length_);
} }
@@ -175,7 +175,7 @@ DnrInstance::getAdnAsText() const {
void void
DnrInstance::setAdn(const std::string& adn) { DnrInstance::setAdn(const std::string& adn) {
std::string trimmed_adn = isc::util::str::trim(adn); std::string trimmed_adn = str::trim(adn);
if (trimmed_adn.empty()) { if (trimmed_adn.empty()) {
isc_throw(InvalidOptionDnrDomainName, "Mandatory Authentication Domain Name fully " isc_throw(InvalidOptionDnrDomainName, "Mandatory Authentication Domain Name fully "
"qualified domain-name must not be empty"); "qualified domain-name must not be empty");
@@ -226,7 +226,7 @@ DnrInstance::unpackAdn(OptionBufferConstIter& begin, OptionBufferConstIter end)
void void
DnrInstance::checkSvcParams(bool from_wire_data) { DnrInstance::checkSvcParams(bool from_wire_data) {
std::string svc_params = isc::util::str::trim(svc_params_); std::string svc_params = str::trim(svc_params_);
if (svc_params.empty()) { if (svc_params.empty()) {
isc_throw(InvalidOptionDnrSvcParams, "Provided Svc Params field is empty"); isc_throw(InvalidOptionDnrSvcParams, "Provided Svc Params field is empty");
} }
@@ -249,16 +249,16 @@ DnrInstance::checkSvcParams(bool from_wire_data) {
// SvcParams in presentation format MAY appear in any order, but keys MUST NOT be repeated. // SvcParams in presentation format MAY appear in any order, but keys MUST NOT be repeated.
// Let's put all elements of a whitespace-separated list into a vector. // Let's put all elements of a whitespace-separated list into a vector.
std::vector<std::string> tokens = isc::util::str::tokens(svc_params, " "); std::vector<std::string> tokens = str::tokens(svc_params, " ");
// Set of keys used to check if a key is not repeated. // Set of keys used to check if a key is not repeated.
std::set<std::string> keys; std::set<std::string> keys;
// String sanitizer is used to check keys syntax. // String sanitizer is used to check keys syntax.
util::str::StringSanitizerPtr sanitizer; str::StringSanitizerPtr sanitizer;
// SvcParamKeys are lower-case alphanumeric strings. Key names // SvcParamKeys are lower-case alphanumeric strings. Key names
// contain 1-63 characters from the ranges "a"-"z", "0"-"9", and "-". // contain 1-63 characters from the ranges "a"-"z", "0"-"9", and "-".
std::string regex = "[^a-z0-9-]"; std::string regex = "[^a-z0-9-]";
sanitizer.reset(new util::str::StringSanitizer(regex, "")); sanitizer.reset(new str::StringSanitizer(regex, ""));
// The service parameters MUST NOT include // The service parameters MUST NOT include
// "ipv4hint" or "ipv6hint" SvcParams as they are superseded by the // "ipv4hint" or "ipv6hint" SvcParams as they are superseded by the
// included IP addresses. // included IP addresses.
@@ -266,7 +266,7 @@ DnrInstance::checkSvcParams(bool from_wire_data) {
// Now let's check each SvcParamKey=SvcParamValue pair. // Now let's check each SvcParamKey=SvcParamValue pair.
for (const std::string& token : tokens) { for (const std::string& token : tokens) {
std::vector<std::string> key_val = isc::util::str::tokens(token, "="); std::vector<std::string> key_val = str::tokens(token, "=");
if (key_val.size() > 2) { if (key_val.size() > 2) {
isc_throw(InvalidOptionDnrSvcParams, "Wrong Svc Params syntax - more than one " isc_throw(InvalidOptionDnrSvcParams, "Wrong Svc Params syntax - more than one "
"equals sign found in SvcParamKey=SvcParamValue " "equals sign found in SvcParamKey=SvcParamValue "

View File

@@ -8,20 +8,18 @@
#include <dhcp/option4_dnr.h> #include <dhcp/option4_dnr.h>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>
using namespace isc; using namespace isc;
using namespace isc::dhcp; using namespace isc::dhcp;
using namespace isc::asiolink; using namespace isc::asiolink;
using boost::scoped_ptr;
namespace { namespace {
// This test verifies constructor of the empty Option4Dnr class. // This test verifies constructor of the empty Option4Dnr class.
TEST(Option4DnrTest, emptyCtor) { TEST(Option4DnrTest, emptyCtor) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -34,7 +32,7 @@ TEST(Option4DnrTest, emptyCtor) {
// with adding ADN-only-mode DNR instance to option's DNR instances. // with adding ADN-only-mode DNR instance to option's DNR instances.
TEST(Option4DnrTest, oneAdnOnlyModeInstance) { TEST(Option4DnrTest, oneAdnOnlyModeInstance) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -73,7 +71,7 @@ TEST(Option4DnrTest, oneAdnOnlyModeInstance) {
// with adding multiple ADN-only-mode DNR instances to option's DNR instances. // with adding multiple ADN-only-mode DNR instances to option's DNR instances.
TEST(Option4DnrTest, multipleAdnOnlyModeInstances) { TEST(Option4DnrTest, multipleAdnOnlyModeInstances) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -136,7 +134,7 @@ TEST(Option4DnrTest, multipleAdnOnlyModeInstances) {
// 2. All fields included (IP addresses and service params also) DNR instance. // 2. All fields included (IP addresses and service params also) DNR instance.
TEST(Option4DnrTest, mixedDnrInstances) { TEST(Option4DnrTest, mixedDnrInstances) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -196,7 +194,7 @@ TEST(Option4DnrTest, mixedDnrInstances) {
// 1. ADN only mode // 1. ADN only mode
TEST(Option4DnrTest, packOneAdnOnlyModeInstance) { TEST(Option4DnrTest, packOneAdnOnlyModeInstance) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -237,7 +235,7 @@ TEST(Option4DnrTest, packOneAdnOnlyModeInstance) {
// 3. ADN only mode // 3. ADN only mode
TEST(Option4DnrTest, packMultipleAdnOnlyModeInstances) { TEST(Option4DnrTest, packMultipleAdnOnlyModeInstances) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -297,7 +295,7 @@ TEST(Option4DnrTest, packMultipleAdnOnlyModeInstances) {
// 2. All fields included (IP addresses and service params also). // 2. All fields included (IP addresses and service params also).
TEST(Option4DnrTest, packMixedDnrInstances) { TEST(Option4DnrTest, packMixedDnrInstances) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -364,7 +362,7 @@ TEST(Option4DnrTest, onWireDataCtor) {
}; };
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
} }
@@ -385,7 +383,7 @@ TEST(Option4DnrTest, unpackOneAdnOnly) {
}; };
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -441,7 +439,7 @@ TEST(Option4DnrTest, unpackOneDnrInstance) {
}; };
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -494,7 +492,7 @@ TEST(Option4DnrTest, unpackMixedDnrInstances) {
}; };
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -542,7 +540,7 @@ TEST(Option4DnrTest, unpackTruncatedDnrInstanceDataLen) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -566,7 +564,7 @@ TEST(Option4DnrTest, unpackTruncatedDnrInstanceData) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -590,7 +588,7 @@ TEST(Option4DnrTest, unpackTruncatedAdn) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OpaqueDataTupleError); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OpaqueDataTupleError);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -614,7 +612,7 @@ TEST(Option4DnrTest, unpackInvalidFqdnAdn) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -637,7 +635,7 @@ TEST(Option4DnrTest, unpackNoFqdnAdn) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -665,7 +663,7 @@ TEST(Option4DnrTest, unpackTruncatedIpAddress) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OpaqueDataTupleError); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OpaqueDataTupleError);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -692,7 +690,7 @@ TEST(Option4DnrTest, unpackNoIpAddress) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -721,7 +719,7 @@ TEST(Option4DnrTest, unpackIpAddressNon4Modulo) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -751,7 +749,7 @@ TEST(Option4DnrTest, unpackvcParamsInvalidCharKey) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws an exception while doing unpack. // Create option instance. Check that constructor throws an exception while doing unpack.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), InvalidOptionDnrSvcParams); EXPECT_THROW(option.reset(new Option4Dnr(buf.begin(), buf.end())), InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -760,7 +758,7 @@ TEST(Option4DnrTest, unpackvcParamsInvalidCharKey) {
// toText method is correctly formatted. // toText method is correctly formatted.
TEST(Option4DnrTest, toText) { TEST(Option4DnrTest, toText) {
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option4Dnr> option; Option4DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option4Dnr())); EXPECT_NO_THROW(option.reset(new Option4Dnr()));
ASSERT_TRUE(option); ASSERT_TRUE(option);

View File

@@ -8,12 +8,10 @@
#include <dhcp/option6_dnr.h> #include <dhcp/option6_dnr.h>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>
using namespace isc; using namespace isc;
using namespace isc::dhcp; using namespace isc::dhcp;
using boost::scoped_ptr;
namespace { namespace {
@@ -33,7 +31,7 @@ TEST(Option6DnrTest, onWireCtorAdnOnlyMode) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -73,7 +71,7 @@ TEST(Option6DnrTest, onWireCtorDataTruncated) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws OutOfRange exception. // Create option instance. Check that constructor throws OutOfRange exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -90,7 +88,7 @@ TEST(Option6DnrTest, onWireCtorOnlyWhitespaceFqdn) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws InvalidOptionDnrDomainName exception. // Create option instance. Check that constructor throws InvalidOptionDnrDomainName exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -108,7 +106,7 @@ TEST(Option6DnrTest, onWireCtorNoAdnFqdn) {
// Create option instance. Encrypted DNS options are designed to ALWAYS include // Create option instance. Encrypted DNS options are designed to ALWAYS include
// an authentication domain name, so check that constructor throws // an authentication domain name, so check that constructor throws
// InvalidOptionDnrDomainName exception. // InvalidOptionDnrDomainName exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), InvalidOptionDnrDomainName);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -125,7 +123,7 @@ TEST(Option6DnrTest, onWireCtorTruncatedFqdn) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws OpaqueDataTupleError exception. // Create option instance. Check that constructor throws OpaqueDataTupleError exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OpaqueDataTupleError); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OpaqueDataTupleError);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -145,7 +143,7 @@ TEST(Option6DnrTest, onWireCtorAddrLenTruncated) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws OutOfRange exception. // Create option instance. Check that constructor throws OutOfRange exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -167,7 +165,7 @@ TEST(Option6DnrTest, onWireCtorAddrLenZero) {
// Create option instance. Check that constructor throws OutOfRange exception. // Create option instance. Check that constructor throws OutOfRange exception.
// If additional data is supplied (i.e. not ADN only mode), // If additional data is supplied (i.e. not ADN only mode),
// the option includes at least one valid IP address. // the option includes at least one valid IP address.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -187,7 +185,7 @@ TEST(Option6DnrTest, onWireCtorAddrLenNot16Modulo) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws OutOfRange exception. // Create option instance. Check that constructor throws OutOfRange exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -213,7 +211,7 @@ TEST(Option6DnrTest, onWireCtorValidIpV6Addresses) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -268,7 +266,7 @@ TEST(Option6DnrTest, onWireCtorTruncatedIpV6Addresses) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws OutOfRange exception. // Create option instance. Check that constructor throws OutOfRange exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -291,7 +289,7 @@ TEST(Option6DnrTest, onWireCtorSvcParamsIncluded) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end()))); EXPECT_NO_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -344,7 +342,7 @@ TEST(Option6DnrTest, onWireCtorSvcParamsInvalidCharKey) {
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data)); OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
// Create option instance. Check that constructor throws InvalidOptionDnrSvcParams exception. // Create option instance. Check that constructor throws InvalidOptionDnrSvcParams exception.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), InvalidOptionDnrSvcParams); EXPECT_THROW(option.reset(new Option6Dnr(buf.begin(), buf.end())), InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -357,7 +355,7 @@ TEST(Option6DnrTest, adnOnlyModeCtor) {
const std::string adn = "myhost.example.com."; const std::string adn = "myhost.example.com.";
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn))); EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn)));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -393,7 +391,7 @@ TEST(Option6DnrTest, adnOnlyModeCtorNoFqdn) {
const std::string adn; // invalid empty ADN const std::string adn; // invalid empty ADN
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn)), InvalidOptionDnrDomainName); EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn)), InvalidOptionDnrDomainName);
ASSERT_FALSE(option); ASSERT_FALSE(option);
} }
@@ -410,7 +408,7 @@ TEST(Option6DnrTest, allFieldsCtor) {
const std::string svc_params = "alpn"; const std::string svc_params = "alpn";
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params))); EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -449,7 +447,7 @@ TEST(Option6DnrTest, allFieldsCtorNoIpAddress) {
const std::string svc_params = "alpn"; const std::string svc_params = "alpn";
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)), EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)),
OutOfRange); OutOfRange);
ASSERT_FALSE(option); ASSERT_FALSE(option);
@@ -467,7 +465,7 @@ TEST(Option6DnrTest, svcParamsTwoEqualSignsPerParam) {
const std::string svc_params = "key123=val1=val2 key234"; // invalid svc param - 2 equal signs const std::string svc_params = "key123=val1=val2 key234"; // invalid svc param - 2 equal signs
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)), EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)),
InvalidOptionDnrSvcParams); InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
@@ -485,7 +483,7 @@ TEST(Option6DnrTest, svcParamsForbiddenKey) {
const std::string svc_params = "key123=val1 ipv6hint"; // forbidden svc param key - ipv6hint const std::string svc_params = "key123=val1 ipv6hint"; // forbidden svc param key - ipv6hint
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)), EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)),
InvalidOptionDnrSvcParams); InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
@@ -503,7 +501,7 @@ TEST(Option6DnrTest, svcParamsKeyRepeated) {
const std::string svc_params = "key123=val1 key234 key123"; // svc param key key123 repeated const std::string svc_params = "key123=val1 key234 key123"; // svc param key key123 repeated
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)), EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)),
InvalidOptionDnrSvcParams); InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
@@ -523,7 +521,7 @@ TEST(Option6DnrTest, svcParamsKeyTooLong) {
"veryveryveryveryvlongkey"; // svc param key longer than 63 "veryveryveryveryvlongkey"; // svc param key longer than 63
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)), EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)),
InvalidOptionDnrSvcParams); InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
@@ -541,7 +539,7 @@ TEST(Option6DnrTest, svcParamsKeyHasInvalidChar) {
const std::string svc_params = "alpn=h2 NOT_ALLOWED_CHARS_KEY=123"; // svc param key has forbidden chars const std::string svc_params = "alpn=h2 NOT_ALLOWED_CHARS_KEY=123"; // svc param key has forbidden chars
// Create option instance. Check that constructor throws. // Create option instance. Check that constructor throws.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)), EXPECT_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)),
InvalidOptionDnrSvcParams); InvalidOptionDnrSvcParams);
ASSERT_FALSE(option); ASSERT_FALSE(option);
@@ -558,7 +556,7 @@ TEST(Option6DnrTest, toText) {
const std::string svc_params = "alpn"; const std::string svc_params = "alpn";
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params))); EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -577,7 +575,7 @@ TEST(Option6DnrTest, packAdnOnlyMode) {
const std::string adn = "myhost.example.com."; const std::string adn = "myhost.example.com.";
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn))); EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn)));
ASSERT_TRUE(option); ASSERT_TRUE(option);
@@ -616,7 +614,7 @@ TEST(Option6DnrTest, pack) {
const std::string svc_params = "alpn"; const std::string svc_params = "alpn";
// Create option instance. Check that constructor doesn't throw. // Create option instance. Check that constructor doesn't throw.
scoped_ptr<Option6Dnr> option; Option6DnrPtr option;
EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params))); EXPECT_NO_THROW(option.reset(new Option6Dnr(service_priority, adn, addresses, svc_params)));
ASSERT_TRUE(option); ASSERT_TRUE(option);