EXPECT_EQ(expected_code, rcode_);
}
+ /// @brief Returns an interface configuration used by the most of the
+ /// unit tests.
+ std::string genIfaceConfig() const {
+ return ("\"interface-config\": {"
+ " \"interfaces\": [ \"*\" ]"
+ "}");
+ }
+
/// @brief Create the simple configuration with single option.
///
/// This function allows to set one of the parameters that configure
std::string>& params)
{
std::ostringstream stream;
- stream << "{ \"interfaces\": [ \"*\" ],"
+ stream << "{ " << genIfaceConfig() << ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
/// test to make sure that contents of the database do not affect the
/// results of subsequent tests.
void resetConfiguration() {
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"hooks-libraries\": [ ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
ConstElementPtr status;
EXPECT_NO_THROW(status = configureDhcp6Server(srv_,
- Element::fromJSON("{ \"interfaces\": [ \"*\" ],"
+ Element::fromJSON("{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr status;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr x;
// Collection of four subnets for which ids should be autogenerated
// - ids are unspecified or set to 0.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
TEST_F(Dhcp6ParserTest, multipleSubnetsExplicitIDs) {
ConstElementPtr x;
// Four subnets with arbitrary subnet ids.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
TEST_F(Dhcp6ParserTest, multipleSubnetsOverlapingIDs) {
ConstElementPtr x;
// Four subnets, two of them have the same id.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr x;
// All four subnets
- string config4 = "{ \"interfaces\": [ \"*\" ],"
+ string config4 = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000 }";
// Three subnets (the last one removed)
- string config_first3 = "{ \"interfaces\": [ \"*\" ],"
+ string config_first3 = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000 }";
// Second subnet removed
- string config_second_removed = "{ \"interfaces\": [ \"*\" ],"
+ string config_second_removed = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr status;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// There should be at least one interface
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// There should be at least one interface
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr status;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// parameter.
TEST_F(Dhcp6ParserTest, interfaceIdGlobal) {
- const string config = "{ \"interfaces\": [ \"*\" ],"
+ const string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// The test defines 2 subnets, each with 2 pools.
TEST_F(Dhcp6ParserTest, multiplePools) {
// Collection with two subnets, each with 2 pools.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr status;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr x;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// Define a single valid pd pool.
string config =
- "{ \"interfaces\": [ \"*\" ],"
+ "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
};
string config =
- "{ \"interfaces\": [ \"*\" ],"
+ "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// Define a single valid pd pool.
string config =
- "{ \"interfaces\": [ \"*\" ],"
+ "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
const char *config[] = {
// No prefix.
- "{ \"interfaces\": [ \"*\" ],"
+ "{ \"interface-config\": { },"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000 }"
"] }",
// No prefix-len.
- "{ \"interfaces\": [ \"*\" ],"
+ "{ \"interface-config\": { },"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000 }"
"] }",
// No delegated-len.
- "{ \"interfaces\": [ \"*\" ],"
+ "{ \"interface-config\": { },"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000 }"
"] }",
// Delegated length is too short.
- "{ \"interfaces\": [ \"*\" ],"
+ "{ \"interface-config\": { },"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// configuration does not include options configuration.
TEST_F(Dhcp6ParserTest, optionDataDefaults) {
ConstElementPtr x;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000,"
"\"renew-timer\": 1000,"
// The definition is not required for the option that
// belongs to the 'dhcp6' option space as it is the
// standard option.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"valid-lifetime\": 4000,"
"\"rebind-timer\": 2000,"
// at the very end (when all other parameters are configured).
// Starting stage 1. Configure sub-options and their definitions.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"valid-lifetime\": 4000,"
"\"rebind-timer\": 2000,"
// the configuration from the stage 2 is repeated because BIND
// configuration manager sends whole configuration for the lists
// where at least one element is being modified or added.
- config = "{ \"interfaces\": [ \"*\" ],"
+ config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000,"
"\"renew-timer\": 1000,"
"\"option-data\": [ {"
// for multiple subnets.
TEST_F(Dhcp6ParserTest, optionDataInMultipleSubnets) {
ConstElementPtr x;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// This configuration string is to configure two options
// sharing the code 1 and belonging to the different vendor spaces.
// (different vendor-id values).
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"valid-lifetime\": 4000,"
"\"rebind-timer\": 2000,"
// This configuration string is to configure two options
// sharing the code 1 and belonging to the different vendor spaces.
// (different vendor-id values).
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"valid-lifetime\": 4000,"
"\"rebind-timer\": 2000,"
// In the first stahe we create definitions of suboptions
// that we will add to the base option.
// Let's create some dummy options: foo and foo2.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"valid-lifetime\": 4000,"
"\"rebind-timer\": 2000,"
// We add our dummy options to this option space and thus
// they should be included as sub-options in the 'vendor-opts'
// option.
- config = "{ \"interfaces\": [ \"*\" ],"
+ config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000,"
"\"renew-timer\": 1000,"
"\"option-data\": [ {"
// Create the first part of the configuration string.
string config =
- "{ \"interfaces\": [ \"*\" ],"
- "\"hooks-libraries\": [";
+ "{ \"interface-config\": { },"
+ "\"hooks-libraries\": [";
// Append the libraries (separated by commas if needed)
for (int i = 0; i < libraries.size(); ++i) {
ConstElementPtr status;
- string config = "{ \"interfaces\": [ \"eth0\" ],"
+ string config = "{ \"interface-config\": {"
+ " \"interfaces\": [ \"eth0\" ]"
+ "},"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// but also includes '*'. This keyword switches server into the
// mode when it listens on all interfaces regardless of what interface names
// were specified in the "interfaces" parameter.
- string config = "{ \"interfaces\": [ \"eth0\", \"eth1\", \"*\" ],"
+ string config = "{ \"interface-config\": {"
+ " \"interfaces\": [ \"eth0\", \"eth1\", \"*\" ]"
+ "},"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
ConstElementPtr status;
// A config with relay information.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ { "
// with defined client classes.
TEST_F(Dhcp6ParserTest, classifySubnets) {
ConstElementPtr x;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
// Verify that the convenience method agrees.
ASSERT_FALSE(CfgMgr::instance().ddnsEnabled());
- string config_str = "{ \"interfaces\": [ \"*\" ],"
+ string config_str = "{ " + genIfaceConfig() + ","
"\"preferred-lifetime\": 3000,"
"\"valid-lifetime\": 4000,"
"\"rebind-timer\": 2000, "
// Configuration string with an invalid D2 client config,
// "server-ip" is invalid.
- string config_str = "{ \"interfaces\": [ \"*\" ],"
+ string config_str = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ { "
// respective IPv6 subnets.
TEST_F(Dhcp6ParserTest, reservations) {
ConstElementPtr x;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ "
TEST_F(Dhcp6ParserTest, reservationBogus) {
// Case 1: misspelled "duid" parameter.
ConstElementPtr x;
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ "
checkResult(x, 1);
// Case 2: DUID and HW Address both specified.
- config = "{ \"interfaces\": [ \"*\" ],"
+ config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ "
checkResult(x, 1);
// Case 3: Neither ip address nor hostname specified.
- config = "{ \"interfaces\": [ \"*\" ],"
+ config = "{ " + genIfaceConfig() + ","
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ "
ConstElementPtr status;
EXPECT_NO_THROW(status = configureDhcp6Server(srv_,
- Element::fromJSON("{ \"interfaces\": [ \"*\" ],"
+ Element::fromJSON("{ " + genIfaceConfig() + ","
"\"mac-sources\": [ \"rfc6939\", \"rfc4649\", \"rfc4580\","
"\"client-link-addr-option\", \"remote-id\", \"subscriber-id\"],"
"\"preferred-lifetime\": 3000,"
ConstElementPtr status;
EXPECT_NO_THROW(status = configureDhcp6Server(srv_,
- Element::fromJSON("{ \"interfaces\": [ \"*\" ],"
+ Element::fromJSON("{ " + genIfaceConfig() + ","
"\"mac-sources\": [ ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
ConstElementPtr status;
EXPECT_NO_THROW(status = configureDhcp6Server(srv_,
- Element::fromJSON("{ \"interfaces\": [ \"*\" ],"
+ Element::fromJSON("{ " + genIfaceConfig() + ","
"\"mac-sources\": [ \"from-wire\" ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "