Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
97f4d442
Commit
97f4d442
authored
Feb 20, 2014
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3322] 2 unit-tests for CfgMgr added.
parent
1280b91e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
+73
-0
No files found.
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
View file @
97f4d442
...
...
@@ -472,6 +472,79 @@ TEST_F(CfgMgrTest, classifySubnet4) {
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"192.0.2.130"
),
classify_
));
}
// This test verifies if the configuration manager is able to hold v4 subnets
// with their relay address information and return proper subnets, based on
// those addresses.
TEST_F
(
CfgMgrTest
,
subnet4RelayOverride
)
{
CfgMgr
&
cfg_mgr
=
CfgMgr
::
instance
();
// Let's configure 3 subnets
Subnet4Ptr
subnet1
(
new
Subnet4
(
IOAddress
(
"192.0.2.0"
),
26
,
1
,
2
,
3
));
Subnet4Ptr
subnet2
(
new
Subnet4
(
IOAddress
(
"192.0.2.64"
),
26
,
1
,
2
,
3
));
Subnet4Ptr
subnet3
(
new
Subnet4
(
IOAddress
(
"192.0.2.128"
),
26
,
1
,
2
,
3
));
cfg_mgr
.
addSubnet4
(
subnet1
);
cfg_mgr
.
addSubnet4
(
subnet2
);
cfg_mgr
.
addSubnet4
(
subnet3
);
// Check that without relay-info specified, subnets are not selected
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.1"
),
classify_
,
true
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.2"
),
classify_
,
true
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.3"
),
classify_
,
true
));
// Now specify relay info
subnet1
->
setRelayInfo
(
IOAddress
(
"10.0.0.1"
));
subnet2
->
setRelayInfo
(
IOAddress
(
"10.0.0.2"
));
subnet3
->
setRelayInfo
(
IOAddress
(
"10.0.0.3"
));
// And try again. This time relay-info is there and should match.
EXPECT_EQ
(
subnet1
,
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.1"
),
classify_
,
true
));
EXPECT_EQ
(
subnet2
,
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.2"
),
classify_
,
true
));
EXPECT_EQ
(
subnet3
,
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.3"
),
classify_
,
true
));
// Finally, check that the relay works only if hint provided is relay address
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.1"
),
classify_
,
false
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.2"
),
classify_
,
false
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet4
(
IOAddress
(
"10.0.0.3"
),
classify_
,
false
));
}
// This test verifies if the configuration manager is able to hold v6 subnets
// with their relay address information and return proper subnets, based on
// those addresses.
TEST_F
(
CfgMgrTest
,
subnet6RelayOverride
)
{
CfgMgr
&
cfg_mgr
=
CfgMgr
::
instance
();
// Let's configure 3 subnets
Subnet6Ptr
subnet1
(
new
Subnet6
(
IOAddress
(
"2001:db8:1::"
),
48
,
1
,
2
,
3
,
4
));
Subnet6Ptr
subnet2
(
new
Subnet6
(
IOAddress
(
"2001:db8:2::"
),
48
,
1
,
2
,
3
,
4
));
Subnet6Ptr
subnet3
(
new
Subnet6
(
IOAddress
(
"2001:db8:3::"
),
48
,
1
,
2
,
3
,
4
));
cfg_mgr
.
addSubnet6
(
subnet1
);
cfg_mgr
.
addSubnet6
(
subnet2
);
cfg_mgr
.
addSubnet6
(
subnet3
);
// Check that without relay-info specified, subnets are not selected
EXPECT_FALSE
(
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::1"
),
classify_
,
true
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::2"
),
classify_
,
true
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::3"
),
classify_
,
true
));
// Now specify relay info
subnet1
->
setRelayInfo
(
IOAddress
(
"2001:db8:ff::1"
));
subnet2
->
setRelayInfo
(
IOAddress
(
"2001:db8:ff::2"
));
subnet3
->
setRelayInfo
(
IOAddress
(
"2001:db8:ff::3"
));
// And try again. This time relay-info is there and should match.
EXPECT_EQ
(
subnet1
,
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::1"
),
classify_
,
true
));
EXPECT_EQ
(
subnet2
,
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::2"
),
classify_
,
true
));
EXPECT_EQ
(
subnet3
,
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::3"
),
classify_
,
true
));
// Finally, check that the relay works only if hint provided is relay address
EXPECT_FALSE
(
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::1"
),
classify_
,
false
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::2"
),
classify_
,
false
));
EXPECT_FALSE
(
cfg_mgr
.
getSubnet6
(
IOAddress
(
"2001:db8:ff::3"
),
classify_
,
false
));
}
// This test verifies if the configuration manager is able to hold and return
// valid leases
TEST_F
(
CfgMgrTest
,
classifySubnet6
)
{
...
...
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