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
317b6afe
Commit
317b6afe
authored
Apr 08, 2018
by
Francis Dupont
Browse files
[5374] Finished to address comments
parent
2de90c47
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/tests/shared_network_unittest.cc
View file @
317b6afe
// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017
-2018
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -1205,6 +1205,41 @@ public:
ASSERT_NO_FATAL_FAILURE
(
verifyAssignedStats
());
}
/// @brief Check precedence.
///
/// @param config the configuration.
/// @param ns_address expected name server address.
void
testPrecedence
(
const
std
::
string
&
config
,
const
std
::
string
&
ns_address
)
{
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers.
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration.
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA.
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response.
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option.
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
ns_address
,
addrs
[
0
].
toText
());
}
/// @brief Destructor.
virtual
~
Dhcpv4SharedNetworkTest
()
{
StatsMgr
::
instance
().
removeAll
();
...
...
@@ -2091,34 +2126,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceGlobal) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
"192.0.2.1"
,
addrs
[
0
].
toText
());
testPrecedence
(
config
,
"192.0.2.1"
);
}
// Verify option processing precedence
...
...
@@ -2173,34 +2181,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceClass) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
"192.0.2.2"
,
addrs
[
0
].
toText
());
testPrecedence
(
config
,
"192.0.2.2"
);
}
// Verify option processing precedence
...
...
@@ -2265,35 +2246,8 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceClasses) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
// Class order is the insert order
EXPECT_EQ
(
"192.0.2.2"
,
addrs
[
0
].
toText
()
);
testPrecedence
(
config
,
"192.0.2.2"
);
}
// Verify option processing precedence
...
...
@@ -2354,34 +2308,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceNetwork) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
"192.0.2.3"
,
addrs
[
0
].
toText
());
testPrecedence
(
config
,
"192.0.2.3"
);
}
// Verify option processing precedence
...
...
@@ -2448,34 +2375,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceSubnet) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
"192.0.2.4"
,
addrs
[
0
].
toText
());
testPrecedence
(
config
,
"192.0.2.4"
);
}
// Verify option processing precedence
...
...
@@ -2548,34 +2448,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedencePool) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
"192.0.2.5"
,
addrs
[
0
].
toText
());
testPrecedence
(
config
,
"192.0.2.5"
);
}
// Verify option processing precedence
...
...
@@ -2654,34 +2527,7 @@ TEST_F(Dhcpv4SharedNetworkTest, precedenceReservation) {
" ]"
"}"
;
// Create client and set MAC address to the one that has a reservation.
Dhcp4Client
client
(
Dhcp4Client
::
SELECTING
);
client
.
setIfaceName
(
"eth1"
);
client
.
setHWAddress
(
"aa:bb:cc:dd:ee:ff"
);
// Request domain-name-servers
client
.
requestOptions
(
DHO_DOMAIN_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform a DORA
doDORA
(
client
,
"192.0.2.28"
,
"192.0.2.28"
);
// Check response
Pkt4Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
EXPECT_EQ
(
DHCPACK
,
resp
->
getType
());
EXPECT_EQ
(
"192.0.2.28"
,
resp
->
getYiaddr
().
toText
());
// Check domain-name-servers option
OptionPtr
opt
=
resp
->
getOption
(
DHO_DOMAIN_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option4AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
"192.0.2.6"
,
addrs
[
0
].
toText
());
testPrecedence
(
config
,
"192.0.2.6"
);
}
}
// end of anonymous namespace
src/bin/dhcp6/tests/classify_unittests.cc
View file @
317b6afe
...
...
@@ -235,14 +235,18 @@ const char* CONFIGS[] = {
"
\"
subnet6
\"
: [ "
"{
\"
subnet
\"
:
\"
2001:db8::/32
\"
, "
"
\"
interface
\"
:
\"
eth1
\"
,"
"
\"
pools
\"
: [ "
" {
\"
pool
\"
:
\"
2001:db8:1::/48
\"
,"
"
\"
pd-pools
\"
: [ "
" {
\"
prefix
\"
:
\"
2001:db8:1::
\"
,"
"
\"
prefix-len
\"
: 48,
\"
delegated-len
\"
: 64,"
"
\"
client-class
\"
:
\"
server1_and_telephones
\"
},"
" {
\"
pool
\"
:
\"
2001:db8:2::/48
\"
,"
" {
\"
prefix
\"
:
\"
2001:db8:2::
\"
,"
"
\"
prefix-len
\"
: 48,
\"
delegated-len
\"
: 64,"
"
\"
client-class
\"
:
\"
server1_and_computers
\"
},"
" {
\"
pool
\"
:
\"
2001:db8:3::/48
\"
,"
" {
\"
prefix
\"
:
\"
2001:db8:3::
\"
,"
"
\"
prefix-len
\"
: 48,
\"
delegated-len
\"
: 64,"
"
\"
client-class
\"
:
\"
server2_and_telephones
\"
},"
" {
\"
pool
\"
:
\"
2001:db8:4::/48
\"
,"
" {
\"
prefix
\"
:
\"
2001:db8:4::
\"
,"
"
\"
prefix-len
\"
: 48,
\"
delegated-len
\"
: 64,"
"
\"
client-class
\"
:
\"
server2_and_computers
\"
} ]"
" } ],"
"
\"
valid-lifetime
\"
: 4000 }"
...
...
@@ -1721,4 +1725,204 @@ TEST_F(ClassifyTest, server1Telephone) {
EXPECT_EQ
(
"2001:db8:1:1::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server1 computer.
TEST_F
(
ClassifyTest
,
server1Computer
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestAddress
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"bar"
));
client
.
addExtraOption
(
hostname
);
// Add server1
client
.
addClass
(
"server1"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
1
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The address is from the second pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:1:2::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server2 telephone.
TEST_F
(
ClassifyTest
,
server2Telephone
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestAddress
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"foo"
));
client
.
addExtraOption
(
hostname
);
// Add server2
client
.
addClass
(
"server2"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
1
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The address is from the third pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:1:3::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server2 computer.
TEST_F
(
ClassifyTest
,
server2Computer
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestAddress
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"bar"
));
client
.
addExtraOption
(
hostname
);
// Add server2
client
.
addClass
(
"server2"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
1
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The address is from the forth pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:1:4::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server1 telephone
// with prefixes.
TEST_F
(
ClassifyTest
,
pDserver1Telephone
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestPrefix
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"foo"
));
client
.
addExtraOption
(
hostname
);
// Add server1
client
.
addClass
(
"server1"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
2
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The prefix is from the first pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:1::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server1 computer
// with prefix.
TEST_F
(
ClassifyTest
,
pDserver1Computer
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestPrefix
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"bar"
));
client
.
addExtraOption
(
hostname
);
// Add server1
client
.
addClass
(
"server1"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
2
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The prefix is from the second pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:2::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server2 telephone
// with prefixes.
TEST_F
(
ClassifyTest
,
pDserver2Telephone
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestPrefix
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"foo"
));
client
.
addExtraOption
(
hostname
);
// Add server2
client
.
addClass
(
"server2"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
2
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The prefix is from the third pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:3::"
,
lease_client
.
addr_
.
toText
());
}
// This test checks the complex membership from HA with server2 computer
// with prefix.
TEST_F
(
ClassifyTest
,
pDserver2Computer
)
{
// Create a client.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
ASSERT_NO_THROW
(
client
.
requestPrefix
(
0xabca0
));
// Add option.
OptionStringPtr
hostname
(
new
OptionString
(
Option
::
V6
,
1234
,
"bar"
));
client
.
addExtraOption
(
hostname
);
// Add server2
client
.
addClass
(
"server2"
);
// Load the config and perform a SARR
configure
(
CONFIGS
[
2
],
*
client
.
getServer
());
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// The prefix is from the forth pool.
ASSERT_EQ
(
1
,
client
.
getLeaseNum
());
Lease6
lease_client
=
client
.
getLease
(
0
);
EXPECT_EQ
(
"2001:db8:4::"
,
lease_client
.
addr_
.
toText
());
}
}
// end of anonymous namespace
src/bin/dhcp6/tests/shared_network_unittest.cc
View file @
317b6afe
// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017
-2018
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -1452,6 +1452,41 @@ public:
}
}
/// @brief Check precedence.
///
/// @param config the configuration.
/// @param ns_address expected name server address.
void
testPrecedence
(
const
std
::
string
&
config
,
const
std
::
string
&
ns_address
)
{
// Create client and set DUID to the one that has a reservation.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
client
.
setDUID
(
"00:03:00:01:aa:bb:cc:dd:ee:ff"
);
client
.
requestAddress
(
0xabca
,
IOAddress
(
"2001:db8:1::28"
));
// Request dns-servers.
client
.
requestOption
(
D6O_NAME_SERVERS
);
// Create server configuration.
configure
(
config
,
*
client
.
getServer
());
// Perform SARR.
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response.
EXPECT_EQ
(
1
,
client
.
getLeaseNum
());
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// Check dns-servers option.
OptionPtr
opt
=
resp
->
getOption
(
D6O_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option6AddrLstPtr
servers
=
boost
::
dynamic_pointer_cast
<
Option6AddrLst
>
(
opt
);
ASSERT_TRUE
(
servers
);
auto
addrs
=
servers
->
getAddresses
();
ASSERT_EQ
(
1
,
addrs
.
size
());
EXPECT_EQ
(
ns_address
,
addrs
[
0
].
toText
());
}
/// @brief Destructor.
virtual
~
Dhcpv6SharedNetworkTest
()
{
StatsMgr
::
instance
().
removeAll
();
...
...
@@ -2469,34 +2504,7 @@ TEST_F(Dhcpv6SharedNetworkTest, precedenceGlobal) {
" ]"
"}"
;
// Create client and set DUID to the one that has a reservation.
Dhcp6Client
client
;
client
.
setInterface
(
"eth1"
);
client
.
setDUID
(
"00:03:00:01:aa:bb:cc:dd:ee:ff"
);
client
.
requestAddress
(
0xabca
,
IOAddress
(
"2001:db8:1::28"
));
// Request dns-servers
client
.
requestOption
(
D6O_NAME_SERVERS
);
// Create server configuration
configure
(
config
,
*
client
.
getServer
());
// Perform SARR
ASSERT_NO_THROW
(
client
.
doSARR
());
// Check response
EXPECT_EQ
(
1
,
client
.
getLeaseNum
());
Pkt6Ptr
resp
=
client
.
getContext
().
response_
;
ASSERT_TRUE
(
resp
);
// Check dns-servers option
OptionPtr
opt
=
resp
->
getOption
(
D6O_NAME_SERVERS
);
ASSERT_TRUE
(
opt
);
Option6AddrLstPtr
servers
=