Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adam Osuchowski
Kea
Commits
d5ccd277
Commit
d5ccd277
authored
Aug 18, 2014
by
Marcin Siodelski
Browse files
[3477] Return status of DDNS updates in the configuration summary.
parent
32b9a136
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/configuration.cc
View file @
d5ccd277
...
...
@@ -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"
;
}
...
...
src/lib/dhcpsrv/configuration.h
View file @
d5ccd277
...
...
@@ -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_
;
...
...
src/lib/dhcpsrv/tests/configuration_unittest.cc
View file @
d5ccd277
...
...
@@ -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_
ALL
4
));
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_
SUBNET
4
));
// 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_
ALL
6
));
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_
SUBNET
6
));
// Add IPv4 subnet and make sure it is reported.
addSubnet4
(
0
);
EXPECT_EQ
(
"added IPv4 subnets: 1"
,
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_
ALL
4
));
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_
SUBNET
4
));
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_
ALL
6
));
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_
SUBNET
6
));
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_
ALL
4
));
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_
SUBNET
4
));
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment