Commit d5ccd277 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3477] Return status of DDNS updates in the configuration summary.

parent 32b9a136
......@@ -43,6 +43,11 @@ Configuration::getConfigSummary(const uint32_t selection) const {
s << "; ";
}
if ((selection & CFGSEL_DDNS) == CFGSEL_DDNS) {
bool ddns_enabled = CfgMgr::instance().ddnsEnabled();
s << "DDNS: " << (ddns_enabled ? "enabled" : "disabled") << "; ";
}
if (s.tellp() == 0) {
s << "no config details available";
}
......
......@@ -84,12 +84,14 @@ typedef std::vector<isc::dhcp::LoggingInfo> LoggingInfoStorage;
/// @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_;
......
......@@ -108,6 +108,12 @@ public:
/// 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.
......@@ -141,6 +147,11 @@ ConfigurationTest::clearSubnets() {
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());
......@@ -171,6 +182,21 @@ TEST_F(ConfigurationTest, loggingInfo) {
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) {
......@@ -180,49 +206,49 @@ 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment