+2002. [bug] tmark
+ Fixed a bug in MySql config back end that caused it to
+ store unspecified, client-class valid and preferred life
+ time values as zero in the database.
+ (Gitlab #2344)
+
2001. [bug] razvan
Fixed a bug which causes client classes with empty test
expressions to fail class evaluation when those classes are
MySqlBinding::createString(client_class->getSname()),
MySqlBinding::createString(client_class->getFilename()),
MySqlBinding::createBool(client_class->getRequired()),
- MySqlBinding::createInteger<uint32_t>(client_class->getValid()),
- MySqlBinding::createInteger<uint32_t>(client_class->getValid().getMin()),
- MySqlBinding::createInteger<uint32_t>(client_class->getValid().getMax()),
+ createBinding(client_class->getValid()),
+ createMinBinding(client_class->getValid()),
+ createMaxBinding(client_class->getValid()),
MySqlBinding::createBool(depend_on_known),
(follow_class_name.empty() ? MySqlBinding::createNull() :
MySqlBinding::createString(follow_class_name)),
MySqlBinding::createString(client_class->getName()),
MySqlBinding::createString(client_class->getTest()),
MySqlBinding::createBool(client_class->getRequired()),
- MySqlBinding::createInteger<uint32_t>(client_class->getValid()),
- MySqlBinding::createInteger<uint32_t>(client_class->getValid().getMin()),
- MySqlBinding::createInteger<uint32_t>(client_class->getValid().getMax()),
+ createBinding(client_class->getValid()),
+ createMinBinding(client_class->getValid()),
+ createMaxBinding(client_class->getValid()),
MySqlBinding::createBool(depend_on_known),
(follow_class_name.empty() ? MySqlBinding::createNull() :
MySqlBinding::createString(follow_class_name)),
- MySqlBinding::createInteger<uint32_t>(client_class->getPreferred()),
- MySqlBinding::createInteger<uint32_t>(client_class->getPreferred().getMin()),
- MySqlBinding::createInteger<uint32_t>(client_class->getPreferred().getMax()),
+ createBinding(client_class->getPreferred()),
+ createMinBinding(client_class->getPreferred()),
+ createMaxBinding(client_class->getPreferred()),
MySqlBinding::createTimestamp(client_class->getModificationTime()),
};
ExpressionPtr match_expr = boost::make_shared<Expression>();
CfgOptionPtr cfg_option = boost::make_shared<CfgOption>();
auto class1 = boost::make_shared<ClientClassDef>("foo", match_expr, cfg_option);
+ class1->setCfgOptionDef(boost::make_shared<CfgOptionDef>());
class1->setRequired(true);
class1->setNextServer(IOAddress("1.2.3.4"));
class1->setSname("cool");
test_client_classes_.push_back(class1);
auto class2 = boost::make_shared<ClientClassDef>("bar", match_expr, cfg_option);
+ class2->setCfgOptionDef(boost::make_shared<CfgOptionDef>());
class2->setTest("member('foo')");
test_client_classes_.push_back(class2);
auto class3 = boost::make_shared<ClientClassDef>("foobar", match_expr, cfg_option);
+ class3->setCfgOptionDef(boost::make_shared<CfgOptionDef>());
class3->setTest("member('foo') and member('bar')");
test_client_classes_.push_back(class3);
}
client_classes = cbptr_->getAllClientClasses4(ServerSelector::ONE("server1"));
auto classes_list = client_classes.getClasses();
ASSERT_EQ(3, classes_list->size());
- EXPECT_EQ("foo", (*classes_list->begin())->getName());
- EXPECT_FALSE((*classes_list->begin())->getMatchExpr());
- EXPECT_EQ("bar", (*(classes_list->begin() + 1))->getName());
- EXPECT_FALSE((*(classes_list->begin() + 1))->getMatchExpr());
- EXPECT_EQ("foobar", (*(classes_list->begin() + 2))->getName());
- EXPECT_FALSE((*(classes_list->begin() + 2))->getMatchExpr());
+
+ auto fetched_class = classes_list->begin();
+ ASSERT_EQ("foo", (*fetched_class)->getName());
+ EXPECT_FALSE((*fetched_class)->getMatchExpr());
+ EXPECT_EQ(class1->toElement()->str(), (*fetched_class)->toElement()->str());
+
+ ++fetched_class;
+ ASSERT_EQ("bar", (*fetched_class)->getName());
+ EXPECT_FALSE((*fetched_class)->getMatchExpr());
+ EXPECT_EQ(class2->toElement()->str(), (*fetched_class)->toElement()->str());
+
+ ++fetched_class;
+ ASSERT_EQ("foobar", (*fetched_class)->getName());
+ EXPECT_FALSE((*fetched_class)->getMatchExpr());
+ EXPECT_EQ(class3->toElement()->str(), (*fetched_class)->toElement()->str());
// Move the third class between the first and second class.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateClientClass4(ServerSelector::ONE("server1"), class3, "foo"));
void
GenericConfigBackendDHCPv6Test::SetUp() {
+ CfgMgr::instance().setFamily(AF_INET6);
+
// Ensure we have the proper schema with no transient data.
createSchema();
ExpressionPtr match_expr = boost::make_shared<Expression>();
CfgOptionPtr cfg_option = boost::make_shared<CfgOption>();
auto class1 = boost::make_shared<ClientClassDef>("foo", match_expr, cfg_option);
+ class1->setCfgOptionDef(boost::make_shared<CfgOptionDef>());
class1->setRequired(true);
class1->setValid(Triplet<uint32_t>(30, 60, 90));
+ class1->setPreferred(Triplet<uint32_t>(25, 55, 85));
test_client_classes_.push_back(class1);
auto class2 = boost::make_shared<ClientClassDef>("bar", match_expr, cfg_option);
+ class2->setCfgOptionDef(boost::make_shared<CfgOptionDef>());
class2->setTest("member('foo')");
test_client_classes_.push_back(class2);
auto class3 = boost::make_shared<ClientClassDef>("foobar", match_expr, cfg_option);
+ class3->setCfgOptionDef(boost::make_shared<CfgOptionDef>());
class3->setTest("member('foo') and member('bar')");
test_client_classes_.push_back(class3);
}
client_classes = cbptr_->getAllClientClasses6(ServerSelector::ONE("server1"));
auto classes_list = client_classes.getClasses();
ASSERT_EQ(3, classes_list->size());
- EXPECT_EQ("foo", (*classes_list->begin())->getName());
- EXPECT_FALSE((*classes_list->begin())->getMatchExpr());
- EXPECT_EQ("bar", (*(classes_list->begin() + 1))->getName());
- EXPECT_FALSE((*(classes_list->begin() + 1))->getMatchExpr());
- EXPECT_EQ("foobar", (*(classes_list->begin() + 2))->getName());
- EXPECT_FALSE((*(classes_list->begin() + 2))->getMatchExpr());
+
+ auto fetched_class = classes_list->begin();
+ ASSERT_EQ("foo", (*fetched_class)->getName());
+ EXPECT_FALSE((*fetched_class)->getMatchExpr());
+ EXPECT_EQ(class1->toElement()->str(), (*fetched_class)->toElement()->str());
+
+ ++fetched_class;
+ ASSERT_EQ("bar", (*fetched_class)->getName());
+ EXPECT_FALSE((*fetched_class)->getMatchExpr());
+ EXPECT_EQ(class2->toElement()->str(), (*fetched_class)->toElement()->str());
+
+ ++fetched_class;
+ ASSERT_EQ("foobar", (*fetched_class)->getName());
+ EXPECT_FALSE((*fetched_class)->getMatchExpr());
+ EXPECT_EQ(class3->toElement()->str(), (*fetched_class)->toElement()->str());
// Move the third class between the first and second class.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateClientClass6(ServerSelector::ONE("server1"), class3, "foo"));