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
ISC Open Source Projects
Kea
Commits
dce538b3
Commit
dce538b3
authored
Jul 13, 2017
by
Marcin Siodelski
Browse files
[5108] Addressed review comments.
Added unit tests that check that configuration of various servers can coexist.
parent
67dd7b47
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/agent/tests/parser_unittests.cc
View file @
dce538b3
...
...
@@ -117,6 +117,54 @@ TEST(ParserTest, keywordJSON) {
testParser
(
txt
,
ParserContext
::
PARSER_JSON
);
}
// This test checks that the DhcpDdns configuration is accepted
// by the parser.
TEST
(
ParserTest
,
keywordDhcpDdns
)
{
string
txt
=
"{
\"
DhcpDdns
\"
:
\n
"
"{
\n
"
"
\"
ip-address
\"
:
\"
192.168.77.1
\"
,
\n
"
"
\"
port
\"
: 777 ,
\n
"
"
\"
ncr-protocol
\"
:
\"
UDP
\"
,
\n
"
"
\"
tsig-keys
\"
: [],
\n
"
"
\"
forward-ddns
\"
: {},
\n
"
"
\"
reverse-ddns
\"
: {}
\n
"
"}
\n
"
"}
\n
"
;
testParser
(
txt
,
ParserContext
::
PARSER_AGENT
);
}
// This test checks that the Dhcp6 configuration is accepted
// by the parser.
TEST
(
ParserTest
,
keywordDhcp6
)
{
string
txt
=
"{
\"
Dhcp6
\"
: {
\"
interfaces-config
\"
: {"
"
\"
interfaces
\"
: [
\"
type
\"
,
\"
htype
\"
] },
\n
"
"
\"
preferred-lifetime
\"
: 3000,
\n
"
"
\"
rebind-timer
\"
: 2000,
\n
"
"
\"
renew-timer
\"
: 1000,
\n
"
"
\"
subnet6
\"
: [ { "
"
\"
pools
\"
: [ {
\"
pool
\"
:
\"
2001:db8:1::/64
\"
} ],"
"
\"
subnet
\"
:
\"
2001:db8:1::/48
\"
, "
"
\"
interface
\"
:
\"
test
\"
} ],
\n
"
"
\"
valid-lifetime
\"
: 4000 } }"
;
testParser
(
txt
,
ParserContext
::
PARSER_AGENT
);
}
// This test checks that the Dhcp4 configuration is accepted
// by the parser.
TEST
(
ParserTest
,
keywordDhcp4
)
{
string
txt
=
"{
\"
Dhcp4
\"
: {
\"
interfaces-config
\"
: {"
"
\"
interfaces
\"
: [
\"
type
\"
,
\"
htype
\"
] },
\n
"
"
\"
rebind-timer
\"
: 2000,
\n
"
"
\"
renew-timer
\"
: 1000,
\n
"
"
\"
subnet4
\"
: [ { "
"
\"
pools
\"
: [ {
\"
pool
\"
:
\"
192.0.2.1 - 192.0.2.100
\"
} ],"
"
\"
subnet
\"
:
\"
192.0.2.0/24
\"
, "
"
\"
interface
\"
:
\"
test
\"
} ],
\n
"
"
\"
valid-lifetime
\"
: 4000 } }"
;
testParser
(
txt
,
ParserContext
::
PARSER_AGENT
);
}
// This test checks if full config (with top level and Control-agent objects) can
// be parsed with syntactic checking (and as pure JSON).
TEST
(
ParserTest
,
keywordAgent
)
{
...
...
src/bin/d2/tests/parser_unittest.cc
View file @
dce538b3
...
...
@@ -159,6 +159,11 @@ TEST(ParserTest, keywordDhcp4) {
testParser
(
txt
,
D2ParserContext
::
PARSER_DHCPDDNS
);
}
TEST
(
ParserTest
,
keywordControlAgent
)
{
string
txt
=
"{
\"
Control-agent
\"
: { } }"
;
testParser
(
txt
,
D2ParserContext
::
PARSER_DHCPDDNS
);
}
TEST
(
ParserTest
,
Logging
)
{
string
txt
=
"{
\"
Logging
\"
: {
\n
"
"
\"
loggers
\"
: [
\n
"
...
...
src/bin/dhcp4/tests/kea_controller_unittest.cc
View file @
dce538b3
...
...
@@ -183,6 +183,31 @@ TEST_F(JSONFileBackendTest, jsonFile) {
EXPECT_EQ
(
Lease
::
TYPE_V4
,
pools3
.
at
(
0
)
->
getType
());
}
// This test verifies that the configurations for various servers
// can coexist and that the DHCPv4 configuration parsers will simply
// ignore them.
TEST_F
(
JSONFileBackendTest
,
serverConfigurationsCoexistence
)
{
std
::
string
config
=
"{
\"
Dhcp4
\"
: {"
"
\"
rebind-timer
\"
: 2000, "
"
\"
renew-timer
\"
: 1000,
\n
"
"
\"
valid-lifetime
\"
: 4000 }, "
"
\"
Dhcp6
\"
: { },"
"
\"
DhcpDdns
\"
: { },"
"
\"
Control-agent
\"
: { }"
"}"
;
writeFile
(
TEST_FILE
,
config
);
// Now initialize the server
boost
::
scoped_ptr
<
ControlledDhcpv4Srv
>
srv
;
ASSERT_NO_THROW
(
srv
.
reset
(
new
ControlledDhcpv4Srv
(
0
))
);
// And configure it using the config file.
EXPECT_NO_THROW
(
srv
->
init
(
TEST_FILE
));
}
// This test checks if configuration can be read from a JSON file
// using hash (#) line comments
TEST_F
(
JSONFileBackendTest
,
hashComments
)
{
...
...
src/bin/dhcp6/tests/kea_controller_unittest.cc
View file @
dce538b3
...
...
@@ -169,6 +169,32 @@ TEST_F(JSONFileBackendTest, jsonFile) {
EXPECT_EQ
(
Lease
::
TYPE_NA
,
pools3
.
at
(
0
)
->
getType
());
}
// This test verifies that the configurations for various servers
// can coexist and that the DHCPv6 configuration parsers will simply
// ignore them.
TEST_F
(
JSONFileBackendTest
,
serverConfigurationsCoexistence
)
{
std
::
string
config
=
"{
\"
Dhcp6
\"
: {"
"
\"
rebind-timer
\"
: 2000, "
"
\"
renew-timer
\"
: 1000,
\n
"
"
\"
preferred-lifetime
\"
: 1000,
\n
"
"
\"
valid-lifetime
\"
: 4000 }, "
"
\"
Dhcp4
\"
: { },"
"
\"
DhcpDdns
\"
: { },"
"
\"
Control-agent
\"
: { }"
"}"
;
writeFile
(
TEST_FILE
,
config
);
// Now initialize the server
boost
::
scoped_ptr
<
ControlledDhcpv6Srv
>
srv
;
ASSERT_NO_THROW
(
srv
.
reset
(
new
ControlledDhcpv6Srv
(
0
))
);
// And configure it using the config file.
EXPECT_NO_THROW
(
srv
->
init
(
TEST_FILE
));
}
// This test checks if configuration can be read from a JSON file
// using hash (#) line comments
TEST_F
(
JSONFileBackendTest
,
hashComments
)
{
...
...
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