From: Marcin Siodelski Date: Tue, 4 Dec 2018 09:55:46 +0000 (+0100) Subject: [#86,!152] Modified v6 FQDN option unit tests for case insensitive compare. X-Git-Tag: 174-warning-for-unused-trace-levels_base~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33b569193cd6793b6feb7314644f2c669ab091f3;p=thirdparty%2Fkea.git [#86,!152] Modified v6 FQDN option unit tests for case insensitive compare. --- diff --git a/src/lib/dhcp/option6_client_fqdn.h b/src/lib/dhcp/option6_client_fqdn.h index 58adfbd52e..2ddcfb731c 100644 --- a/src/lib/dhcp/option6_client_fqdn.h +++ b/src/lib/dhcp/option6_client_fqdn.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-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 @@ -70,6 +70,10 @@ class Option6ClientFqdnImpl; /// domain-names to indicate that server should generate complete fully /// qualified domain-name. /// +/// Since domain names are case insensitive (see RFC 4343), this class +/// converts them to lower case format regardless if they are received over +/// the wire or created from strings. +/// /// Design choice: This class uses pimpl idiom to separate the interface /// from implementation specifics. Implementations may use different approaches /// to handle domain names (mostly validation of the domain-names). The existing diff --git a/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc b/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc index 2d1bad878b..c2934899cc 100644 --- a/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc +++ b/src/lib/dhcp/tests/option6_client_fqdn_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-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 @@ -146,9 +146,9 @@ TEST(Option6ClientFqdnTest, copyConstructEmptyDomainName) { TEST(Option6ClientFqdnTest, constructFromWire) { const uint8_t in_data[] = { Option6ClientFqdn::FLAG_S, // flags - 6, 109, 121, 104, 111, 115, 116, // myhost. - 7, 101, 120, 97, 109, 112, 108, 101, // example. - 3, 99, 111, 109, 0 // com. + 6, 77, 121, 104, 111, 115, 116, // Myhost. + 7, 69, 120, 97, 109, 112, 108, 101, // Example. + 3, 67, 111, 109, 0 // Com. }; size_t in_data_size = sizeof(in_data) / sizeof(in_data[0]); OptionBuffer in_buf(in_data, in_data + in_data_size); @@ -210,7 +210,7 @@ TEST(Option6ClientFqdnTest, constructFromWireTruncated) { TEST(Option6ClientFqdnTest, constructFromWirePartial) { const uint8_t in_data[] = { Option6ClientFqdn::FLAG_N, // flags - 6, 109, 121, 104, 111, 115, 116 // myhost + 6, 77, 121, 104, 111, 115, 116 // Myhost }; size_t in_data_size = sizeof(in_data) / sizeof(in_data[0]); OptionBuffer in_buf(in_data, in_data + in_data_size); @@ -274,7 +274,7 @@ TEST(Option6ClientFqdnTest, assignment) { // Create first option. Option6ClientFqdn option(Option6ClientFqdn::FLAG_S, - "myhost.example.com", + "Myhost.Example.Com", Option6ClientFqdn::FULL); // Verify that the values have been set correctly. @@ -514,13 +514,13 @@ TEST(Option6ClientFqdnTest, setDomainName) { ASSERT_EQ(Option6ClientFqdn::FULL, option->getDomainNameType()); // Partial domain-name. - ASSERT_NO_THROW(option->setDomainName("myhost", + ASSERT_NO_THROW(option->setDomainName("Myhost", Option6ClientFqdn::PARTIAL)); EXPECT_EQ("myhost", option->getDomainName()); EXPECT_EQ(Option6ClientFqdn::PARTIAL, option->getDomainNameType()); // Fully qualified domain-name. - ASSERT_NO_THROW(option->setDomainName("example.com", + ASSERT_NO_THROW(option->setDomainName("Example.com", Option6ClientFqdn::FULL)); EXPECT_EQ("example.com.", option->getDomainName()); EXPECT_EQ(Option6ClientFqdn::FULL, option->getDomainNameType()); @@ -664,8 +664,8 @@ TEST(Option6ClientFqdnTest, unpack) { const uint8_t in_data[] = { Option6ClientFqdn::FLAG_S, // flags - 6, 109, 121, 104, 111, 115, 116, // myhost. - 7, 101, 120, 97, 109, 112, 108, 101, // example. + 6, 77, 121, 104, 111, 115, 116, // Myhost. + 7, 69, 120, 97, 109, 112, 108, 101, // Example. 3, 99, 111, 109, 0 // com. }; size_t in_data_size = sizeof(in_data) / sizeof(in_data[0]); @@ -703,7 +703,7 @@ TEST(Option6ClientFqdnTest, unpackPartial) { const uint8_t in_data[] = { Option6ClientFqdn::FLAG_S, // flags - 6, 109, 121, 104, 111, 115, 116 // myhost + 6, 77, 121, 104, 111, 115, 116 // Myhost }; size_t in_data_size = sizeof(in_data) / sizeof(in_data[0]); OptionBuffer in_buf(in_data, in_data + in_data_size);