Skip to content
GitLab
Menu
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
1bd9870c
Commit
1bd9870c
authored
Jan 05, 2017
by
Marcin Siodelski
Browse files
[5030] Migrated Host Reservation related parsers to SimpleParser.
parent
6bb31a56
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/json_config_parser.cc
View file @
1bd9870c
...
...
@@ -152,9 +152,9 @@ public:
// Parse Host Reservations for this subnet if any.
ConstElementPtr
reservations
=
subnet
->
get
(
"reservations"
);
if
(
reservations
)
{
ParserPtr
parser
(
new
HostReservationsListParser
<
HostReservationP
arser
4
>
(
subnet_
->
getID
())
)
;
parser
->
build
(
reservations
);
HostReservationsListParser
<
HostReservationParser4
>
p
arser
(
subnet_
->
getID
());
parser
.
parse
(
reservations
);
}
}
...
...
@@ -446,8 +446,7 @@ DhcpConfigParser* createGlobalDhcp4ConfigParser(const std::string& config_id,
parser
=
new
ExpirationConfigParser
();
}
else
if
(
config_id
.
compare
(
"client-classes"
)
==
0
)
{
parser
=
new
ClientClassDefListParser
(
config_id
,
globalContext
());
}
else
if
(
config_id
.
compare
(
"host-reservation-identifiers"
)
==
0
)
{
parser
=
new
HostReservationIdsParser4
();
// host-reservation-identifiers have been converted to SimpleParser already.
}
else
{
isc_throw
(
DhcpConfigError
,
"unsupported global configuration parameter: "
...
...
@@ -637,6 +636,12 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
continue
;
}
if
(
config_pair
.
first
==
"host-reservation-identifiers"
)
{
HostReservationIdsParser4
parser
;
parser
.
parse
(
config_pair
.
second
);
continue
;
}
ParserPtr
parser
(
createGlobalDhcp4ConfigParser
(
config_pair
.
first
,
config_pair
.
second
));
LOG_DEBUG
(
dhcp4_logger
,
DBG_DHCP4_DETAIL
,
DHCP4_PARSER_CREATED
)
...
...
src/bin/dhcp6/json_config_parser.cc
View file @
1bd9870c
...
...
@@ -385,9 +385,9 @@ public:
// Parse Host Reservations for this subnet if any.
ConstElementPtr
reservations
=
subnet
->
get
(
"reservations"
);
if
(
reservations
)
{
ParserPtr
parser
(
new
HostReservationsListParser
<
HostReservationP
arser
6
>
(
subnet_
->
getID
())
)
;
parser
->
build
(
reservations
);
HostReservationsListParser
<
HostReservationParser6
>
p
arser
(
subnet_
->
getID
());
parser
.
parse
(
reservations
);
}
}
}
...
...
@@ -731,8 +731,7 @@ DhcpConfigParser* createGlobal6DhcpConfigParser(const std::string& config_id,
parser
=
new
ClientClassDefListParser
(
config_id
,
globalContext
());
}
else
if
(
config_id
.
compare
(
"server-id"
)
==
0
)
{
parser
=
new
DUIDConfigParser
();
}
else
if
(
config_id
.
compare
(
"host-reservation-identifiers"
)
==
0
)
{
parser
=
new
HostReservationIdsParser6
();
// host-reservation-identifiers have been converted to SimpleParser already.
}
else
{
isc_throw
(
DhcpConfigError
,
"unsupported global configuration parameter: "
...
...
@@ -911,6 +910,12 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
continue
;
}
if
(
config_pair
.
first
==
"host-reservation-identifiers"
)
{
HostReservationIdsParser6
parser
;
parser
.
parse
(
config_pair
.
second
);
continue
;
}
ParserPtr
parser
(
createGlobal6DhcpConfigParser
(
config_pair
.
first
,
config_pair
.
second
));
LOG_DEBUG
(
dhcp6_logger
,
DBG_DHCP6_DETAIL
,
DHCP6_PARSER_CREATED
)
...
...
src/lib/dhcpsrv/parsers/host_reservation_parser.cc
View file @
1bd9870c
// Copyright (C) 2014-201
6
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-201
7
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
...
...
@@ -95,11 +95,17 @@ namespace isc {
namespace
dhcp
{
HostReservationParser
::
HostReservationParser
(
const
SubnetID
&
subnet_id
)
:
DhcpConfigParser
(),
subnet_id_
(
subnet_id
)
{
:
SimpleParser
(),
subnet_id_
(
subnet_id
)
{
}
void
HostReservationParser
::
parse
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
parseInternal
(
reservation_data
);
}
void
HostReservationParser
::
build
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
HostReservationParser
::
parseInternal
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
std
::
string
identifier
;
std
::
string
identifier_name
;
std
::
string
hostname
;
...
...
@@ -185,8 +191,8 @@ HostReservationParser4::HostReservationParser4(const SubnetID& subnet_id)
}
void
HostReservationParser4
::
build
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
HostReservationParser
::
build
(
reservation_data
);
HostReservationParser4
::
parseInternal
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
HostReservationParser
::
parseInternal
(
reservation_data
);
host_
->
setIPv4SubnetID
(
subnet_id_
);
...
...
@@ -247,8 +253,8 @@ HostReservationParser6::HostReservationParser6(const SubnetID& subnet_id)
}
void
HostReservationParser6
::
build
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
HostReservationParser
::
build
(
reservation_data
);
HostReservationParser6
::
parseInternal
(
isc
::
data
::
ConstElementPtr
reservation_data
)
{
HostReservationParser
::
parseInternal
(
reservation_data
);
host_
->
setIPv6SubnetID
(
subnet_id_
);
...
...
@@ -359,7 +365,12 @@ HostReservationIdsParser::HostReservationIdsParser()
}
void
HostReservationIdsParser
::
build
(
isc
::
data
::
ConstElementPtr
ids_list
)
{
HostReservationIdsParser
::
parse
(
isc
::
data
::
ConstElementPtr
ids_list
)
{
parseInternal
(
ids_list
);
}
void
HostReservationIdsParser
::
parseInternal
(
isc
::
data
::
ConstElementPtr
ids_list
)
{
// Remove existing identifier types.
staging_cfg_
->
clearIdentifierTypes
();
...
...
src/lib/dhcpsrv/parsers/host_reservation_parser.h
View file @
1bd9870c
// Copyright (C) 2014-201
6
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-201
7
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
...
...
@@ -8,21 +8,24 @@
#define HOST_RESERVATION_PARSER_H
#include <cc/data.h>
#include <cc/simple_parser.h>
#include <dhcpsrv/host.h>
#include <dhcpsrv/parsers/dhcp_config_parser.h>
namespace
isc
{
namespace
dhcp
{
/// @brief Parser for a single host reservation entry.
class
HostReservationParser
:
public
DhcpConfig
Parser
{
class
HostReservationParser
:
public
isc
::
data
::
Simple
Parser
{
public:
/// @brief Constructor.
///
/// @param subnet_id Identifier of the subnet that the host is
/// connected to.
HostReservationParser
(
const
SubnetID
&
subnet_id
);
explicit
HostReservationParser
(
const
SubnetID
&
subnet_id
);
/// @brief Destructor.
virtual
~
HostReservationParser
()
{
}
/// @brief Parses a single entry for host reservation.
///
...
...
@@ -30,13 +33,21 @@ public:
/// reservation configuration.
///
/// @throw DhcpConfigError If the configuration is invalid.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
reservation_data
);
/// @brief Commit, unused.
virtual
void
commit
()
{
}
void
parse
(
isc
::
data
::
ConstElementPtr
reservation_data
);
protected:
/// @brief Parses a single entry for host reservation.
///
/// This method is called by @ref parse and it can be overriden in the
/// derived classes to provide class specific parsing logic.
///
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
///
/// @throw DhcpConfigError If the configuration is invalid.
virtual
void
parseInternal
(
isc
::
data
::
ConstElementPtr
reservation_data
);
/// @brief Inserts @c host_ object to the staging configuration.
///
/// This method should be called by derived classes to insert the fully
...
...
@@ -92,15 +103,15 @@ public:
/// connected to.
HostReservationParser4
(
const
SubnetID
&
subnet_id
);
protected:
/// @brief Parses a single host reservation for DHCPv4.
///
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
///
/// @throw DhcpConfigError If the configuration is invalid.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
reservation_data
);
protected:
virtual
void
parseInternal
(
isc
::
data
::
ConstElementPtr
reservation_data
);
/// @brief Returns set of the supported parameters for DHCPv4.
///
...
...
@@ -111,7 +122,6 @@ protected:
/// @return Set of supported parameter names.
virtual
const
std
::
set
<
std
::
string
>&
getSupportedParameters
(
const
bool
identifiers_only
)
const
;
};
/// @brief Parser for a single host reservation for DHCPv6.
...
...
@@ -124,15 +134,15 @@ public:
/// connected to.
HostReservationParser6
(
const
SubnetID
&
subnet_id
);
protected:
/// @brief Parses a single host reservation for DHCPv6.
///
/// @param reservation_data Data element holding map with a host
/// reservation configuration.
///
/// @throw DhcpConfigError If the configuration is invalid.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
reservation_data
);
protected:
virtual
void
parseInternal
(
isc
::
data
::
ConstElementPtr
reservation_data
);
/// @brief Returns set of the supported parameters for DHCPv6.
///
...
...
@@ -151,25 +161,36 @@ protected:
/// This is a parent parser class for parsing "host-reservation-identifiers"
/// global configuration parmeter. The DHCPv4 and DHCPv6 specific parsers
/// derive from this class.
class
HostReservationIdsParser
:
public
DhcpConfig
Parser
{
class
HostReservationIdsParser
:
public
isc
::
data
::
Simple
Parser
{
public:
/// @brief Constructor.
HostReservationIdsParser
();
/// @brief Destructor.
virtual
~
HostReservationIdsParser
()
{
}
/// @brief Parses a list of host identifiers.
///
/// @param ids_list Data element pointing to an ordered list of host
/// identifier names.
///
/// @throw DhcpConfigError If specified configuration is invalid.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
ids_list
);
/// @brief Commit, unused.
virtual
void
commit
()
{
}
void
parse
(
isc
::
data
::
ConstElementPtr
ids_list
);
protected:
/// @brief Parses a list of host identifiers.
///
/// This method is called by @ref parse and it can be overriden in the
/// derived classes to provide class specific parsing logic.
///
/// @param ids_list Data element pointing to an ordered list of host
/// identifier names.
///
/// @throw DhcpConfigError If specified configuration is invalid.
virtual
void
parseInternal
(
isc
::
data
::
ConstElementPtr
ids_list
);
/// @brief Checks if specified identifier name is supported in the
/// context of the parser.
///
...
...
src/lib/dhcpsrv/parsers/host_reservations_list_parser.h
View file @
1bd9870c
// Copyright (C) 2014-201
5
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-201
7
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
...
...
@@ -8,8 +8,8 @@
#define HOST_RESERVATIONS_LIST_PARSER_H
#include <cc/data.h>
#include <cc/simple_parser.h>
#include <dhcpsrv/subnet_id.h>
#include <dhcpsrv/parsers/dhcp_config_parser.h>
#include <boost/foreach.hpp>
namespace
isc
{
...
...
@@ -21,7 +21,7 @@ namespace dhcp {
/// parse individual reservations: @c HostReservationParser4 or
/// @c HostReservationParser6.
template
<
typename
HostReservationParserType
>
class
HostReservationsListParser
:
public
DhcpConfig
Parser
{
class
HostReservationsListParser
:
public
isc
::
data
::
Simple
Parser
{
public:
/// @brief Constructor.
...
...
@@ -39,16 +39,13 @@ public:
///
/// @throw DhcpConfigError If the configuration if any of the reservations
/// is invalid.
v
irtual
void
build
(
isc
::
data
::
ConstElementPtr
hr_list
)
{
v
oid
parse
(
isc
::
data
::
ConstElementPtr
hr_list
)
{
BOOST_FOREACH
(
data
::
ConstElementPtr
reservation
,
hr_list
->
listValue
())
{
ParserPtr
parser
(
new
HostReservationParserType
(
subnet_id_
)
)
;
parser
->
build
(
reservation
);
HostReservationParserType
parser
(
subnet_id_
);
parser
.
parse
(
reservation
);
}
}
/// @brief Commit, unused.
virtual
void
commit
()
{
}
private:
/// @brief Identifier of the subnet to whic the reservations belong.
...
...
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
View file @
1bd9870c
// Copyright (C) 2014-201
6
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-201
7
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
...
...
@@ -15,6 +15,7 @@
#include <dhcp/option6_addrlst.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/host.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dhcpsrv/parsers/host_reservation_parser.h>
#include <dhcpsrv/testutils/config_result_check.h>
#include <boost/pointer_cast.hpp>
...
...
@@ -116,7 +117,7 @@ protected:
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
ParserType
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
// Retrieve a host.
HostCollection
hosts
;
...
...
@@ -147,7 +148,7 @@ protected:
ElementPtr
config_element
=
Element
::
fromJSON
(
config
.
str
());
HostReservationParser4
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -172,7 +173,7 @@ protected:
void
testInvalidConfig
(
const
std
::
string
&
config
)
const
{
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
ParserType
parser
(
SubnetID
(
10
));
EXPECT_THROW
(
parser
.
build
(
config_element
),
DhcpConfigError
);
EXPECT_THROW
(
parser
.
parse
(
config_element
),
DhcpConfigError
);
}
/// @brief HW Address object used by tests.
...
...
@@ -286,7 +287,7 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser4
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -309,7 +310,7 @@ TEST_F(HostReservationParserTest, dhcp4ClientClasses) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser4
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -335,7 +336,7 @@ TEST_F(HostReservationParserTest, dhcp4MessageFields) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser4
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -422,7 +423,7 @@ TEST_F(HostReservationParserTest, noIPAddress) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser4
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -517,7 +518,7 @@ TEST_F(HostReservationParserTest, dhcp6HWaddr) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser6
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -564,7 +565,7 @@ TEST_F(HostReservationParserTest, dhcp6DUID) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser6
parser
(
SubnetID
(
12
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -623,7 +624,7 @@ TEST_F(HostReservationParserTest, dhcp6NoHostname) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser6
parser
(
SubnetID
(
12
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -659,7 +660,7 @@ TEST_F(HostReservationParserTest, dhcp6ClientClasses) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser6
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -770,7 +771,7 @@ TEST_F(HostReservationParserTest, options4) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser4
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -827,7 +828,7 @@ TEST_F(HostReservationParserTest, options6) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationParser6
parser
(
SubnetID
(
10
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
// One host should have been added to the configuration.
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
...
...
@@ -981,7 +982,7 @@ public:
void
testInvalidConfig
(
const
std
::
string
&
config
)
const
{
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
ParserType
parser
;
EXPECT_THROW
(
parser
.
build
(
config_element
),
DhcpConfigError
);
EXPECT_THROW
(
parser
.
parse
(
config_element
),
DhcpConfigError
);
}
};
...
...
@@ -995,7 +996,7 @@ TEST_F(HostReservationIdsParserTest, dhcp4Identifiers) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationIdsParser4
parser
;
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
ConstCfgHostOperationsPtr
cfg
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHostOperations4
();
...
...
@@ -1017,7 +1018,7 @@ TEST_F(HostReservationIdsParserTest, dhcp6Identifiers) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationIdsParser6
parser
;
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
ConstCfgHostOperationsPtr
cfg
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHostOperations6
();
...
...
@@ -1051,7 +1052,7 @@ TEST_F(HostReservationIdsParserTest, dhcp4AutoIdentifiers) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationIdsParser4
parser
;
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
ConstCfgHostOperationsPtr
cfg
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHostOperations4
();
...
...
@@ -1094,7 +1095,7 @@ TEST_F(HostReservationIdsParserTest, dhcp6AutoIdentifiers) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationIdsParser6
parser
;
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
ConstCfgHostOperationsPtr
cfg
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHostOperations6
();
...
...
src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc
View file @
1bd9870c
// Copyright (C) 2014-201
6
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-201
7
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
...
...
@@ -13,6 +13,7 @@
#include <dhcpsrv/cfg_hosts.h>
#include <dhcpsrv/host.h>
#include <dhcpsrv/subnet_id.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dhcpsrv/parsers/host_reservation_parser.h>
#include <dhcpsrv/parsers/host_reservations_list_parser.h>
#include <gtest/gtest.h>
...
...
@@ -86,7 +87,7 @@ TEST_F(HostReservationsListParserTest, ipv4Reservations) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
);
HostReservationsListParser
<
HostReservationParser4
>
parser
(
SubnetID
(
1
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -139,7 +140,7 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue4) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
.
str
());
HostReservationsListParser
<
HostReservationParser4
>
parser
(
SubnetID
(
1
));
EXPECT_THROW
(
parser
.
build
(
config_element
),
DhcpConfigError
);
EXPECT_THROW
(
parser
.
parse
(
config_element
),
DhcpConfigError
);
}
}
...
...
@@ -164,7 +165,7 @@ TEST_F(HostReservationsListParserTest, ipv6Reservations) {
// Parse configuration.
HostReservationsListParser
<
HostReservationParser6
>
parser
(
SubnetID
(
2
));
ASSERT_NO_THROW
(
parser
.
build
(
config_element
));
ASSERT_NO_THROW
(
parser
.
parse
(
config_element
));
CfgHostsPtr
cfg_hosts
=
CfgMgr
::
instance
().
getStagingCfg
()
->
getCfgHosts
();
HostCollection
hosts
;
...
...
@@ -231,7 +232,7 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue6) {
ElementPtr
config_element
=
Element
::
fromJSON
(
config
.
str
());
HostReservationsListParser
<
HostReservationParser6
>
parser
(
SubnetID
(
1
));
EXPECT_THROW
(
parser
.
build
(
config_element
),
DhcpConfigError
);
EXPECT_THROW
(
parser
.
parse
(
config_element
),
DhcpConfigError
);
}
}
...
...
Write
Preview
Supports
Markdown
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