Browse Source

[3282] Fixed setDomainName methods

Modified the setDomainName() method in both Option4ClientFqdn
and Option6ClientFqdn to always the domain name type based
on the type parameter passed in.
Thomas Markwalder 11 years ago
parent
commit
1422c7b03b

+ 3 - 2
src/lib/dhcp/option4_client_fqdn.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -217,7 +217,6 @@ setDomainName(const std::string& domain_name,
     } else {
         try {
             domain_name_.reset(new isc::dns::Name(name));
-            domain_name_type_ = name_type;
 
         } catch (const Exception& ex) {
             isc_throw(InvalidOption4FqdnDomainName,
@@ -227,6 +226,8 @@ setDomainName(const std::string& domain_name,
 
         }
     }
+
+    domain_name_type_ = name_type;
 }
 
 void

+ 3 - 2
src/lib/dhcp/option6_client_fqdn.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -188,7 +188,6 @@ setDomainName(const std::string& domain_name,
     } else {
         try {
             domain_name_.reset(new isc::dns::Name(name, true));
-            domain_name_type_ = name_type;
 
         } catch (const Exception& ex) {
             isc_throw(InvalidOption6FqdnDomainName, "invalid domain-name value '"
@@ -197,6 +196,8 @@ setDomainName(const std::string& domain_name,
 
         }
     }
+
+    domain_name_type_ = name_type;
 }
 
 void

+ 2 - 1
src/lib/dhcp/tests/option4_client_fqdn_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -615,6 +615,7 @@ TEST(Option4ClientFqdnTest, setDomainName) {
     // Empty domain name (partial). This should be successful.
     ASSERT_NO_THROW(option->setDomainName("", Option4ClientFqdn::PARTIAL));
     EXPECT_TRUE(option->getDomainName().empty());
+    EXPECT_EQ(Option4ClientFqdn::PARTIAL, option->getDomainNameType());
 
     // Fully qualified domain-names must not be empty.
     EXPECT_THROW(option->setDomainName("", Option4ClientFqdn::FULL),

+ 2 - 1
src/lib/dhcp/tests/option6_client_fqdn_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -537,6 +537,7 @@ TEST(Option6ClientFqdnTest, setDomainName) {
     // Empty domain name (partial). This should be successful.
     ASSERT_NO_THROW(option->setDomainName("", Option6ClientFqdn::PARTIAL));
     EXPECT_TRUE(option->getDomainName().empty());
+    EXPECT_EQ(Option6ClientFqdn::PARTIAL, option->getDomainNameType());
 
     // Fully qualified domain-names must not be empty.
     EXPECT_THROW(option->setDomainName("", Option6ClientFqdn::FULL),