/// @todo Migrate all other configuration parameters from cfgmgr.h here
struct Configuration {
- static const uint16_t CFGSEL_NONE = 0x00000000;
- static const uint16_t CFGSEL_SUBNET4 = 0x00000001;
- static const uint16_t CFGSEL_SUBNET6 = 0x00000002;
- static const uint16_t CFGSEL_ALL4 = 0x00000001;
- static const uint16_t CFGSEL_ALL6 = 0x00000002;
- static const uint16_t CFGSEL_ALL = 0x00000003;
+ static const uint16_t CFGSEL_NONE = 0x0000;
+ static const uint16_t CFGSEL_SUBNET4 = 0x0001;
+ static const uint16_t CFGSEL_SUBNET6 = 0x0002;
+ static const uint16_t CFGSEL_SUBNET = 0x0003;
+ static const uint16_t CFGSEL_ALL4 = 0x0001;
+ static const uint16_t CFGSEL_ALL6 = 0x0002;
+ static const uint16_t CFGSEL_DDNS = 0x0004;
+ static const uint16_t CFGSEL_ALL = 0xFFFF;
/// @brief logging specific information
LoggingInfoStorage logging_info_;
/// from @c CfgMgr to @c Configuration.
void clearSubnets();
+ /// @brief Enable/disable DDNS.
+ ///
+ /// @param enable A boolean value indicating if the DDNS should be
+ /// enabled (true) or disabled (false).
+ void enableDDNS(const bool enable);
+
/// @brief Stores configuration.
Configuration conf_;
/// @brief A collection of IPv4 subnets used by unit tests.
CfgMgr::instance().deleteSubnets6();
}
+void
+ConfigurationTest::enableDDNS(const bool enable) {
+ CfgMgr::instance().getD2ClientConfig()->enableUpdates(enable);
+}
+
// Check that by default there are no logging entries
TEST_F(ConfigurationTest, basic) {
EXPECT_TRUE(conf_.logging_info_.empty());
EXPECT_EQ(2097152, conf_.logging_info_[0].destinations_[0].maxsize_);
}
+// Check that the configuration summary including information about the status
+// of DDNS is returned.
+TEST_F(ConfigurationTest, summaryDDNS) {
+ EXPECT_EQ("DDNS: disabled",
+ conf_.getConfigSummary(Configuration::CFGSEL_DDNS));
+
+ enableDDNS(true);
+ EXPECT_EQ("DDNS: enabled",
+ conf_.getConfigSummary(Configuration::CFGSEL_DDNS));
+
+ enableDDNS(false);
+ EXPECT_EQ("no IPv4 subnets!; no IPv6 subnets!; DDNS: disabled",
+ conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+}
+
// Check that the configuration summary including information about added
// subnets is returned.
TEST_F(ConfigurationTest, summarySubnets) {
// Initially, there are no subnets added but it should be explicitly
// reported when we query for information about the subnets.
EXPECT_EQ("no IPv4 subnets!; no IPv6 subnets!",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET));
// If we just want information about IPv4 subnets, there should be no
// mention of IPv6 subnets, even though there are none added.
EXPECT_EQ("no IPv4 subnets!",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL4));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET4));
// If we just want information about IPv6 subnets, there should be no
// mention of IPv4 subnets, even though there are none added.
EXPECT_EQ("no IPv6 subnets!",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL6));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET6));
// Add IPv4 subnet and make sure it is reported.
addSubnet4(0);
EXPECT_EQ("added IPv4 subnets: 1",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL4));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET4));
EXPECT_EQ("added IPv4 subnets: 1; no IPv6 subnets!",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET));
// Add IPv6 subnet and make sure it is reported.
addSubnet6(0);
EXPECT_EQ("added IPv6 subnets: 1",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL6));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET6));
EXPECT_EQ("added IPv4 subnets: 1; added IPv6 subnets: 1",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET));
// Add one more subnet and make sure the bumped value is only
// for IPv4, but not for IPv6.
addSubnet4(1);
EXPECT_EQ("added IPv4 subnets: 2; added IPv6 subnets: 1",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET));
EXPECT_EQ("added IPv4 subnets: 2",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL4));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET4));
addSubnet6(1);
EXPECT_EQ("added IPv4 subnets: 2; added IPv6 subnets: 2",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET));
// Remove all subnets and make sure that there are no reported subnets
// back again.
clearSubnets();
EXPECT_EQ("no IPv4 subnets!; no IPv6 subnets!",
- conf_.getConfigSummary(Configuration::CFGSEL_ALL));
+ conf_.getConfigSummary(Configuration::CFGSEL_SUBNET));
}
} // end of anonymous namespace