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
Sebastian Schrader
Kea
Commits
db804253
Commit
db804253
authored
Nov 05, 2014
by
Marcin Siodelski
Browse files
[3467] Added a lacking unit test for the minimal option-data config.
parent
3b56a498
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
View file @
db804253
...
...
@@ -776,6 +776,66 @@ TEST_F(ParseConfigTest, optionDataMinimal) {
EXPECT_EQ
(
"2001:db8:1::20"
,
opt
->
getAddresses
()[
0
].
toText
());
}
// This test verifies that the option data configuration with a minimal
// set of parameters works as expected when option definition is
// created in the configruation file.
TEST_F
(
ParseConfigTest
,
optionDataMinimalWithOptionDef
)
{
// Configuration string.
std
::
string
config
=
"{
\"
option-def
\"
: [ {"
"
\"
name
\"
:
\"
foo-name
\"
,"
"
\"
code
\"
: 2345,"
"
\"
type
\"
:
\"
ipv6-address
\"
,"
"
\"
array
\"
: True,"
"
\"
record-types
\"
:
\"\"
,"
"
\"
space
\"
:
\"
dhcp6
\"
,"
"
\"
encapsulate
\"
:
\"\"
"
" } ],"
"
\"
option-data
\"
: [ {"
"
\"
name
\"
:
\"
foo-name
\"
,"
"
\"
data
\"
:
\"
2001:db8:1::10, 2001:db8:1::123
\"
"
" } ]"
"}"
;
int
rcode
=
0
;
ASSERT_NO_THROW
(
rcode
=
parseConfiguration
(
config
));
EXPECT_EQ
(
0
,
rcode
);
Option6AddrLstPtr
opt
=
boost
::
dynamic_pointer_cast
<
Option6AddrLst
>
(
getOptionPtr
(
"dhcp6"
,
2345
));
ASSERT_TRUE
(
opt
);
ASSERT_EQ
(
2
,
opt
->
getAddresses
().
size
());
EXPECT_EQ
(
"2001:db8:1::10"
,
opt
->
getAddresses
()[
0
].
toText
());
EXPECT_EQ
(
"2001:db8:1::123"
,
opt
->
getAddresses
()[
1
].
toText
());
CfgMgr
::
instance
().
clear
();
// Do the same test but now use an option code.
config
=
"{
\"
option-def
\"
: [ {"
"
\"
name
\"
:
\"
foo-name
\"
,"
"
\"
code
\"
: 2345,"
"
\"
type
\"
:
\"
ipv6-address
\"
,"
"
\"
array
\"
: True,"
"
\"
record-types
\"
:
\"\"
,"
"
\"
space
\"
:
\"
dhcp6
\"
,"
"
\"
encapsulate
\"
:
\"\"
"
" } ],"
"
\"
option-data
\"
: [ {"
"
\"
code
\"
: 2345,"
"
\"
data
\"
:
\"
2001:db8:1::10, 2001:db8:1::123
\"
"
" } ]"
"}"
;
rcode
=
0
;
ASSERT_NO_THROW
(
rcode
=
parseConfiguration
(
config
));
EXPECT_EQ
(
0
,
rcode
);
opt
=
boost
::
dynamic_pointer_cast
<
Option6AddrLst
>
(
getOptionPtr
(
"dhcp6"
,
2345
));
ASSERT_TRUE
(
opt
);
ASSERT_EQ
(
2
,
opt
->
getAddresses
().
size
());
EXPECT_EQ
(
"2001:db8:1::10"
,
opt
->
getAddresses
()[
0
].
toText
());
EXPECT_EQ
(
"2001:db8:1::123"
,
opt
->
getAddresses
()[
1
].
toText
());
}
};
// 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