|
@@ -1,4 +1,4 @@
|
|
-// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
|
|
|
|
|
|
+// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
|
|
//
|
|
//
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
@@ -124,6 +124,14 @@ public:
|
|
unlink(UNLOAD_MARKER_FILE);
|
|
unlink(UNLOAD_MARKER_FILE);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ /// @brief Returns an interface configuration used by the most of the
|
|
|
|
+ /// unit tests.
|
|
|
|
+ std::string genIfaceConfig() const {
|
|
|
|
+ return ("\"interfaces-config\": {"
|
|
|
|
+ " \"interfaces\": [ \"*\" ]"
|
|
|
|
+ "}");
|
|
|
|
+ }
|
|
|
|
+
|
|
/// @brief Create the simple configuration with single option.
|
|
/// @brief Create the simple configuration with single option.
|
|
///
|
|
///
|
|
/// This function allows to set one of the parameters that configure
|
|
/// This function allows to set one of the parameters that configure
|
|
@@ -183,7 +191,7 @@ public:
|
|
/// describing an option.
|
|
/// describing an option.
|
|
std::string createConfigWithOption(const std::map<std::string, std::string>& params) {
|
|
std::string createConfigWithOption(const std::map<std::string, std::string>& params) {
|
|
std::ostringstream stream;
|
|
std::ostringstream stream;
|
|
- stream << "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ stream << "{ " << genIfaceConfig() << "," <<
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -446,7 +454,7 @@ public:
|
|
/// contents of the database do not affect result of
|
|
/// contents of the database do not affect result of
|
|
/// subsequent tests.
|
|
/// subsequent tests.
|
|
void resetConfiguration() {
|
|
void resetConfiguration() {
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"hooks-libraries\": [ ], "
|
|
"\"hooks-libraries\": [ ], "
|
|
"\"valid-lifetime\": 4000, "
|
|
"\"valid-lifetime\": 4000, "
|
|
"\"subnet4\": [ ], "
|
|
"\"subnet4\": [ ], "
|
|
@@ -500,7 +508,7 @@ TEST_F(Dhcp4ParserTest, emptySubnet) {
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_,
|
|
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_,
|
|
- Element::fromJSON("{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ Element::fromJSON("{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ ], "
|
|
"\"subnet4\": [ ], "
|
|
@@ -519,7 +527,7 @@ TEST_F(Dhcp4ParserTest, emptySubnet) {
|
|
TEST_F(Dhcp4ParserTest, unspecifiedRenewTimer) {
|
|
TEST_F(Dhcp4ParserTest, unspecifiedRenewTimer) {
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
|
|
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
|
|
@@ -553,7 +561,7 @@ TEST_F(Dhcp4ParserTest, unspecifiedRenewTimer) {
|
|
TEST_F(Dhcp4ParserTest, unspecifiedRebindTimer) {
|
|
TEST_F(Dhcp4ParserTest, unspecifiedRebindTimer) {
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
|
|
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
|
|
@@ -587,7 +595,7 @@ TEST_F(Dhcp4ParserTest, subnetGlobalDefaults) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -622,7 +630,7 @@ TEST_F(Dhcp4ParserTest, multipleSubnets) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
// Collection of four subnets for which subnet ids should be
|
|
// Collection of four subnets for which subnet ids should be
|
|
// autogenerated - ids are unspecified or set to 0.
|
|
// autogenerated - ids are unspecified or set to 0.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -676,7 +684,7 @@ TEST_F(Dhcp4ParserTest, multipleSubnets) {
|
|
TEST_F(Dhcp4ParserTest, multipleSubnetsExplicitIDs) {
|
|
TEST_F(Dhcp4ParserTest, multipleSubnetsExplicitIDs) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
// Four subnets with arbitrary subnet ids.
|
|
// Four subnets with arbitrary subnet ids.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -730,7 +738,7 @@ TEST_F(Dhcp4ParserTest, multipleSubnetsExplicitIDs) {
|
|
TEST_F(Dhcp4ParserTest, multipleSubnetsOverlapingIDs) {
|
|
TEST_F(Dhcp4ParserTest, multipleSubnetsOverlapingIDs) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
// Four subnets, two of them having the same id.
|
|
// Four subnets, two of them having the same id.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -768,7 +776,7 @@ TEST_F(Dhcp4ParserTest, reconfigureRemoveSubnet) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
|
|
|
|
// All four subnets
|
|
// All four subnets
|
|
- string config4 = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config4 = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -794,7 +802,7 @@ TEST_F(Dhcp4ParserTest, reconfigureRemoveSubnet) {
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
|
|
|
|
// Three subnets (the last one removed)
|
|
// Three subnets (the last one removed)
|
|
- string config_first3 = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_first3 = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -815,7 +823,7 @@ TEST_F(Dhcp4ParserTest, reconfigureRemoveSubnet) {
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
|
|
|
|
// Second subnet removed
|
|
// Second subnet removed
|
|
- string config_second_removed = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_second_removed = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -899,7 +907,7 @@ TEST_F(Dhcp4ParserTest, nextServerGlobal) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"next-server\": \"1.2.3.4\", "
|
|
"\"next-server\": \"1.2.3.4\", "
|
|
@@ -929,7 +937,7 @@ TEST_F(Dhcp4ParserTest, nextServerSubnet) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -960,7 +968,7 @@ TEST_F(Dhcp4ParserTest, nextServerNegative) {
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
// Config with junk instead of next-server address
|
|
// Config with junk instead of next-server address
|
|
- string config_bogus1 = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_bogus1 = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -972,7 +980,7 @@ TEST_F(Dhcp4ParserTest, nextServerNegative) {
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
|
|
|
|
// Config with IPv6 next server address
|
|
// Config with IPv6 next server address
|
|
- string config_bogus2 = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_bogus2 = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -984,7 +992,7 @@ TEST_F(Dhcp4ParserTest, nextServerNegative) {
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
|
|
|
|
// Config with empty next server address
|
|
// Config with empty next server address
|
|
- string config_bogus3 = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_bogus3 = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -1019,7 +1027,7 @@ TEST_F(Dhcp4ParserTest, nextServerOverride) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"next-server\": \"192.0.0.1\", "
|
|
"\"next-server\": \"192.0.0.1\", "
|
|
@@ -1049,7 +1057,7 @@ TEST_F(Dhcp4ParserTest, echoClientId) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config_false = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_false = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"echo-client-id\": false,"
|
|
"\"echo-client-id\": false,"
|
|
@@ -1058,7 +1066,7 @@ TEST_F(Dhcp4ParserTest, echoClientId) {
|
|
" \"subnet\": \"192.0.2.0/24\" } ],"
|
|
" \"subnet\": \"192.0.2.0/24\" } ],"
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
|
|
|
|
- string config_true = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_true = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"echo-client-id\": true,"
|
|
"\"echo-client-id\": true,"
|
|
@@ -1093,7 +1101,7 @@ TEST_F(Dhcp4ParserTest, subnetLocal) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -1124,7 +1132,7 @@ TEST_F(Dhcp4ParserTest, subnetLocal) {
|
|
TEST_F(Dhcp4ParserTest, multiplePools) {
|
|
TEST_F(Dhcp4ParserTest, multiplePools) {
|
|
|
|
|
|
// Collection with two subnets, each with 2 pools.
|
|
// Collection with two subnets, each with 2 pools.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -1183,7 +1191,7 @@ TEST_F(Dhcp4ParserTest, poolOutOfSubnet) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -1208,7 +1216,7 @@ TEST_F(Dhcp4ParserTest, poolPrefixLen) {
|
|
|
|
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -1785,7 +1793,7 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
|
|
// configuration does not include options configuration.
|
|
// configuration does not include options configuration.
|
|
TEST_F(Dhcp4ParserTest, optionDataDefaults) {
|
|
TEST_F(Dhcp4ParserTest, optionDataDefaults) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"option-data\": [ {"
|
|
"\"option-data\": [ {"
|
|
@@ -1857,7 +1865,7 @@ TEST_F(Dhcp4ParserTest, optionDataTwoSpaces) {
|
|
// The definition is not required for the option that
|
|
// The definition is not required for the option that
|
|
// belongs to the 'dhcp4' option space as it is the
|
|
// belongs to the 'dhcp4' option space as it is the
|
|
// standard option.
|
|
// standard option.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
@@ -1937,7 +1945,7 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) {
|
|
// at the very end (when all other parameters are configured).
|
|
// at the very end (when all other parameters are configured).
|
|
|
|
|
|
// Starting stage 1. Configure sub-options and their definitions.
|
|
// Starting stage 1. Configure sub-options and their definitions.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
@@ -1989,7 +1997,7 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) {
|
|
// the configuration from the stage 2 is repeated because BIND
|
|
// the configuration from the stage 2 is repeated because BIND
|
|
// configuration manager sends whole configuration for the lists
|
|
// configuration manager sends whole configuration for the lists
|
|
// where at least one element is being modified or added.
|
|
// where at least one element is being modified or added.
|
|
- config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"option-data\": [ {"
|
|
"\"option-data\": [ {"
|
|
@@ -2085,7 +2093,7 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) {
|
|
// option setting.
|
|
// option setting.
|
|
TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) {
|
|
TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"option-data\": [ {"
|
|
"\"option-data\": [ {"
|
|
@@ -2239,7 +2247,7 @@ TEST_F(Dhcp4ParserTest, optionDataBoolean) {
|
|
// for multiple subnets.
|
|
// for multiple subnets.
|
|
TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
|
|
TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -2513,7 +2521,7 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) {
|
|
// In the first stage we create definitions of suboptions
|
|
// In the first stage we create definitions of suboptions
|
|
// that we will add to the base option.
|
|
// that we will add to the base option.
|
|
// Let's create some dummy options: foo and foo2.
|
|
// Let's create some dummy options: foo and foo2.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
@@ -2569,7 +2577,7 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) {
|
|
// We add our dummy options to this option space and thus
|
|
// We add our dummy options to this option space and thus
|
|
// they should be included as sub-options in the 'vendor-opts'
|
|
// they should be included as sub-options in the 'vendor-opts'
|
|
// option.
|
|
// option.
|
|
- config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"option-data\": [ {"
|
|
"\"option-data\": [ {"
|
|
@@ -2676,7 +2684,7 @@ TEST_F(Dhcp4ParserTest, vendorOptionsHex) {
|
|
// This configuration string is to configure two options
|
|
// This configuration string is to configure two options
|
|
// sharing the code 1 and belonging to the different vendor spaces.
|
|
// sharing the code 1 and belonging to the different vendor spaces.
|
|
// (different vendor-id values).
|
|
// (different vendor-id values).
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
@@ -2735,7 +2743,7 @@ TEST_F(Dhcp4ParserTest, vendorOptionsCsv) {
|
|
// This configuration string is to configure two options
|
|
// This configuration string is to configure two options
|
|
// sharing the code 1 and belonging to the different vendor spaces.
|
|
// sharing the code 1 and belonging to the different vendor spaces.
|
|
// (different vendor-id values).
|
|
// (different vendor-id values).
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"valid-lifetime\": 4000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"rebind-timer\": 2000,"
|
|
"\"renew-timer\": 1000,"
|
|
"\"renew-timer\": 1000,"
|
|
@@ -2799,7 +2807,9 @@ buildHooksLibrariesConfig(const std::vector<std::string>& libraries) {
|
|
|
|
|
|
// Create the first part of the configuration string.
|
|
// Create the first part of the configuration string.
|
|
string config =
|
|
string config =
|
|
- "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ "{ \"interfaces-config\": {"
|
|
|
|
+ " \"interfaces\": [ \"*\" ]"
|
|
|
|
+ "},"
|
|
"\"hooks-libraries\": [";
|
|
"\"hooks-libraries\": [";
|
|
|
|
|
|
// Append the libraries (separated by commas if needed)
|
|
// Append the libraries (separated by commas if needed)
|
|
@@ -2939,7 +2949,9 @@ TEST_F(Dhcp4ParserTest, selectedInterfaces) {
|
|
IfaceMgrTestConfig test_config(true);
|
|
IfaceMgrTestConfig test_config(true);
|
|
|
|
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"eth0\", \"eth1\" ],"
|
|
|
|
|
|
+ string config = "{ \"interfaces-config\": {"
|
|
|
|
+ " \"interfaces\": [ \"eth0\", \"eth1\" ]"
|
|
|
|
+ "},"
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
@@ -2976,7 +2988,9 @@ TEST_F(Dhcp4ParserTest, allInterfaces) {
|
|
// but it also includes asterisk. The asterisk switches server into the
|
|
// but it also includes asterisk. The asterisk switches server into the
|
|
// mode when it listens on all interfaces regardless of what interface names
|
|
// mode when it listens on all interfaces regardless of what interface names
|
|
// were specified in the "interfaces" parameter.
|
|
// were specified in the "interfaces" parameter.
|
|
- string config = "{ \"interfaces\": [ \"eth0\", \"*\", \"eth1\" ],"
|
|
|
|
|
|
+ string config = "{ \"interfaces-config\": {"
|
|
|
|
+ " \"interfaces\": [ \"eth0\", \"*\", \"eth1\" ]"
|
|
|
|
+ "},"
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
@@ -3008,7 +3022,9 @@ TEST_F(Dhcp4ParserTest, selectedInterfacesAndAddresses) {
|
|
IfaceMgrTestConfig test_config(true);
|
|
IfaceMgrTestConfig test_config(true);
|
|
|
|
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"eth0/10.0.0.1\", \"eth1/192.0.2.3\" ],"
|
|
|
|
|
|
+ string config = "{ \"interfaces-config\": {"
|
|
|
|
+ " \"interfaces\": [ \"eth0/10.0.0.1\", \"eth1/192.0.2.3\" ]"
|
|
|
|
+ "},"
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"valid-lifetime\": 4000 }";
|
|
"\"valid-lifetime\": 4000 }";
|
|
@@ -3053,7 +3069,7 @@ TEST_F(Dhcp4ParserTest, d2ClientConfig) {
|
|
// Verify that the convenience method agrees.
|
|
// Verify that the convenience method agrees.
|
|
ASSERT_FALSE(CfgMgr::instance().ddnsEnabled());
|
|
ASSERT_FALSE(CfgMgr::instance().ddnsEnabled());
|
|
|
|
|
|
- string config_str = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_str = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -3118,7 +3134,7 @@ TEST_F(Dhcp4ParserTest, invalidD2ClientConfig) {
|
|
|
|
|
|
// Configuration string with an invalid D2 client config,
|
|
// Configuration string with an invalid D2 client config,
|
|
// "server-ip" is invalid.
|
|
// "server-ip" is invalid.
|
|
- string config_str = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config_str = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -3164,7 +3180,7 @@ TEST_F(Dhcp4ParserTest, subnetRelayInfo) {
|
|
ConstElementPtr status;
|
|
ConstElementPtr status;
|
|
|
|
|
|
// A config with relay information.
|
|
// A config with relay information.
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -3195,7 +3211,7 @@ TEST_F(Dhcp4ParserTest, subnetRelayInfo) {
|
|
// with defined client classes.
|
|
// with defined client classes.
|
|
TEST_F(Dhcp4ParserTest, classifySubnets) {
|
|
TEST_F(Dhcp4ParserTest, classifySubnets) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ { "
|
|
"\"subnet4\": [ { "
|
|
@@ -3281,7 +3297,7 @@ TEST_F(Dhcp4ParserTest, classifySubnets) {
|
|
// respective IPv4 subnets.
|
|
// respective IPv4 subnets.
|
|
TEST_F(Dhcp4ParserTest, reservations) {
|
|
TEST_F(Dhcp4ParserTest, reservations) {
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ "
|
|
"\"subnet4\": [ "
|
|
@@ -3401,7 +3417,7 @@ TEST_F(Dhcp4ParserTest, reservations) {
|
|
TEST_F(Dhcp4ParserTest, reservationBogus) {
|
|
TEST_F(Dhcp4ParserTest, reservationBogus) {
|
|
// Case 1: misspelled hw-address parameter.
|
|
// Case 1: misspelled hw-address parameter.
|
|
ConstElementPtr x;
|
|
ConstElementPtr x;
|
|
- string config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ string config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ "
|
|
"\"subnet4\": [ "
|
|
@@ -3427,7 +3443,7 @@ TEST_F(Dhcp4ParserTest, reservationBogus) {
|
|
checkResult(x, 1);
|
|
checkResult(x, 1);
|
|
|
|
|
|
// Case 2: DUID and HW Address both specified.
|
|
// Case 2: DUID and HW Address both specified.
|
|
- config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ "
|
|
"\"subnet4\": [ "
|
|
@@ -3455,7 +3471,7 @@ TEST_F(Dhcp4ParserTest, reservationBogus) {
|
|
checkResult(x, 1);
|
|
checkResult(x, 1);
|
|
|
|
|
|
// Case 3: Neither ip address nor hostname specified.
|
|
// Case 3: Neither ip address nor hostname specified.
|
|
- config = "{ \"interfaces\": [ \"*\" ],"
|
|
|
|
|
|
+ config = "{ " + genIfaceConfig() + "," +
|
|
"\"rebind-timer\": 2000, "
|
|
"\"rebind-timer\": 2000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"renew-timer\": 1000, "
|
|
"\"subnet4\": [ "
|
|
"\"subnet4\": [ "
|