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
6accbe4b
Commit
6accbe4b
authored
Mar 02, 2017
by
Tomek Mrugalski
🛰
Browse files
[5134_rebase] bug in setAllDefaults fixed, unit-tests added.
parent
a3399502
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/agent/simple_parser.cc
View file @
6accbe4b
...
...
@@ -69,7 +69,7 @@ size_t AgentSimpleParser::setAllDefaults(isc::data::ElementPtr global) {
}
ElementPtr
d6
=
boost
::
const_pointer_cast
<
Element
>
(
sockets
->
get
(
"dhcp6-server"
));
if
(
d
2
)
{
if
(
d
6
)
{
cnt
+=
SimpleParser
::
setDefaults
(
d6
,
SOCKET_DEFAULTS
);
}
}
...
...
src/bin/agent/tests/ctrl_agent_cfg_mgr_unittest.cc
View file @
6accbe4b
...
...
@@ -233,6 +233,28 @@ const char* AGENT_CONFIGS[] = {
" }
\n
"
" }
\n
"
" ]
\n
"
"}"
,
// Configuration 5: http and 1 socket (d2 only)
"{
\n
"
"
\"
http-host
\"
:
\"
betelguese
\"
,
\n
"
"
\"
http-port
\"
: 8001,
\n
"
"
\"
control-sockets
\"
: {
\n
"
"
\"
d2-server
\"
: {
\n
"
"
\"
socket-name
\"
:
\"
/tmp/socket-d2
\"\n
"
" }
\n
"
" }
\n
"
"}"
,
// Configuration 6: http and 1 socket (dhcp6 only)
"{
\n
"
"
\"
http-host
\"
:
\"
betelguese
\"
,
\n
"
"
\"
http-port
\"
: 8001,
\n
"
"
\"
control-sockets
\"
: {
\n
"
"
\"
dhcp6-server
\"
: {
\n
"
"
\"
socket-name
\"
:
\"
/tmp/socket-v6
\"\n
"
" }
\n
"
" }
\n
"
"}"
};
...
...
@@ -289,7 +311,7 @@ TEST_F(AgentParserTest, configParseHttpOnly) {
// Tests if a single socket can be configured. BTW this test also checks
// if default value for socket-type is specified (the config doesn't have it,
// so the default value should be filed in).
TEST_F
(
AgentParserTest
,
configParse
1
Socket
)
{
TEST_F
(
AgentParserTest
,
configParseSocket
Dhcp4
)
{
configParse
(
AGENT_CONFIGS
[
2
],
0
);
CtrlAgentCfgContextPtr
ctx
=
cfg_mgr_
.
getCtrlAgentCfgContext
();
...
...
@@ -302,6 +324,39 @@ TEST_F(AgentParserTest, configParse1Socket) {
EXPECT_FALSE
(
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_D2
));
}
// Tests if a single socket can be configured. BTW this test also checks
// if default value for socket-type is specified (the config doesn't have it,
// so the default value should be filed in).
TEST_F
(
AgentParserTest
,
configParseSocketD2
)
{
configParse
(
AGENT_CONFIGS
[
5
],
0
);
CtrlAgentCfgContextPtr
ctx
=
cfg_mgr_
.
getCtrlAgentCfgContext
();
ASSERT_TRUE
(
ctx
);
ConstElementPtr
socket
=
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_D2
);
ASSERT_TRUE
(
socket
);
EXPECT_EQ
(
"{
\"
socket-name
\"
:
\"
/tmp/socket-d2
\"
,
\"
socket-type
\"
:
\"
unix
\"
}"
,
socket
->
str
());
EXPECT_FALSE
(
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_DHCP4
));
EXPECT_FALSE
(
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_DHCP6
));
}
// Tests if a single socket can be configured. BTW this test also checks
// if default value for socket-type is specified (the config doesn't have it,
// so the default value should be filed in).
TEST_F
(
AgentParserTest
,
configParseSocketDhcp6
)
{
configParse
(
AGENT_CONFIGS
[
6
],
0
);
CtrlAgentCfgContextPtr
ctx
=
cfg_mgr_
.
getCtrlAgentCfgContext
();
ASSERT_TRUE
(
ctx
);
ConstElementPtr
socket
=
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_DHCP6
);
ASSERT_TRUE
(
socket
);
EXPECT_EQ
(
"{
\"
socket-name
\"
:
\"
/tmp/socket-v6
\"
,
\"
socket-type
\"
:
\"
unix
\"
}"
,
socket
->
str
());
EXPECT_FALSE
(
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_DHCP4
));
EXPECT_FALSE
(
ctx
->
getControlSocketInfo
(
CtrlAgentCfgContext
::
TYPE_D2
));
}
// This tests if all 3 sockets can be configured and makes sure the parser
// doesn't confuse them.
TEST_F
(
AgentParserTest
,
configParse3Sockets
)
{
...
...
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