Skip to content
GitLab
Menu
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
07f4340e
Commit
07f4340e
authored
Nov 28, 2016
by
Francis Dupont
Committed by
Tomek Mrugalski
Nov 29, 2016
Browse files
[5014_phase2] Added recursive include unit test
parent
58bb8f34
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp6/tests/kea_controller_unittest.cc
View file @
07f4340e
...
...
@@ -12,6 +12,7 @@
#include <dhcp/duid.h>
#include <dhcp/iface_mgr.h>
#include <dhcp6/ctrl_dhcp6_srv.h>
#include <dhcp6/parser_context.h>
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/lease.h>
...
...
@@ -370,6 +371,46 @@ TEST_F(JSONFileBackendTest, include) {
EXPECT_EQ
(
Lease
::
TYPE_NA
,
pools1
.
at
(
0
)
->
getType
());
}
// This test checks if recursive include of a file is detected
TEST_F
(
JSONFileBackendTest
,
recursiveInclude
)
{
string
config_recursive_include
=
"{
\"
Dhcp6
\"
: {"
"
\"
interfaces-config
\"
: {"
"
\"
interfaces
\"
: [ <?include
\"
"
+
string
(
TEST_INCLUDE
)
+
"
\"
?> ]"
"},"
"
\"
preferred-lifetime
\"
: 3000,"
"
\"
rebind-timer
\"
: 2000, "
"
\"
renew-timer
\"
: 1000,
\n
"
"
\"
subnet6
\"
: [ { "
"
\"
pools
\"
: [ {
\"
pool
\"
:
\"
2001:db8:1::/80
\"
} ],"
"
\"
subnet
\"
:
\"
2001:db8:1::/64
\"
"
" } ],"
"
\"
valid-lifetime
\"
: 4000 }"
"}"
;
string
include
=
"
\"
eth
\"
, <?include
\"
"
+
string
(
TEST_INCLUDE
)
+
"
\"
?>"
;
string
msg
=
"configuration error using file '"
+
string
(
TEST_FILE
)
+
"': Too many nested include."
;
writeFile
(
TEST_FILE
,
config_recursive_include
);
writeFile
(
TEST_INCLUDE
,
include
);
// Now initialize the server
boost
::
scoped_ptr
<
ControlledDhcpv6Srv
>
srv
;
ASSERT_NO_THROW
(
srv
.
reset
(
new
ControlledDhcpv6Srv
(
0
))
);
// And configure it using config
try
{
srv
->
init
(
TEST_FILE
);
FAIL
()
<<
"Expected Dhcp6ParseError but nothing was raised"
;
}
catch
(
const
Exception
&
ex
)
{
EXPECT_EQ
(
msg
,
ex
.
what
());
}
}
// This test checks if configuration can be read from a JSON file.
// This test checks if configuration detects failure when trying:
// - empty file
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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