Removed configuration parameter allow-client-update.
It was deemed to really just be the inverse of override-client-update.
Renamed convenience method isDhcpDdns to ddnsEnabled.
Made enum to string converion functions case insenstive.
Updated copyright dates and other cosmetic changes.
"item_type": "map",
"item_optional": false,
"item_default": {"enable-updates": false},
+ "item_description" : "Contains parameters pertaining DHCP-driven DDNS updates",
"map_item_spec": [
{
"item_name": "enable-updates",
"item_type": "boolean",
"item_optional": false,
- "item_default": False,
+ "item_default": false,
"item_description" : "Enables DDNS update processing"
},
{
- "item_name": "server_ip",
+ "item_name": "server-ip",
"item_type": "string",
"item_optional": true,
"item_default": "127.0.0.1",
- "item_description" : "IP address of b10-dhcp-ddns"
+ "item_description" : "IP address of b10-dhcp-ddns (IPv4 or IPv6)"
},
{
- "item_name": "server_port",
+ "item_name": "server-port",
"item_type": "integer",
"item_optional": true,
- "item_default": 5301,
+ "item_default": 53001,
"item_description" : "port number of b10-dhcp-ddns"
},
{
- "item_name": "ncr_protocol",
+ "item_name": "ncr-protocol",
"item_type": "string",
"item_optional": true,
"item_default": "UDP",
"item_description" : "Socket protocol to use with b10-dhcp-ddns"
},
{
- "item_name": "ncr_format",
+ "item_name": "ncr-format",
"item_type": "string",
"item_optional": true,
"item_default": "JSON",
"item_type": "boolean",
"item_optional": true,
"item_default": false,
- "item_description": "Should server request a DNS Remove, before a DNS Update on renewals"
+ "item_description": "Enable requesting a DNS Remove, before a DNS Update on renewals"
},
{
"item_name": "always-include-fqdn",
"item_type": "boolean",
"item_optional": true,
- "item_default": False,
- "item_description": "Should server always include the FQDN option in its response"
- },
- {
-
- "item_name": "allow-client-update",
- "item_type": "boolean",
- "item_optional": true,
- "item_default": False,
- "item_description": "Enable AAAA RR update delegation to the client"
+ "item_default": false,
+ "item_description": "Enable always including the FQDN option in its response"
},
{
"item_name": "override-no-update",
"item_name": "override-client-update",
"item_type": "boolean",
"item_optional": true,
- "item_default": true,
+ "item_default": false,
"item_description": "Server performs an update even if client requested delegation"
},
{
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
/// Verifies that the BIND10 DHCP-DDNS configuration specification file
// is valid.
TEST(Dhcp4SpecTest, basicSpec) {
+ (isc::config::moduleSpecFromFile(specfile("dhcp4.spec")));
ASSERT_NO_THROW(isc::config::moduleSpecFromFile(specfile("dhcp4.spec")));
}
EXPECT_FALSE(d2_client_config->getEnableUpdates());
// Verify that the convenience method agrees.
- ASSERT_FALSE(CfgMgr::instance().isDhcpDdnsEnabled());
+ ASSERT_FALSE(CfgMgr::instance().ddnsEnabled());
string config_str = "{ \"interfaces\": [ \"*\" ],"
"\"rebind-timer\": 2000, "
" \"dhcp-ddns\" : {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 777, "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
checkResult(status, 0);
// Verify that DHCP-DDNS updating is enabled.
- EXPECT_TRUE(CfgMgr::instance().isDhcpDdnsEnabled());
+ EXPECT_TRUE(CfgMgr::instance().ddnsEnabled());
// Verify that the D2 configuration can be retrieved.
d2_client_config = CfgMgr::instance().getD2ClientConfig();
// Verify that the configuration values are correct.
EXPECT_TRUE(d2_client_config->getEnableUpdates());
EXPECT_EQ("192.168.2.1", d2_client_config->getServerIp().toText());
- EXPECT_EQ(5301, d2_client_config->getServerPort());
+ EXPECT_EQ(777, d2_client_config->getServerPort());
EXPECT_EQ(dhcp_ddns::NCR_UDP, d2_client_config->getNcrProtocol());
EXPECT_EQ(dhcp_ddns::FMT_JSON, d2_client_config->getNcrFormat());
EXPECT_TRUE(d2_client_config->getRemoveOnRenew());
EXPECT_TRUE(d2_client_config->getAlwaysIncludeFqdn());
- EXPECT_TRUE(d2_client_config->getAllowClientUpdate());
EXPECT_TRUE(d2_client_config->getOverrideNoUpdate());
EXPECT_TRUE(d2_client_config->getOverrideClientUpdate());
EXPECT_TRUE(d2_client_config->getReplaceClientName());
EXPECT_FALSE(d2_client_config->getEnableUpdates());
// Verify that the convenience method agrees.
- ASSERT_FALSE(CfgMgr::instance().isDhcpDdnsEnabled());
+ ASSERT_FALSE(CfgMgr::instance().ddnsEnabled());
}
}
#include <dhcp_ddns/dhcp_ddns_log.h>
#include <dhcp_ddns/ncr_io.h>
+#include <boost/algorithm/string/predicate.hpp>
+
namespace isc {
namespace dhcp_ddns {
NameChangeProtocol stringToNcrProtocol(const std::string& protocol_str) {
- if (protocol_str == "UDP") {
- return NCR_UDP;
- }
+ if (boost::iequals(protocol_str, "UDP")) {
+ return (NCR_UDP);
+ }
- if (protocol_str == "TCP") {
- return NCR_TCP;
+ if (boost::iequals(protocol_str, "TCP")) {
+ return (NCR_TCP);
}
isc_throw(BadValue, "Invalid NameChangeRequest protocol:" << protocol_str);
break;
}
- return ("UNKNOWN");
+ std::ostringstream stream;
+ stream << "UNKNOWN(" << protocol << ")";
+ return (stream.str());
}
namespace dhcp_ddns {
/// @brief Defines the list of socket protocols supported.
+/// Currently only UDP is implemented.
+/// @todo TCP is intended to be implemented prior 1.0 release.
+/// @todo Give some thought to an ANY protocol which might try
+/// first as UDP then as TCP, etc.
enum NameChangeProtocol {
NCR_UDP,
NCR_TCP
#include <asiolink/io_error.h>
#include <cryptolink/cryptolink.h>
+#include <boost/algorithm/string/predicate.hpp>
#include <botan/sha2_32.h>
#include <sstream>
#include <limits>
+
namespace isc {
namespace dhcp_ddns {
+
NameChangeFormat stringToNcrFormat(const std::string& fmt_str) {
- if (fmt_str == "JSON") {
+ if (boost::iequals(fmt_str, "JSON")) {
return FMT_JSON;
}
return ("JSON");
}
- return ("UNKNOWN");
+ std::ostringstream stream;
+ stream << "UNKNOWN(" << format << ")";
+ return (stream.str());
}
/********************************* D2Dhcid ************************************/
/// @brief Tests conversion of NameChangeFormat between enum and strings.
TEST(NameChangeFormatTest, formatEnumConversion){
ASSERT_EQ(stringToNcrFormat("JSON"), dhcp_ddns::FMT_JSON);
+ ASSERT_EQ(stringToNcrFormat("jSoN"), dhcp_ddns::FMT_JSON);
ASSERT_THROW(stringToNcrFormat("bogus"), isc::BadValue);
ASSERT_EQ(ncrFormatToString(dhcp_ddns::FMT_JSON), "JSON");
/// @brief Tests conversion of NameChangeProtocol between enum and strings.
TEST(NameChangeProtocolTest, protocolEnumConversion){
ASSERT_EQ(stringToNcrProtocol("UDP"), dhcp_ddns::NCR_UDP);
+ ASSERT_EQ(stringToNcrProtocol("udP"), dhcp_ddns::NCR_UDP);
ASSERT_EQ(stringToNcrProtocol("TCP"), dhcp_ddns::NCR_TCP);
+ ASSERT_EQ(stringToNcrProtocol("Tcp"), dhcp_ddns::NCR_TCP);
ASSERT_THROW(stringToNcrProtocol("bogus"), isc::BadValue);
ASSERT_EQ(ncrProtocolToString(dhcp_ddns::NCR_UDP), "UDP");
}
bool
-CfgMgr::isDhcpDdnsEnabled() {
- return (d2_client_mgr_.isDhcpDdnsEnabled());
+CfgMgr::ddnsEnabled() {
+ return (d2_client_mgr_.ddnsEnabled());
}
const D2ClientConfigPtr&
/// @param Convenience method for checking if DHCP-DDNS updates are enabled.
///
/// @return True if the D2 configuration is enabled.
- bool isDhcpDdnsEnabled();
+ bool ddnsEnabled();
/// @brief Fetches the DHCP-DDNS configuration pointer.
///
-// 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
NameChangeFormat& ncr_format,
const bool remove_on_renew,
const bool always_include_fqdn,
- const bool allow_client_update,
const bool override_no_update,
const bool override_client_update,
const bool replace_client_name,
ncr_format_(ncr_format),
remove_on_renew_(remove_on_renew),
always_include_fqdn_(always_include_fqdn),
- allow_client_update_(allow_client_update),
override_no_update_(override_no_update),
override_client_update_(override_client_update),
replace_client_name_(replace_client_name),
generated_prefix_(generated_prefix),
qualifying_suffix_(qualifying_suffix) {
- if (ncr_format_ != dhcp_ddns::FMT_JSON) {
- isc_throw(D2ClientError, "D2ClientConfig: NCR Format:"
- << dhcp_ddns::ncrFormatToString(ncr_format)
- << " is not yet supported");
- }
-
- if (ncr_protocol_ != dhcp_ddns::NCR_UDP) {
- isc_throw(D2ClientError, "D2ClientConfig: NCR Protocol:"
- << dhcp_ddns::ncrProtocolToString(ncr_protocol)
- << " is not yet supported");
- }
-
- // @todo perhaps more validation we should do yet?
- // Are there any invalid combinations of options we need to test against?
- // For instance are allow_client_update and override_client_update mutually
- // exclusive?
- // Also do we care about validating contents if it's disabled?
+ validateContents();
}
D2ClientConfig::D2ClientConfig()
ncr_format_(dhcp_ddns::FMT_JSON),
remove_on_renew_(false),
always_include_fqdn_(false),
- allow_client_update_(false),
override_no_update_(false),
override_client_update_(false),
replace_client_name_(false),
generated_prefix_(""),
qualifying_suffix_("") {
+ validateContents();
}
D2ClientConfig::~D2ClientConfig(){};
+void
+D2ClientConfig::validateContents() {
+ if (ncr_format_ != dhcp_ddns::FMT_JSON) {
+ isc_throw(D2ClientError, "D2ClientConfig: NCR Format:"
+ << dhcp_ddns::ncrFormatToString(ncr_format_)
+ << " is not yet supported");
+ }
+
+ if (ncr_protocol_ != dhcp_ddns::NCR_UDP) {
+ isc_throw(D2ClientError, "D2ClientConfig: NCR Protocol:"
+ << dhcp_ddns::ncrProtocolToString(ncr_protocol_)
+ << " is not yet supported");
+ }
+
+ // @todo perhaps more validation we should do yet?
+ // Are there any invalid combinations of options we need to test against?
+ // Also do we care about validating contents if it's disabled?
+}
+
bool
D2ClientConfig::operator == (const D2ClientConfig& other) const {
return ((enable_updates_ == other.enable_updates_) &&
(ncr_format_ == other.ncr_format_) &&
(remove_on_renew_ == other.remove_on_renew_) &&
(always_include_fqdn_ == other.always_include_fqdn_) &&
- (allow_client_update_ == other.allow_client_update_) &&
(override_no_update_ == other.override_no_update_) &&
(override_client_update_ == other.override_client_update_) &&
(replace_client_name_ == other.replace_client_name_) &&
<< ", remove_on_renew: " << (remove_on_renew_ ? "yes" : "no")
<< ", always_include_fqdn: " << (always_include_fqdn_ ?
"yes" : "no")
- << ", allow_client_update: " << (allow_client_update_ ?
- "yes" : "no")
<< ", override_no_update: " << (override_no_update_ ?
"yes" : "no")
<< ", override_client_update: " << (override_client_update_ ?
// For now we just update the configuration.
d2_client_config_ = new_config;
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_CFGMGR_CFG_DHCP_DDNS)
- .arg(!isDhcpDdnsEnabled() ? "DHCP-DDNS updates disabled" :
+ .arg(!ddnsEnabled() ? "DHCP-DDNS updates disabled" :
"DHCP_DDNS updates enabled");
}
bool
-D2ClientMgr::isDhcpDdnsEnabled() {
+D2ClientMgr::ddnsEnabled() {
return (d2_client_config_->getEnableUpdates());
}
-// 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
/// @brief Constructor
///
/// @param enable_updates Enables DHCP-DDNS updates
- /// @param server_ip IP address of the b10-dhcp-ddns server
+ /// @param server_ip IP address of the b10-dhcp-ddns server (IPv4 or IPv6)
/// @param server_port IP port of the b10-dhcp-ddns server
/// @param ncr_protocol Socket protocol to use with b10-dhcp-ddns
/// Currently only UDP is supported.
/// is unnecessary).
/// @param always_include_fqdn Enables always including the FQDN option in
/// DHCP responses.
- /// @param allow_client_update Enables delegation of updates to clients
/// @param override_no_update Enables updates, even if clients request no
/// updates.
/// @param override_client_update Perform updates, even if client requested
const dhcp_ddns::NameChangeFormat& ncr_format,
const bool remove_on_renew,
const bool always_include_fqdn,
- const bool allow_client_update,
const bool override_no_update,
const bool override_client_update,
const bool replace_client_name,
return(enable_updates_);
}
- /// @brief Return the IP address of b10-dhcp-ddns.
+ /// @brief Return the IP address of b10-dhcp-ddns (IPv4 or IPv6).
const isc::asiolink::IOAddress& getServerIp() const {
return(server_ip_);
}
return(always_include_fqdn_);
}
- /// @brief Return whether or not updates can be delegated to clients.
- bool getAllowClientUpdate() const {
- return(allow_client_update_);
- }
-
/// @brief Return if updates are done even if clients request no updates.
bool getOverrideNoUpdate() const {
return(override_no_update_);
/// @brief Generates a string representation of the class contents.
std::string toText() const;
+protected:
+ /// @brief Validates member values.
+ ///
+ /// Method is used by the constructor to validate member contents.
+ ///
+ /// @throw D2ClientError if given an invalid protocol or format.
+ virtual void validateContents();
+
private:
/// @brief Indicates whether or not DHCP DDNS updating is enabled.
bool enable_updates_;
- /// @brief IP address of the b10-dhcp-ddns server.
+ /// @brief IP address of the b10-dhcp-ddns server (IPv4 or IPv6).
isc::asiolink::IOAddress server_ip_;
/// @brief IP port of the b10-dhcp-ddns server.
/// @brief Should Kea always include the FQDN option in its response.
bool always_include_fqdn_;
- /// @brief Should Kea permit the client to do updates.
- bool allow_client_update_;
-
/// @brief Should Kea perform updates, even if client requested no updates.
/// Overrides the client request for no updates via the N flag.
bool override_no_update_;
/// Provides services for managing the current D2ClientConfig and managing
/// communications with D2. (@todo The latter will be added once communication
/// with D2 is implemented through the integration of
-/// dhcp_ddns::NameChangeSender interface(s).
+/// dhcp_ddns::NameChangeSender interface(s)).
///
class D2ClientMgr {
public:
/// @brief Convenience method for checking if DHCP-DDNS is enabled.
///
/// @return True if the D2 configuration is enabled.
- bool isDhcpDdnsEnabled();
+ bool ddnsEnabled();
/// @brief Fetches the DHCP-DDNS configuration pointer.
///
-// 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
bool remove_on_renew = boolean_values_->getParam("remove-on-renew");
bool always_include_fqdn = boolean_values_->getParam("always-include-fqdn");
- bool allow_client_update = boolean_values_->getParam("allow-client-update");
bool override_no_update = boolean_values_->getParam("override-no-update");
bool override_client_update = boolean_values_->
getParam("override-client-update");
server_port, ncr_protocol,
ncr_format, remove_on_renew,
always_include_fqdn,
- allow_client_update,
override_no_update,
override_client_update,
replace_client_name,
-// 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
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
EXPECT_TRUE(false == lease->fqdn_fwd_);
EXPECT_TRUE(false == lease->fqdn_rev_);
EXPECT_TRUE(*lease->duid_ == *duid_);
- // @todo: check cltt
+ /// @todo: check cltt
}
/// @brief Checks if specified address is increased properly
EXPECT_TRUE(*lease->client_id_ == *clientid_);
}
EXPECT_TRUE(lease->hwaddr_ == hwaddr_->hwaddr_);
- // @todo: check cltt
+ /// @todo: check cltt
}
virtual ~AllocEngine4Test() {
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
cfg_mgr.addOptionSpace4(space3), isc::dhcp::InvalidOptionSpace
);
- // @todo decode if a duplicate vendor space is allowed.
+ /// @todo decode if a duplicate vendor space is allowed.
}
// This test verifies that new DHCPv6 option spaces can be added to
cfg_mgr.addOptionSpace6(space3), isc::dhcp::InvalidOptionSpace
);
- // @todo decide if a duplicate vendor space is allowed.
+ /// @todo decide if a duplicate vendor space is allowed.
}
// This test verifies that it is possible to specify interfaces that server
EXPECT_FALSE(original_config->getEnableUpdates());
// Make sure convenience method agrees.
- EXPECT_FALSE(CfgMgr::instance().isDhcpDdnsEnabled());
+ EXPECT_FALSE(CfgMgr::instance().ddnsEnabled());
// Verify that we cannot set the configuration to an empty pointer.
D2ClientConfigPtr new_cfg;
ASSERT_NO_THROW(new_cfg.reset(new D2ClientConfig(true,
isc::asiolink::IOAddress("127.0.0.1"), 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
// Verify that we can assign a new, non-empty configuration.
EXPECT_TRUE(updated_config->getEnableUpdates());
// Make sure convenience method agrees with updated configuration.
- EXPECT_TRUE(CfgMgr::instance().isDhcpDdnsEnabled());
+ EXPECT_TRUE(CfgMgr::instance().ddnsEnabled());
// Make sure the configuration we fetched is the one we assigned,
// and not the original configuration.
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
namespace {
-// brief Checks constructors and accessors of D2ClientConfig.
+/// @brief Checks constructors and accessors of D2ClientConfig.
TEST(D2ClientConfigTest, constructorsAndAccessors) {
D2ClientConfigPtr d2_client_config;
dhcp_ddns::NameChangeFormat ncr_format = dhcp_ddns::FMT_JSON;
bool remove_on_renew = true;
bool always_include_fqdn = true;
- bool allow_client_update = true;
bool override_no_update = true;
bool override_client_update = true;
bool replace_client_name = true;
ncr_format,
remove_on_renew,
always_include_fqdn,
- allow_client_update,
override_no_update,
override_client_update,
replace_client_name,
EXPECT_EQ(d2_client_config->getNcrFormat(), ncr_format);
EXPECT_EQ(d2_client_config->getRemoveOnRenew(), remove_on_renew);
EXPECT_EQ(d2_client_config->getAlwaysIncludeFqdn(), always_include_fqdn);
- EXPECT_EQ(d2_client_config->getAllowClientUpdate(), allow_client_update);
EXPECT_EQ(d2_client_config->getOverrideNoUpdate(), override_no_update);
EXPECT_EQ(d2_client_config->getOverrideClientUpdate(),
override_client_update);
*d2_client_config << std::endl);
// Verify that constructor does not allow use of NCR_TCP.
- // @todo obviously this becomes invalid once TCP is supported.
+ /// @todo obviously this becomes invalid once TCP is supported.
ASSERT_THROW(d2_client_config.reset(new
D2ClientConfig(enable_updates,
server_ip,
ncr_format,
remove_on_renew,
always_include_fqdn,
- allow_client_update,
override_no_update,
override_client_update,
replace_client_name,
qualifying_suffix)),
D2ClientError);
- // @todo if additional validation is added to ctor, this test needs to
- // expand accordingly.
+ /// @todo if additional validation is added to ctor, this test needs to
+ /// expand accordingly.
}
-// Tests the equality and inequality operators of D2ClientConfig.
+/// @brief Tests the equality and inequality operators of D2ClientConfig.
TEST(D2ClientConfigTest, equalityOperator) {
D2ClientConfigPtr ref_config;
D2ClientConfigPtr test_config;
ASSERT_NO_THROW(ref_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(ref_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_TRUE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(false,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
test_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 333,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- false, true, true, true, true, true,
+ false, true, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, false, true, true, true, true,
- "pre-fix", "suf-fix")));
- ASSERT_TRUE(test_config);
- EXPECT_FALSE(*ref_config == *test_config);
- EXPECT_TRUE(*ref_config != *test_config);
-
- // Check a configuration that differs only by allow_client_update.
- ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
- ref_address, 477,
- dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, false, true, true, true,
+ true, false, true, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, false, true, true,
+ true, true, false, true, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, false, true,
+ true, true, true, false, true,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, false,
+ true, true, true, true, false,
"pre-fix", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"bogus", "suf-fix")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
ASSERT_NO_THROW(test_config.reset(new D2ClientConfig(true,
ref_address, 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "bogus")));
ASSERT_TRUE(test_config);
EXPECT_FALSE(*ref_config == *test_config);
EXPECT_TRUE(*ref_config != *test_config);
}
-// This test checks the D2ClientMgr constructor.
+/// @brief Checks the D2ClientMgr constructor.
TEST(D2ClientMgr, constructor) {
D2ClientMgrPtr d2_client_mgr;
EXPECT_FALSE(original_config->getEnableUpdates());
// Make sure convenience method agrees.
- EXPECT_FALSE(d2_client_mgr->isDhcpDdnsEnabled());
+ EXPECT_FALSE(d2_client_mgr->ddnsEnabled());
}
-// This test checks passing the D2ClientMgr a valid D2 client configuration.
-// @todo Once NameChangeSender is integrated, this test needs to expand, and
-// additional scenario tests will need to be written.
+/// @brief Checks passing the D2ClientMgr a valid D2 client configuration.
+/// @todo Once NameChangeSender is integrated, this test needs to expand, and
+/// additional scenario tests will need to be written.
TEST(D2ClientMgr, validConfig) {
D2ClientMgrPtr d2_client_mgr;
ASSERT_NO_THROW(new_cfg.reset(new D2ClientConfig(true,
isc::asiolink::IOAddress("127.0.0.1"), 477,
dhcp_ddns::NCR_UDP, dhcp_ddns::FMT_JSON,
- true, true, true, true, true, true,
+ true, true, true, true, true,
"pre-fix", "suf-fix")));
// Verify that we can assign a new, non-empty configuration.
EXPECT_TRUE(updated_config->getEnableUpdates());
// Make sure convenience method agrees with the updated configuration.
- EXPECT_TRUE(d2_client_mgr->isDhcpDdnsEnabled());
+ EXPECT_TRUE(d2_client_mgr->ddnsEnabled());
// Make sure the configuration we fetched is the one we assigned,
// and not the original configuration.
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
// Check with a set of libraries, some of which are invalid.
TEST_F(ParseConfigTest, invalidHooksLibrariesTest) {
- // @todo Initialize global library context to null
+ /// @todo Initialize global library context to null
// Configuration string. This contains an invalid library which should
// trigger an error in the "build" stage.
/// @brief Checks that a valid, enabled D2 client configuration works correctly.
TEST_F(ParseConfigTest, validD2Config) {
- // Configuration string. This contains a set of valid libraries.
+ // Configuration string containing valid values.
std::string config_str =
"{ \"dhcp-ddns\" :"
" {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 3432, "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
ASSERT_TRUE(rcode == 0) << error_text_;
// Verify that DHCP-DDNS is enabled and we can fetch the configuration.
- EXPECT_TRUE(CfgMgr::instance().isDhcpDdnsEnabled());
+ EXPECT_TRUE(CfgMgr::instance().ddnsEnabled());
D2ClientConfigPtr d2_client_config;
ASSERT_NO_THROW(d2_client_config = CfgMgr::instance().getD2ClientConfig());
ASSERT_TRUE(d2_client_config);
// Verify that the configuration values are as expected.
EXPECT_TRUE(d2_client_config->getEnableUpdates());
EXPECT_EQ("192.168.2.1", d2_client_config->getServerIp().toText());
- EXPECT_EQ(5301, d2_client_config->getServerPort());
+ EXPECT_EQ(3432, d2_client_config->getServerPort());
EXPECT_EQ(dhcp_ddns::NCR_UDP, d2_client_config->getNcrProtocol());
EXPECT_EQ(dhcp_ddns::FMT_JSON, d2_client_config->getNcrFormat());
EXPECT_TRUE(d2_client_config->getRemoveOnRenew());
EXPECT_TRUE(d2_client_config->getAlwaysIncludeFqdn());
- EXPECT_TRUE(d2_client_config->getAllowClientUpdate());
EXPECT_TRUE(d2_client_config->getOverrideNoUpdate());
EXPECT_TRUE(d2_client_config->getOverrideClientUpdate());
EXPECT_TRUE(d2_client_config->getReplaceClientName());
EXPECT_EQ("test.prefix", d2_client_config->getGeneratedPrefix());
EXPECT_EQ("test.suffix.", d2_client_config->getQualifyingSuffix());
+
+ // Another valid Configuration string.
+ // This one has IPV6 server ip, control flags false,
+ // empty prefix/suffix
+ std::string config_str2 =
+ "{ \"dhcp-ddns\" :"
+ " {"
+ " \"enable-updates\" : true, "
+ " \"server-ip\" : \"3005::1\", "
+ " \"server-port\" : 43567, "
+ " \"ncr-protocol\" : \"UDP\", "
+ " \"ncr-format\" : \"JSON\", "
+ " \"remove-on-renew\" : false, "
+ " \"always-include-fqdn\" : false, "
+ " \"override-no-update\" : false, "
+ " \"override-client-update\" : false, "
+ " \"replace-client-name\" : false, "
+ " \"generated-prefix\" : \"\", "
+ " \"qualifying-suffix\" : \"\" "
+ " }"
+ "}";
+
+ // Verify that the configuration string parses.
+ rcode = parseConfiguration(config_str2);
+ ASSERT_TRUE(rcode == 0) << error_text_;
+
+ // Verify that DHCP-DDNS is enabled and we can fetch the configuration.
+ EXPECT_TRUE(CfgMgr::instance().ddnsEnabled());
+ ASSERT_NO_THROW(d2_client_config = CfgMgr::instance().getD2ClientConfig());
+ ASSERT_TRUE(d2_client_config);
+
+ // Verify that the configuration values are as expected.
+ EXPECT_TRUE(d2_client_config->getEnableUpdates());
+ EXPECT_EQ("3005::1", d2_client_config->getServerIp().toText());
+ EXPECT_EQ(43567, d2_client_config->getServerPort());
+ EXPECT_EQ(dhcp_ddns::NCR_UDP, d2_client_config->getNcrProtocol());
+ EXPECT_EQ(dhcp_ddns::FMT_JSON, d2_client_config->getNcrFormat());
+ EXPECT_FALSE(d2_client_config->getRemoveOnRenew());
+ EXPECT_FALSE(d2_client_config->getAlwaysIncludeFqdn());
+ EXPECT_FALSE(d2_client_config->getOverrideNoUpdate());
+ EXPECT_FALSE(d2_client_config->getOverrideClientUpdate());
+ EXPECT_FALSE(d2_client_config->getReplaceClientName());
+ EXPECT_EQ("", d2_client_config->getGeneratedPrefix());
+ EXPECT_EQ("", d2_client_config->getQualifyingSuffix());
}
/// @brief Checks that D2 client can be configured with enable flag of
ASSERT_TRUE(rcode == 0) << error_text_;
// Verify that DHCP-DDNS is disabled.
- EXPECT_FALSE(CfgMgr::instance().isDhcpDdnsEnabled());
+ EXPECT_FALSE(CfgMgr::instance().ddnsEnabled());
// Make sure fetched config agrees.
D2ClientConfigPtr d2_client_config;
" {"
" \"enable-updates\" : true, "
//" \"server-ip\" : \"192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 53001, "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
" {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"x192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 53001, "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
" {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 53001, "
" \"ncr-protocol\" : \"Bogus\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
" {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 53001, "
" \"ncr-protocol\" : \"TCP\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
" {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"192.168.2.1\", "
- " \"server-port\" : 5301, "
+ " \"server-port\" : 53001, "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"Bogus\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
" {"
" \"enable-updates\" : true, "
" \"server-ip\" : \"192.168.2.1\", "
- // " \"server-port\" : 5301, "
+ // " \"server-port\" : 53001, "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"remove-on-renew\" : true, "
" \"always-include-fqdn\" : true, "
- " \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
" \"replace-client-name\" : true, "
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
EXPECT_EQ(Lease6Ptr(), x);
}
-// @todo Write more memfile tests
+/// @todo Write more memfile tests
// Simple test about lease4 retrieval through client id method
TEST_F(MemfileLeaseMgrTest, getLease4ClientId) {
-// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
}
// Get the leases matching the hardware address of lease 1
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
HWAddr tmp(leases[1]->hwaddr_, HTYPE_ETHER);
Lease4Collection returned = lmptr_->getLease4(tmp);
EXPECT_EQ(straddress4_[5], addresses[2]);
// Repeat test with just one expected match
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
returned = lmptr_->getLease4(HWAddr(leases[2]->hwaddr_, HTYPE_ETHER));
ASSERT_EQ(1, returned.size());
detailCompareLease(leases[2], *returned.begin());
// Check that an empty vector is valid
EXPECT_TRUE(leases[7]->hwaddr_.empty());
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
returned = lmptr_->getLease4(HWAddr(leases[7]->hwaddr_, HTYPE_ETHER));
ASSERT_EQ(1, returned.size());
detailCompareLease(leases[7], *returned.begin());
for (uint8_t i = 0; i <= HWAddr::MAX_HWADDR_LEN; ++i) {
leases[1]->hwaddr_.resize(i, i);
EXPECT_TRUE(lmptr_->addLease(leases[1]));
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
Lease4Collection returned =
lmptr_->getLease4(HWAddr(leases[1]->hwaddr_, HTYPE_ETHER));
// Database should not let us add one that is too big
// (The 42 is a random value put in each byte of the address.)
- // @todo: 2589 will make this test impossible
+ /// @todo: 2589 will make this test impossible
leases[1]->hwaddr_.resize(HWAddr::MAX_HWADDR_LEN + 100, 42);
EXPECT_THROW(lmptr_->addLease(leases[1]), isc::dhcp::DbOperationError);
}
// Get the leases matching the hardware address of lease 1 and
// subnet ID of lease 1. Result should be a single lease - lease 1.
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
Lease4Ptr returned = lmptr_->getLease4(HWAddr(leases[1]->hwaddr_,
HTYPE_ETHER), leases[1]->subnet_id_);
// Try for a match to the hardware address of lease 1 and the wrong
// subnet ID.
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
returned = lmptr_->getLease4(HWAddr(leases[1]->hwaddr_, HTYPE_ETHER),
leases[1]->subnet_id_ + 1);
EXPECT_FALSE(returned);
// Try for a match to the subnet ID of lease 1 (and lease 4) but
// the wrong hardware address.
vector<uint8_t> invalid_hwaddr(15, 0x77);
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
returned = lmptr_->getLease4(HWAddr(invalid_hwaddr, HTYPE_ETHER),
leases[1]->subnet_id_);
EXPECT_FALSE(returned);
// Try for a match to an unknown hardware address and an unknown
// subnet ID.
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
returned = lmptr_->getLease4(HWAddr(invalid_hwaddr, HTYPE_ETHER),
leases[1]->subnet_id_ + 1);
EXPECT_FALSE(returned);
EXPECT_TRUE(lmptr_->deleteLease(leases[2]->addr_));
leases[1]->addr_ = leases[2]->addr_;
EXPECT_TRUE(lmptr_->addLease(leases[1]));
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
EXPECT_THROW(returned = lmptr_->getLease4(HWAddr(leases[1]->hwaddr_,
HTYPE_ETHER),
leases[1]->subnet_id_),
for (uint8_t i = 0; i <= HWAddr::MAX_HWADDR_LEN; ++i) {
leases[1]->hwaddr_.resize(i, i);
EXPECT_TRUE(lmptr_->addLease(leases[1]));
- // @todo: Simply use HWAddr directly once 2589 is implemented
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
Lease4Ptr returned = lmptr_->getLease4(HWAddr(leases[1]->hwaddr_,
HTYPE_ETHER),
leases[1]->subnet_id_);