Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
ac3a0692
Commit
ac3a0692
authored
Sep 13, 2017
by
Tomek Mrugalski
🛰
Browse files
[5357] Added test for multiple shared-networks
parent
86e2aac4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/tests/config_parser_unittest.cc
View file @
ac3a0692
...
...
@@ -5207,11 +5207,12 @@ TEST_F(Dhcp4ParserTest, sharedNetworks3subnets) {
// This test checks if parameters are derived properly:
// - global to shared network
// - shared network to subnet
// Also, it tests that more than one shared network can be defined.
TEST_F
(
Dhcp4ParserTest
,
sharedNetworksDerive
)
{
string
config
=
"{
\n
"
"
\"
valid-lifetime
\"
: 4,
\n
"
"
\"
rebind-timer
\"
: 2,
\n
"
"
\"
renew-timer
\"
: 1,
\n
"
"
\"
rebind-timer
\"
: 2,
\n
"
"
\"
valid-lifetime
\"
: 4,
\n
"
"
\"
shared-networks
\"
: [ {
\n
"
"
\"
name
\"
:
\"
foo
\"\n
,"
"
\"
renew-timer
\"
: 10,
\n
"
...
...
@@ -5226,6 +5227,17 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
"
\"
renew-timer
\"
: 100
\n
"
" }
\n
"
" ]
\n
"
" },
\n
"
"{ // second shared-network starts here
\n
"
"
\"
name
\"
:
\"
bar
\"
,
\n
"
"
\"
subnet4
\"
: [
\n
"
" {
\n
"
"
\"
subnet
\"
:
\"
192.0.3.0/24
\"
,
\n
"
"
\"
pools
\"
: [ {
\"
pool
\"
:
\"
192.0.3.1-192.0.3.10
\"
} ]
\n
"
" }
\n
"
" ]
\n
"
" } ]
\n
"
"}
\n
"
;
...
...
@@ -5235,15 +5247,16 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
CfgSharedNetworks4Ptr
cfg_net
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgSharedNetworks4
();
// T
here is expected one shared subnet
.
// T
wo shared networks are expected
.
ASSERT_TRUE
(
cfg_net
);
const
SharedNetwork4Collection
*
nets
=
cfg_net
->
getAll
();
ASSERT_TRUE
(
nets
);
ASSERT_EQ
(
1
,
nets
->
size
());
ASSERT_EQ
(
2
,
nets
->
size
());
SharedNetwork4Ptr
net
=
*
(
nets
->
begin
()
);
SharedNetwork4Ptr
net
=
nets
->
at
(
0
);
ASSERT_TRUE
(
net
);
// The first shared network has two subnets.
const
Subnet4Collection
*
subs
=
net
->
getAllSubnets
();
ASSERT_TRUE
(
subs
);
EXPECT_EQ
(
2
,
subs
->
size
());
...
...
@@ -5259,6 +5272,18 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
// from global scope to shared-network level and later again to
// subnet4 level.
checkSubnet
(
*
subs
,
"192.0.2.0/24"
,
100
,
2
,
4
);
// Ok, now check the second shared subnet.
net
=
nets
->
at
(
1
);
ASSERT_TRUE
(
net
);
subs
=
net
->
getAllSubnets
();
ASSERT_TRUE
(
subs
);
EXPECT_EQ
(
1
,
subs
->
size
());
// This subnet should derive its renew-timer from global scope.
checkSubnet
(
*
subs
,
"192.0.3.0/24"
,
1
,
2
,
4
);
}
...
...
src/bin/dhcp6/tests/config_parser_unittest.cc
View file @
ac3a0692
...
...
@@ -5556,6 +5556,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworks3subnets) {
// This test checks if parameters are derived properly:
// - global to shared network
// - shared network to subnet
// Also, it tests that more than one shared network can be defined.
TEST_F
(
Dhcp6ParserTest
,
sharedNetworksDerive
)
{
string
config
=
"{
\n
"
"
\"
renew-timer
\"
: 1,
\n
"
...
...
@@ -5576,7 +5577,16 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
"
\"
renew-timer
\"
: 100
\n
"
" }
\n
"
" ]
\n
"
" } ]
\n
"
" },
\n
"
"{ // second shared-network starts here
\n
"
"
\"
name
\"
:
\"
bar
\"
,
\n
"
"
\"
subnet6
\"
: [
\n
"
" {
\n
"
"
\"
subnet
\"
:
\"
2001:db3::/48
\"
,
\n
"
"
\"
pools
\"
: [ {
\"
pool
\"
:
\"
2001:db3::/64
\"
} ]
\n
"
" }
\n
"
" ]
\n
"
"} ]
\n
"
"}
\n
"
;
configure
(
config
,
CONTROL_RESULT_SUCCESS
,
""
);
...
...
@@ -5585,13 +5595,14 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
CfgSharedNetworks6Ptr
cfg_net
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgSharedNetworks6
();
// T
here is expect
ed
o
ne
shared subnet
.
// T
wo shar
ed ne
tworks are expeced
.
ASSERT_TRUE
(
cfg_net
);
const
SharedNetwork6Collection
*
nets
=
cfg_net
->
getAll
();
ASSERT_TRUE
(
nets
);
ASSERT_EQ
(
1
,
nets
->
size
());
ASSERT_EQ
(
2
,
nets
->
size
());
SharedNetwork6Ptr
net
=
*
(
nets
->
begin
());
// Let's check the first one.
SharedNetwork6Ptr
net
=
nets
->
at
(
0
);
ASSERT_TRUE
(
net
);
const
Subnet6Collection
*
subs
=
net
->
getAllSubnets
();
...
...
@@ -5609,6 +5620,17 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
// from global scope to shared-network level and later again to
// subnet6 level.
checkSubnet
(
*
subs
,
"2001:db2::/48"
,
100
,
2
,
3
,
4
);
// Ok, now check the second shared subnet.
net
=
nets
->
at
(
1
);
ASSERT_TRUE
(
net
);
subs
=
net
->
getAllSubnets
();
ASSERT_TRUE
(
subs
);
EXPECT_EQ
(
1
,
subs
->
size
());
// This subnet should derive its renew-timer from global scope.
checkSubnet
(
*
subs
,
"2001:db3::/48"
,
1
,
2
,
3
,
4
);
}
};
Write
Preview
Markdown
is supported
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