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
de9b4b42
Commit
de9b4b42
authored
Oct 10, 2013
by
Tomek Mrugalski
🛰
Browse files
[3184] unit-test for echoing back RAI implemented
parent
1644a516
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
de9b4b42
...
...
@@ -1592,6 +1592,47 @@ TEST_F(Dhcpv4SrvTest, ServerID) {
EXPECT_EQ
(
srvid_text
,
text
);
}
// Checks if callouts installed on pkt4_receive are indeed called and the
// all necessary parameters are passed.
//
// Note that the test name does not follow test naming convention,
// but the proper hook name is "buffer4_receive".
TEST_F
(
Dhcpv4SrvTest
,
relayAgentInfoEcho
)
{
NakedDhcpv4Srv
srv
(
0
);
// Let's create a relayed DISCOVER. This particular relayed DISCOVER has
// added option 82 (relay agent info) with 3 suboptions. The server
// is supposed to echo it back in its response.
Pkt4Ptr
dis
=
captureRelayedDiscover
();
// Simulate that we have received that traffic
srv
.
fakeReceive
(
dis
);
// Server will now process to run its normal loop, but instead of calling
// IfaceMgr::receive4(), it will read all packets from the list set by
// fakeReceive()
// In particular, it should call registered buffer4_receive callback.
srv
.
run
();
// Check that the server did send a reposonse
ASSERT_EQ
(
1
,
srv
.
fake_sent_
.
size
());
// Make sure that we received a response
Pkt4Ptr
offer
=
srv
.
fake_sent_
.
front
();
ASSERT_TRUE
(
offer
);
// Get Relay Agent Info from query...
OptionPtr
rai_query
=
dis
->
getOption
(
DHO_DHCP_AGENT_OPTIONS
);
ASSERT_TRUE
(
rai_query
);
// Get Relay Agent Info from response...
OptionPtr
rai_response
=
offer
->
getOption
(
DHO_DHCP_AGENT_OPTIONS
);
ASSERT_TRUE
(
rai_response
);
EXPECT_TRUE
(
rai_response
->
equal
(
rai_query
));
}
/// @todo Implement tests for subnetSelect See tests in dhcp6_srv_unittest.cc:
/// selectSubnetAddr, selectSubnetIface, selectSubnetRelayLinkaddr,
/// selectSubnetRelayInterfaceId. Note that the concept of interface-id is not
...
...
@@ -2112,7 +2153,7 @@ vector<string> HooksDhcpv4SrvTest::callback_argument_names_;
// but the proper hook name is "buffer4_receive".
TEST_F
(
HooksDhcpv4SrvTest
,
Buffer4ReceiveSimple
)
{
// Install pkt
6
_receive_callout
// Install pkt
4
_receive_callout
EXPECT_NO_THROW
(
HooksManager
::
preCalloutsLibraryHandle
().
registerCallout
(
"buffer4_receive"
,
buffer4_receive_callout
));
...
...
@@ -2161,7 +2202,7 @@ TEST_F(HooksDhcpv4SrvTest, buffer4RreceiveValueChange) {
// In particular, it should call registered buffer4_receive callback.
srv_
->
run
();
// Check that the server did send a reposon
c
e
// Check that the server did send a reposon
s
e
ASSERT_EQ
(
1
,
srv_
->
fake_sent_
.
size
());
// Make sure that we received a response
...
...
@@ -2184,7 +2225,7 @@ TEST_F(HooksDhcpv4SrvTest, buffer4RreceiveValueChange) {
// (or rather option objects) in it.
TEST_F
(
HooksDhcpv4SrvTest
,
buffer4ReceiveSkip
)
{
// Install pkt
6
_receive_callout
// Install pkt
4
_receive_callout
EXPECT_NO_THROW
(
HooksManager
::
preCalloutsLibraryHandle
().
registerCallout
(
"buffer4_receive"
,
buffer4_receive_skip
));
...
...
@@ -2197,7 +2238,7 @@ TEST_F(HooksDhcpv4SrvTest, buffer4ReceiveSkip) {
// Server will now process to run its normal loop, but instead of calling
// IfaceMgr::receive6(), it will read all packets from the list set by
// fakeReceive()
// In particular, it should call registered pkt
6
_receive callback.
// In particular, it should call registered pkt
4
_receive callback.
srv_
->
run
();
// Check that the server dropped the packet and did not produce any response
...
...
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