// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
+#include <asiolink/addr_utilities.h>
#include <database/database_connection.h>
#include <database/db_exceptions.h>
#include <database/server.h>
ElementPtr user_context = Element::createMap();
user_context->set("foo", Element::create("bar"));
- Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 24, 30, 40, 60, 1024));
+ Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 24,
+ 30, 40, 60, 1024));
subnet->get4o6().setIface4o6("eth0");
subnet->get4o6().setInterfaceId(OptionPtr(new Option(Option::V6, D6O_INTERFACE_ID,
interface_id)));
subnet->setT2Percent(0.444);
subnet->setDdnsSendUpdates(false);
- Pool4Ptr pool1(new Pool4(IOAddress("192.0.2.10"), IOAddress("192.0.2.20")));
+ Pool4Ptr pool1(new Pool4(IOAddress("192.0.2.10"),
+ IOAddress("192.0.2.20")));
subnet->addPool(pool1);
- Pool4Ptr pool2(new Pool4(IOAddress("192.0.2.50"), IOAddress("192.0.2.60")));
+ Pool4Ptr pool2(new Pool4(IOAddress("192.0.2.50"),
+ IOAddress("192.0.2.60")));
subnet->addPool(pool2);
// Add several options to the subnet.
// Adding another subnet with the same subnet id to test
// cases that this second instance can override existing
// subnet instance.
- subnet.reset(new Subnet4(IOAddress("10.0.0.0"), 8, 20, 30, 40, 1024));
+ subnet.reset(new Subnet4(IOAddress("10.0.0.0"),
+ 8, 20, 30, 40, 1024));
- pool1.reset(new Pool4(IOAddress("10.0.0.10"), IOAddress("10.0.0.20")));
+ pool1.reset(new Pool4(IOAddress("10.0.0.10"),
+ IOAddress("10.0.0.20")));
subnet->addPool(pool1);
pool1->getCfgOption()->add(test_options_[3]->option_,
test_options_[4]->persistent_,
test_options_[4]->space_name_);
- pool2.reset(new Pool4(IOAddress("10.0.0.50"), IOAddress("10.0.0.60")));
+ pool2.reset(new Pool4(IOAddress("10.0.0.50"),
+ IOAddress("10.0.0.60")));
pool2->allowClientClass("work");
pool2->requireClientClass("required-class3");
test_subnets_.push_back(subnet);
// Add a subnet with all defaults.
- subnet.reset(new Subnet4(IOAddress("192.0.4.0"), 24, Triplet<uint32_t>(),
- Triplet<uint32_t>(), Triplet<uint32_t>(), 4096));
+ subnet.reset(new Subnet4(IOAddress("192.0.4.0"), 24,
+ Triplet<uint32_t>(), Triplet<uint32_t>(),
+ Triplet<uint32_t>(), 4096));
test_subnets_.push_back(subnet);
}
// Add several options to the shared network.
shared_network->getCfgOption()->add(test_options_[2]->option_,
- test_options_[2]->persistent_,
- test_options_[2]->space_name_);
+ test_options_[2]->persistent_,
+ test_options_[2]->space_name_);
shared_network->getCfgOption()->add(test_options_[3]->option_,
- test_options_[3]->persistent_,
- test_options_[3]->space_name_);
+ test_options_[3]->persistent_,
+ test_options_[3]->space_name_);
shared_network->getCfgOption()->add(test_options_[4]->option_,
- test_options_[4]->persistent_,
- test_options_[4]->space_name_);
+ test_options_[4]->persistent_,
+ test_options_[4]->space_name_);
test_networks_.push_back(shared_network);
desc.space_name_ = "isc";
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
- desc = createAddressOption<Option4AddrLst>(2, false, true, "10.0.0.5",
- "10.0.0.3", "10.0.3.4");
+ desc = createAddressOption<Option4AddrLst>(2, false, true,
+ "10.0.0.5",
+ "10.0.0.3",
+ "10.0.3.4");
desc.space_name_ = "isc";
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
DHCP4_OPTION_SPACE,
"ipv4-address", true)));
defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "isc", "empty")));
- defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "isc", "ipv4-address", true)));
+ defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "isc",
+ "ipv4-address", true)));
// Register option definitions.
LibDHCP::setRuntimeOptionDefs(defs);
}
}
-
void
GenericConfigBackendDHCPv4Test::testNewAuditEntry(const std::vector<ExpAuditEntry>& exp_entries,
const ServerSelector& server_selector) {
// Try to fetch the server which we expect to exist.
ASSERT_NO_THROW_LOG(returned_server = cbptr_->getServer4(ServerTag("server1")));
ASSERT_TRUE(returned_server);
- EXPECT_EQ("server1", returned_server->getServerTag().get());
+ EXPECT_EQ("server1", returned_server->getServerTagAsText());
EXPECT_EQ("this is server 1", returned_server->getDescription());
EXPECT_EQ(timestamps_["yesterday"], returned_server->getModificationTime());
// Create a global parameter (it should work with any object type).
StampedValuePtr global_parameter = StampedValue::create("global", "value");
- ASSERT_THROW(cbptr_->createUpdateGlobalParameter4(ServerSelector::ONE("server1"),
- global_parameter), NullKeyError);
+ // Try to insert it and associate with non-existing server.
+ std::string msg;
+ try {
+ cbptr_->createUpdateGlobalParameter4(ServerSelector::ONE("server1"),
+ global_parameter);
+ msg = "got no exception";
+ } catch (const NullKeyError& ex) {
+ msg = ex.what();
+ } catch (const std::exception&) {
+ msg = "got another exception";
+ }
+ EXPECT_EQ("server 'server1' does not exist", msg);
}
void
EXPECT_FALSE(cbptr_->getSubnet4(ServerSelector::ONE("server1"), subnet2->toText()));
// Update the subnet in the database (both use the same prefix).
- subnet2.reset(new Subnet4(IOAddress("192.0.3.0"), 24, 30, 40, 60, 8192));
+ subnet2.reset(new Subnet4(IOAddress("192.0.3.0"),
+ 24, 30, 40, 60, 8192));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet4(ServerSelector::ONE("server2"), subnet2));
// Fetch again and verify.
// Update the subnet when it conflicts same id and same prefix both
// with different subnets. This should throw.
// Subnets are 10.0.0.0/8 id 1024 and 192.0.3.0/24 id 8192
- subnet2.reset(new Subnet4(IOAddress("10.0.0.0"), 8, 30, 40, 60, 8192));
+ subnet2.reset(new Subnet4(IOAddress("10.0.0.0"),
+ 8, 30, 40, 60, 8192));
EXPECT_THROW(cbptr_->createUpdateSubnet4(ServerSelector::ONE("server2"), subnet2),
DuplicateEntry);
}
Subnet4Ptr returned_subnet = cbptr_->getSubnet4(ServerSelector::ALL(),
test_subnets_[0]->getID());
ASSERT_TRUE(returned_subnet);
+ ASSERT_EQ(1, returned_subnet->getServerTags().size());
+ EXPECT_EQ("all", returned_subnet->getServerTags().begin()->get());
// The easiest way to verify whether the returned subnet matches the inserted
// subnet is to convert both to text.
// Add the first subnet again. We should now have 4 options: 3 options from the
// newly added subnet and one option from the existing subnet.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet4(ServerSelector::ALL(), test_subnets_[0]));
- EXPECT_EQ(4, countRows("dhcp4_options"));
EXPECT_EQ(2, countRows("dhcp4_pool"));
+ EXPECT_EQ(4, countRows("dhcp4_options"));
// Delete the subnet including 3 options. The option from the other subnet should not
// be affected.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork4(ServerSelector::MULTIPLE({ "server1", "server2" }),
shared_network));
{
- SCOPED_TRACE("CREATE audit entry for shared network and MULTIPLE servers");
+ SCOPED_TRACE("UPDATE audit entry for shared network and MULTIPLE servers");
testNewAuditEntry("dhcp4_shared_network",
AuditEntry::ModificationType::UPDATE,
"shared network set");
// The last parameter indicates that we expect two new audit entries.
testNewAuditEntry("dhcp4_option_def",
AuditEntry::ModificationType::DELETE,
- "deleted all option definitions", ServerSelector::ALL(), 2);
+ "deleted all option definitions",
+ ServerSelector::ALL(), 2);
}
}
{
SCOPED_TRACE("verify created option");
- testOptionsEquivalent(*test_options_[0], *returned_opt_boot_file_name);
+ testOptionsEquivalent(*opt_boot_file_name,
+ *returned_opt_boot_file_name);
}
{
{
SCOPED_TRACE("verify updated option");
- testOptionsEquivalent(*opt_boot_file_name, *returned_opt_boot_file_name);
+ testOptionsEquivalent(*opt_boot_file_name,
+ *returned_opt_boot_file_name);
}
{
ASSERT_EQ(2, countRows("dhcp4_options"));
// Add an option into the pool.
- const PoolPtr pool = subnet->getPool(Lease::TYPE_V4, IOAddress("192.0.2.10"));
+ const PoolPtr pool = subnet->getPool(Lease::TYPE_V4,
+ IOAddress("192.0.2.10"));
ASSERT_TRUE(pool);
OptionDescriptorPtr opt_boot_file_name = test_options_[0];
cbptr_->createUpdateOption4(ServerSelector::ANY(),
std::string interface_id_text = "whale";
OptionBuffer interface_id(interface_id_text.begin(), interface_id_text.end());
OptionPtr opt_interface_id(new Option(Option::V6, D6O_INTERFACE_ID,
- interface_id));
+ interface_id));
ElementPtr user_context = Element::createMap();
user_context->set("foo", Element::create("bar"));
- Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8::"),
- 64, 30, 40, 50, 60, 1024));
+ Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8::"), 64,
+ 30, 40, 50, 60, 1024));
subnet->allowClientClass("home");
subnet->setIface("eth1");
subnet->setInterfaceId(opt_interface_id);
subnet->addPool(pool1);
pool1->getCfgOption()->add(test_options_[3]->option_,
- test_options_[3]->persistent_,
- test_options_[3]->space_name_);
+ test_options_[3]->persistent_,
+ test_options_[3]->space_name_);
pool1->getCfgOption()->add(test_options_[4]->option_,
test_options_[4]->persistent_,
shared_network->getCfgOption()->add(test_options_[0]->option_,
test_options_[0]->persistent_,
test_options_[0]->space_name_);
-
test_networks_.push_back(shared_network);
shared_network.reset(new SharedNetwork6("level3"));
user_context->set("foo", Element::create("bar"));
OptionDefinitionPtr option_def(new OptionDefinition("foo", 1234,
- DHCP6_OPTION_SPACE,
- "string",
- "espace"));
+ DHCP6_OPTION_SPACE,
+ "string",
+ "espace"));
test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("bar", 1234, DHCP6_OPTION_SPACE,
OptionDefSpaceContainer defs;
- OptionDescriptor desc = createOption<OptionString>(Option::V6, D6O_NEW_POSIX_TIMEZONE,
- true, false, "my-timezone");
+ OptionDescriptor desc =
+ createOption<OptionString>(Option::V6, D6O_NEW_POSIX_TIMEZONE,
+ true, false, "my-timezone");
desc.space_name_ = DHCP6_OPTION_SPACE;
desc.setContext(user_context);
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
- desc = createOption<OptionUint8>(Option::V6, D6O_PREFERENCE, false, true, 64);
+ desc = createOption<OptionUint8>(Option::V6, D6O_PREFERENCE,
+ false, true, 64);
desc.space_name_ = DHCP6_OPTION_SPACE;
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
desc.space_name_ = "vendor-encapsulated-options";
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
- desc = createAddressOption<Option6AddrLst>(1254, true, true, "2001:db8::3");
+ desc = createAddressOption<Option6AddrLst>(1254, true, true,
+ "2001:db8::3");
desc.space_name_ = DHCP6_OPTION_SPACE;
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
desc = createOption<OptionString>(Option::V6, D6O_NEW_POSIX_TIMEZONE,
true, false, "my-timezone-2");
-
desc.space_name_ = DHCP6_OPTION_SPACE;
desc.setContext(user_context);
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
desc = createOption<OptionString>(Option::V6, D6O_NEW_POSIX_TIMEZONE,
true, false, "my-timezone-3");
-
desc.space_name_ = DHCP6_OPTION_SPACE;
desc.setContext(user_context);
test_options_.push_back(OptionDescriptorPtr(new OptionDescriptor(desc)));
defs.addItem(OptionDefinitionPtr(new OptionDefinition("vendor-encapsulated-1", 1,
"vendor-encapsulated-options",
"uint32")));
-
defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1254", 1254,
DHCP6_OPTION_SPACE,
"ipv6-address", true)));
-
defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "isc", "empty")));
defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "isc",
"ipv6-address", true)));
- boost::posix_time::hours(1);
// One second after today.
timestamps_["after today"] = timestamps_["today"] + boost::posix_time::seconds(1);
-
// Yesterday.
timestamps_["yesterday"] = timestamps_["today"] - boost::posix_time::hours(24);
-
// One second after yesterday.
timestamps_["after yesterday"] = timestamps_["yesterday"] + boost::posix_time::seconds(1);
-
// Two days ago.
timestamps_["two days ago"] = timestamps_["today"] - boost::posix_time::hours(48);
-
// Tomorrow.
timestamps_["tomorrow"] = timestamps_["today"] + boost::posix_time::hours(24);
-
// One second after tomorrow.
timestamps_["after tomorrow"] = timestamps_["tomorrow"] + boost::posix_time::seconds(1);
}
const ServerSelector& server_selector,
const size_t new_entries_num,
const size_t max_tested_entries) {
-
// Get the server tag for which the entries are fetched.
std::string tag;
if (server_selector.getType() == ServerSelector::Type::ALL) {
// Server tag is 'all'.
tag = "all";
} else {
- auto tags = server_selector.getTags();
+ const auto& tags = server_selector.getTags();
// This test is not meant to handle multiple server tags all at once.
if (tags.size() > 1) {
ADD_FAILURE() << "Test error: do not use multiple server tags";
EXPECT_EQ("this is server 1 bis", returned_server->getDescription());
EXPECT_EQ(timestamps_["today"], returned_server->getModificationTime());
-
uint64_t servers_deleted = 0;
// Try to delete non-existing server.
// The number of deleted server should be equal to the number of
// inserted servers. The logical 'all' server should be excluded.
EXPECT_EQ(test_servers_.size() - 1, deleted_servers);
+
+ EXPECT_EQ(1, countRows("dhcp6_server"));
}
void
EXPECT_EQ("fish", returned_global_parameter->getValue());
EXPECT_TRUE(returned_global_parameter->getModificationTime() ==
global_parameter->getModificationTime());
+ ASSERT_EQ(1, returned_global_parameter->getServerTags().size());
+ EXPECT_EQ("all", returned_global_parameter->getServerTags().begin()->get());
{
SCOPED_TRACE("UPDATE audit entry for the global parameter");
// This time inserting the global parameters for the server1 and server2 should
// be successful.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateGlobalParameter6(ServerSelector::ONE("server1"),
- global_parameter1));
+ global_parameter1));
{
SCOPED_TRACE("Global parameter for server1 is set");
// The value of 3 means there should be 3 audit entries available for the
3, 1);
}
-
ASSERT_NO_THROW_LOG(cbptr_->createUpdateGlobalParameter6(ServerSelector::ONE("server2"),
- global_parameter2));
+ global_parameter2));
{
SCOPED_TRACE("Global parameter for server2 is set");
// Same as in case of the server2, there should be 3 audit entries of
// The last parameter is associated with all servers.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateGlobalParameter6(ServerSelector::ALL(),
- global_parameter3));
+ global_parameter3));
{
SCOPED_TRACE("Global parameter for all servers is set");
// There should be one new audit entry for all servers. It indicates
// Attempt to delete global parameter for server1.
uint64_t deleted_num = 0;
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteGlobalParameter6(ServerSelector::ONE("server1"),
- "global"));
+ "global"));
// No parameters should be deleted. In particular, the parameter for the logical
// server 'all' should not be deleted.
EXPECT_EQ(0, deleted_num);
// Deleting the existing value for server2 should succeed.
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteGlobalParameter6(ServerSelector::ONE("server2"),
- "global"));
+ "global"));
EXPECT_EQ(1, deleted_num);
// Create it again to test that deletion of all server removes this too.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateGlobalParameter6(ServerSelector::ONE("server2"),
- global_parameter2));
+ global_parameter2));
// Delete all servers, except 'all'.
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteAllServers6());
const auto& parameters_index = parameters.get<StampedValueNameIndexTag>();
- for (auto param = parameters_index.begin(); param != parameters_index.end();
- ++param) {
- ASSERT_EQ(1, (*param)->getServerTags().size());
- EXPECT_EQ("all", (*param)->getServerTags().begin()->get());
- }
-
// Verify their values.
EXPECT_EQ("value1", (*parameters_index.find("name1"))->getValue());
EXPECT_EQ(65, (*parameters_index.find("name2"))->getIntegerValue());
EXPECT_TRUE((*parameters_index.find("name4"))->getBoolValue());
EXPECT_EQ(1.65, (*parameters_index.find("name5"))->getDoubleValue());
+ for (auto param = parameters_index.begin(); param != parameters_index.end();
+ ++param) {
+ ASSERT_EQ(1, (*param)->getServerTags().size());
+ EXPECT_EQ("all", (*param)->getServerTags().begin()->get());
+ }
+
// Should be able to fetch these parameters when explicitly providing
// the server tag.
parameters = cbptr_->getAllGlobalParameters6(ServerSelector::ONE("server1"));
void
GenericConfigBackendDHCPv6Test::createUpdateSubnet6SelectorsTest() {
- ASSERT_NO_THROW(cbptr_->createUpdateServer6(test_servers_[0]));
- ASSERT_NO_THROW(cbptr_->createUpdateServer6(test_servers_[2]));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateServer6(test_servers_[0]));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateServer6(test_servers_[2]));
// Supported selectors.
Subnet6Ptr subnet = test_subnets_[0];
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(),
- subnet));
+ subnet));
subnet = test_subnets_[2];
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server1"),
- subnet));
+ subnet));
subnet = test_subnets_[3];
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- subnet));
+ subnet));
// Not supported server selectors.
EXPECT_THROW(cbptr_->createUpdateSubnet6(ServerSelector::ANY(), subnet),
// The subnet shouldn't have been added, even though one of the servers exists.
Subnet6Ptr returned_subnet;
- ASSERT_NO_THROW(returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server2"),
- subnet2->getID()));
+ ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server2"),
+ subnet2->getID()));
EXPECT_FALSE(returned_subnet);
// Insert two subnets, one for all servers and one for server2.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet));
{
- SCOPED_TRACE("CREATE audit entry for the subnet");
+ SCOPED_TRACE("A. CREATE audit entry for the subnet");
testNewAuditEntry("dhcp6_subnet",
AuditEntry::ModificationType::CREATE,
"subnet set");
}
-
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server2"), subnet2));
{
- SCOPED_TRACE("CREATE audit entry for the subnet");
+ SCOPED_TRACE("B. CREATE audit entry for the subnet");
testNewAuditEntry("dhcp6_subnet",
AuditEntry::ModificationType::CREATE,
"subnet set", ServerSelector::ONE("subnet2"),
// Test fetching subnet by id.
Subnet6Ptr returned_subnet;
- ASSERT_NO_THROW(returned_subnet = cbptr_->getSubnet6(server_selector, subnet->getID()));
+ ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(server_selector, subnet->getID()));
ASSERT_TRUE(returned_subnet);
ASSERT_EQ(1, returned_subnet->getServerTags().size());
EXPECT_TRUE(returned_subnet->hasServerTag(ServerTag(expected_tag)));
- EXPECT_EQ(subnet->toElement()->str(), returned_subnet->toElement()->str());
+ ASSERT_EQ(subnet->toElement()->str(), returned_subnet->toElement()->str());
// Test fetching subnet by prefix.
- ASSERT_NO_THROW(returned_subnet = cbptr_->getSubnet6(server_selector,
- subnet->toText()));
+ ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(server_selector,
+ subnet->toText()));
ASSERT_TRUE(returned_subnet);
ASSERT_EQ(1, returned_subnet->getServerTags().size());
subnet = test_subnets_[1];
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet));
{
- SCOPED_TRACE("CREATE audit entry for the subnet");
+ SCOPED_TRACE("C. CREATE audit entry for the subnet");
testNewAuditEntry("dhcp6_subnet",
AuditEntry::ModificationType::UPDATE,
"subnet set");
// Update the subnet in the database (both use the same prefix).
subnet2.reset(new Subnet6(IOAddress("2001:db8:3::"),
64, 30, 40, 50, 80, 8192));
- ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server2"), subnet2));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server2"), subnet2));
// Fetch again and verify.
returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server2"), subnet2->toText());
// Subnets are 2001:db8:1::/48 id 1024 and 2001:db8:3::/64 id 8192
subnet2.reset(new Subnet6(IOAddress("2001:db8:1::"),
48, 30, 40, 50, 80, 8192));
- EXPECT_THROW(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server2"), subnet2),
+ EXPECT_THROW(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server2"), subnet2),
DuplicateEntry);
}
// Need to add the shared network to the database because otherwise
// the subnet foreign key would fail.
- cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), shared_network);
- cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet);
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), shared_network));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet));
// Fetch this subnet by subnet identifier.
Subnet6Ptr returned_subnet = cbptr_->getSubnet6(ServerSelector::ALL(),
// The easiest way to verify whether the returned subnet matches the inserted
// subnet is to convert both to text.
EXPECT_EQ(subnet->toElement()->str(), returned_subnet->toElement()->str());
-
}
void
shared_network->add(subnet);
// Store shared network in the database.
- cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- shared_network);
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
+ shared_network));
// Store subnet associated with the shared network in the database.
- cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet);
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet));
// Fetch this subnet by subnet identifier.
Subnet6Ptr returned_subnet = cbptr_->getSubnet6(ServerSelector::ALL(),
GenericConfigBackendDHCPv6Test::getSubnet6ByPrefixTest() {
// Insert subnet to the database.
Subnet6Ptr subnet = test_subnets_[0];
- cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet);
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet));
// Fetch the subnet by prefix.
Subnet6Ptr returned_subnet = cbptr_->getSubnet6(ServerSelector::ALL(),
// See if the subnets are returned ok.
auto subnet_it = subnets.begin();
for (auto i = 0; i < subnets.size(); ++i, ++subnet_it) {
- EXPECT_EQ(test_subnets_[i + 1]->toElement()->str(),
- (*subnet_it)->toElement()->str());
ASSERT_EQ(1, (*subnet_it)->getServerTags().size());
EXPECT_EQ("all", (*subnet_it)->getServerTags().begin()->get());
+ EXPECT_EQ(test_subnets_[i + 1]->toElement()->str(),
+ (*subnet_it)->toElement()->str());
}
- // Attempt to remove the non existing subnet should return 0.
+ // Attempt to remove the non existing subnet should return 0.
EXPECT_EQ(0, cbptr_->deleteSubnet6(ServerSelector::ALL(), 22));
EXPECT_EQ(0, cbptr_->deleteSubnet6(ServerSelector::ALL(),
"2001:db8:555::/64"));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateServer6(test_servers_[2]));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(),
- subnet1));
+ subnet1));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server1"),
- subnet2));
+ subnet2));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- subnet3));
+ subnet3));
Subnet6Collection subnets;
EXPECT_FALSE(returned_subnet->hasServerTag(ServerTag("server2")));
}
+void
+GenericConfigBackendDHCPv6Test::getModifiedSubnets6SelectorsTest() {
+ // Supported selectors.
+ ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::UNASSIGNED(),
+ timestamps_["yesterday"]));
+ ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::ALL(),
+ timestamps_["yesterday"]));
+ ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::ONE("server1"),
+ timestamps_["yesterday"]));
+ ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::MULTIPLE({ "server1", "server2" }),
+ timestamps_["yesterday"]));
+
+ // Not supported selectors.
+ EXPECT_THROW(cbptr_->getModifiedSubnets6(ServerSelector::ANY(),
+ timestamps_["yesterday"]),
+ isc::InvalidOperation);
+}
+
void
GenericConfigBackendDHCPv6Test::deleteSubnet6Test() {
// Create two servers in the database.
// Trying to fetch the subnet by server tag should return no result.
Subnet6Ptr returned_subnet;
ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server1"),
- subnet->getID()));
+ subnet->getID()));
EXPECT_FALSE(returned_subnet);
// The same if we use other calls.
ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server1"),
- subnet->toText()));
+ subnet->toText()));
EXPECT_FALSE(returned_subnet);
Subnet6Collection returned_subnets;
// We should get the subnet if we ask for unassigned.
ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::UNASSIGNED(),
- subnet->getID()));
+ subnet->getID()));
ASSERT_TRUE(returned_subnet);
ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::UNASSIGNED(),
- subnet->toText()));
+ subnet->toText()));
ASSERT_TRUE(returned_subnet);
// Also if we ask for all unassigned subnets it should be returned.
// If we ask for any subnet by subnet id, it should be returned too.
ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::ANY(),
- subnet->getID()));
+ subnet->getID()));
ASSERT_TRUE(returned_subnet);
ASSERT_NO_THROW_LOG(returned_subnet = cbptr_->getSubnet6(ServerSelector::ANY(),
- subnet->toText()));
+ subnet->toText()));
ASSERT_TRUE(returned_subnet);
// Deleting the subnet with the mismatched server tag should not affect our
ASSERT_TRUE(subnets.empty());
}
-void
-GenericConfigBackendDHCPv6Test::getModifiedSubnets6SelectorsTest() {
- // Supported selectors.
- ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::UNASSIGNED(),
- timestamps_["yesterday"]));
- ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::ALL(),
- timestamps_["yesterday"]));
- ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::ONE("server1"),
- timestamps_["yesterday"]));
- ASSERT_NO_THROW_LOG(cbptr_->getModifiedSubnets6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- timestamps_["yesterday"]));
-
- // Not supported selectors.
- EXPECT_THROW(cbptr_->getModifiedSubnets6(ServerSelector::ANY(),
- timestamps_["yesterday"]),
- isc::InvalidOperation);
-}
-
void
GenericConfigBackendDHCPv6Test::subnetLifetimeTest() {
// Insert new subnet with unspecified valid lifetime
EXPECT_TRUE(isEquivalent(test_subnets_[1]->toElement(),
(*subnets.begin())->toElement()));
+ // Check server tag
+ ASSERT_EQ(1, (*subnets.begin())->getServerTags().size());
+ EXPECT_EQ("all", (*subnets.begin())->getServerTags().begin()->get());
+
// Fetch all subnets belonging to shared network level2.
subnets = cbptr_->getSharedNetworkSubnets6(ServerSelector::ALL(), "level2");
ASSERT_EQ(2, subnets.size());
// Add the subnet with two address pools and two prefix delegation
// pools.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(),
- test_subnets_[0]));
+ test_subnets_[0]));
// Make sure that the pools have been added to the database.
EXPECT_EQ(2, countRows("dhcp6_pool"));
EXPECT_EQ(2, countRows("dhcp6_pd_pool"));
// Insert two shared networks, one for all servers, and one for server2.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- shared_network));
+ shared_network));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ONE("server2"),
- shared_network2));
+ shared_network2));
// We are not going to support selection of a single entry for multiple servers.
EXPECT_THROW(cbptr_->getSharedNetwork6(ServerSelector::MULTIPLE({ "server1", "server2" }),
const std::string& expected_tag = ServerTag::ALL) {
SCOPED_TRACE(test_case_name);
SharedNetwork6Ptr network;
- ASSERT_NO_THROW(network = cbptr_->getSharedNetwork6(server_selector,
- shared_network->getName()));
+ ASSERT_NO_THROW_LOG(network = cbptr_->getSharedNetwork6(server_selector,
+ shared_network->getName()));
ASSERT_TRUE(network);
EXPECT_GT(network->getId(), 0);
// Update shared network in the database.
shared_network = test_networks_[1];
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- shared_network));
+ shared_network));
{
SCOPED_TRACE("testing various server selectors after update");
}
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- shared_network));
+ shared_network));
{
SCOPED_TRACE("CREATE audit entry for shared network and ALL servers");
testNewAuditEntry("dhcp6_shared_network",
}
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- shared_network));
+ shared_network));
{
SCOPED_TRACE("UPDATE audit entry for shared network and MULTIPLE servers");
testNewAuditEntry("dhcp6_shared_network",
}
SharedNetwork6Ptr network;
- ASSERT_NO_THROW(network = cbptr_->getSharedNetwork6(ServerSelector::ANY(),
- shared_network->getName()));
+ ASSERT_NO_THROW_LOG(network = cbptr_->getSharedNetwork6(ServerSelector::ANY(),
+ shared_network->getName()));
ASSERT_TRUE(network);
EXPECT_TRUE(network->hasServerTag(ServerTag("server1")));
EXPECT_TRUE(network->hasServerTag(ServerTag("server2")));
void
GenericConfigBackendDHCPv6Test::createUpdateSharedNetwork6SelectorsTest() {
- ASSERT_NO_THROW(cbptr_->createUpdateServer6(test_servers_[0]));
- ASSERT_NO_THROW(cbptr_->createUpdateServer6(test_servers_[2]));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateServer6(test_servers_[0]));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateServer6(test_servers_[2]));
// Supported selectors.
SharedNetwork6Ptr shared_network(new SharedNetwork6("all"));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- shared_network));
+ shared_network));
shared_network.reset(new SharedNetwork6("one"));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ONE("server1"),
- shared_network));
+ shared_network));
shared_network.reset(new SharedNetwork6("multiple"));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- shared_network));
+ shared_network));
// Not supported server selectors.
EXPECT_THROW(cbptr_->createUpdateSharedNetwork6(ServerSelector::ANY(), shared_network),
// And after the shared network itself.
EXPECT_EQ(1, cbptr_->deleteSharedNetwork6(ServerSelector::ALL(),
test_networks_[1]->getName()));
+
networks = cbptr_->getAllSharedNetworks6(ServerSelector::ALL());
ASSERT_EQ(test_networks_.size() - 2, networks.size());
ASSERT_NO_THROW_LOG(cbptr_->createUpdateServer6(test_servers_[2]));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- shared_network1));
+ shared_network1));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ONE("server1"),
- shared_network2));
+ shared_network2));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- shared_network3));
+ shared_network3));
SharedNetwork6Collection networks;
}
// Fetch shared networks with timestamp later than today. Only one
- // shared network should be returned.
+ // shared network should be returned.
SharedNetwork6Collection
networks = cbptr_->getModifiedSharedNetworks6(ServerSelector::ALL(),
timestamps_["after today"]);
// Fetch shared networks with timestamp later than yesterday. We
// should get two shared networks.
networks = cbptr_->getModifiedSharedNetworks6(ServerSelector::ALL(),
- timestamps_["after yesterday"]);
+ timestamps_["after yesterday"]);
ASSERT_EQ(2, networks.size());
// Fetch shared networks with timestamp later than tomorrow. Nothing
GenericConfigBackendDHCPv6Test::getModifiedSharedNetworks6SelectorsTest() {
// Supported selectors.
ASSERT_NO_THROW_LOG(cbptr_->getModifiedSharedNetworks6(ServerSelector::UNASSIGNED(),
- timestamps_["yesterday"]));
+ timestamps_["yesterday"]));
ASSERT_NO_THROW_LOG(cbptr_->getModifiedSharedNetworks6(ServerSelector::ALL(),
- timestamps_["yesterday"]));
+ timestamps_["yesterday"]));
ASSERT_NO_THROW_LOG(cbptr_->getModifiedSharedNetworks6(ServerSelector::ONE("server1"),
- timestamps_["yesterday"]));
+ timestamps_["yesterday"]));
ASSERT_NO_THROW_LOG(cbptr_->getModifiedSharedNetworks6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- timestamps_["yesterday"]));
+ timestamps_["yesterday"]));
// Not supported selectors.
EXPECT_THROW(cbptr_->getModifiedSharedNetworks6(ServerSelector::ANY(),
auto shared_network2 = test_networks_[2];
auto shared_network3 = test_networks_[3];
- // Insert two shared networks, one for all servers, and one for server2.
+ // Insert three shared networks, one for all servers, one for server2 and
+ // one for two servers: server1 and server2.
ASSERT_NO_THROW_LOG(
cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), shared_network1)
);
// Not supported selectors.
EXPECT_THROW(cbptr_->deleteSharedNetwork6(ServerSelector::MULTIPLE({ "server1", "server2" }),
- "level1"),
+ "level1"),
isc::InvalidOperation);
// Not implemented selectors.
// Trying to fetch this shared network by server tag should return no result.
SharedNetwork6Ptr returned_network;
ASSERT_NO_THROW_LOG(returned_network = cbptr_->getSharedNetwork6(ServerSelector::ONE("server1"),
- "level1"));
+ "level1"));
EXPECT_FALSE(returned_network);
// The same if we use other calls.
// We should get the shared network if we ask for unassigned.
ASSERT_NO_THROW_LOG(returned_network = cbptr_->getSharedNetwork6(ServerSelector::UNASSIGNED(),
- "level1"));
+ "level1"));
ASSERT_TRUE(returned_network);
// Also if we ask for all unassigned networks it should be returned.
// If we ask for any network by name, it should be returned too.
ASSERT_NO_THROW_LOG(returned_network = cbptr_->getSharedNetwork6(ServerSelector::ANY(),
- "level1"));
+ "level1"));
ASSERT_TRUE(returned_network);
// Deleting a shared network with the mismatched server tag should not affect
);
EXPECT_EQ(1, deleted_count);
- // We can delete all second networks using UNASSIGNED selector.
+ // We can delete all networks using UNASSIGNED selector.
ASSERT_NO_THROW_LOG(
deleted_count = cbptr_->deleteAllSharedNetworks6(ServerSelector::UNASSIGNED());
);
// Remove the shared network. This should not affect options assigned to the
// other shared network.
ASSERT_NO_THROW_LOG(cbptr_->deleteSharedNetwork6(ServerSelector::ALL(),
- test_networks_[1]->getName()));
+ test_networks_[1]->getName()));
EXPECT_EQ(1, countRows("dhcp6_shared_network"));
EXPECT_EQ(1, countRows("dhcp6_options"));
// Delete this shared network. This should not affect the option associated
// with the remaining shared network.
ASSERT_NO_THROW_LOG(cbptr_->deleteSharedNetwork6(ServerSelector::ALL(),
- test_networks_[0]->getName()));
+ test_networks_[0]->getName()));
EXPECT_EQ(1, countRows("dhcp6_shared_network"));
EXPECT_EQ(1, countRows("dhcp6_options"));
}
// This time creation of the option definition for the server1 should pass.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOptionDef6(ServerSelector::ONE("server1"),
- option1));
+ option1));
{
SCOPED_TRACE("option definition for server1 is set");
// The value of 3 means there should be 3 audit entries available for the
// Creation of the option definition for the server2 should also pass.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOptionDef6(ServerSelector::ONE("server2"),
- option2));
+ option2));
{
SCOPED_TRACE("option definition for server2 is set");
// Same as in case of the server1, there should be 3 audit entries and
// Finally, creation of the option definition for all servers should
// also pass.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOptionDef6(ServerSelector::ALL(),
- option3));
+ option3));
{
SCOPED_TRACE("option definition for server2 is set");
// There should be one new audit entry for all servers. It logs
// Attempt to delete option definition for server1.
uint64_t deleted_num = 0;
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteOptionDef6(ServerSelector::ONE("server1"),
- option1->getCode(),
- option1->getOptionSpaceName()));
+ option1->getCode(),
+ option1->getOptionSpaceName()));
EXPECT_EQ(0, deleted_num);
// Deleting the existing option definition for server2 should succeed.
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteOptionDef6(ServerSelector::ONE("server2"),
- option2->getCode(),
- option2->getOptionSpaceName()));
+ option2->getCode(),
+ option2->getOptionSpaceName()));
EXPECT_EQ(1, deleted_num);
// Create this option definition again to test that deletion of all servers
// removes it too.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOptionDef6(ServerSelector::ONE("server2"),
- option2));
+ option2));
// Delete all servers, except 'all'.
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteAllServers6());
// That option definition overrides the first one so the audit entry should
// indicate an update.
- if (option_def->getName() == "bar") {
- SCOPED_TRACE("UPDATE audit entry for the option definition " +
- option_def->getName());
+ auto name = option_def->getName();
+ if (name.find("bar") != std::string::npos) {
+ SCOPED_TRACE("UPDATE audit entry for the option definition " + name);
testNewAuditEntry("dhcp6_option_def",
AuditEntry::ModificationType::UPDATE,
"option definition set");
++updates_num;
} else {
- SCOPED_TRACE("CREATE audit entry for the option definition " +
- option_def->getName());
+ SCOPED_TRACE("CREATE audit entry for the option definition " + name);
testNewAuditEntry("dhcp6_option_def",
AuditEntry::ModificationType::CREATE,
"option definition set");
}
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOption6(ServerSelector::ONE("server1"),
- opt_timezone1));
+ opt_timezone1));
{
SCOPED_TRACE("global option for server1 is set");
// The value of 3 means there should be 3 audit entries available for the
}
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOption6(ServerSelector::ONE("server2"),
- opt_timezone2));
+ opt_timezone2));
{
SCOPED_TRACE("global option for server2 is set");
// Same as in case of the server1, there should be 3 audit entries and
}
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOption6(ServerSelector::ALL(),
- opt_timezone3));
+ opt_timezone3));
{
SCOPED_TRACE("global option for all servers is set");
// There should be one new audit entry for all servers. It logs
// Attempt to delete global option for server1.
uint64_t deleted_num = 0;
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteOption6(ServerSelector::ONE("server1"),
- opt_timezone1->option_->getType(),
- opt_timezone1->space_name_));
+ opt_timezone1->option_->getType(),
+ opt_timezone1->space_name_));
EXPECT_EQ(0, deleted_num);
// Deleting the existing option for server2 should succeed.
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteOption6(ServerSelector::ONE("server2"),
- opt_timezone2->option_->getType(),
- opt_timezone2->space_name_));
+ opt_timezone2->option_->getType(),
+ opt_timezone2->space_name_));
EXPECT_EQ(1, deleted_num);
// Create this option again to test that deletion of all servers removes it too.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateOption6(ServerSelector::ONE("server2"),
- opt_timezone2));
+ opt_timezone2));
// Delete all servers, except 'all'.
ASSERT_NO_THROW_LOG(deleted_num = cbptr_->deleteAllServers6());
ASSERT_TRUE(returned_subnet);
// The returned subnet should include our pool.
- const PoolPtr returned_pd_pool =
- returned_subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:a:10::"));
+ const PoolPtr returned_pd_pool = returned_subnet->getPool(Lease::TYPE_PD,
+ IOAddress("2001:db8:a:10::"));
ASSERT_TRUE(returned_pd_pool);
// The pd pool should contain option we added earlier.
OptionDescriptor returned_opt_posix_timezone =
- returned_pd_pool->getCfgOption()->get(DHCP6_OPTION_SPACE,
- D6O_NEW_POSIX_TIMEZONE);
+ returned_pd_pool->getCfgOption()->get(DHCP6_OPTION_SPACE, D6O_NEW_POSIX_TIMEZONE);
ASSERT_TRUE(returned_opt_posix_timezone.option_);
{
returned_subnet = cbptr_->getSubnet6(ServerSelector::ALL(),
subnet->getID());
ASSERT_TRUE(returned_subnet);
- const PoolPtr returned_pd_pool1 =
- returned_subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:a:10::"));
+ const PoolPtr returned_pd_pool1 = returned_subnet->getPool(Lease::TYPE_PD,
+ IOAddress("2001:db8:a:10::"));
ASSERT_TRUE(returned_pd_pool1);
// Test that the option has been correctly updated in the database.
returned_opt_posix_timezone =
- returned_pd_pool1->getCfgOption()->get(DHCP6_OPTION_SPACE,
- D6O_NEW_POSIX_TIMEZONE);
+ returned_pd_pool1->getCfgOption()->get(DHCP6_OPTION_SPACE, D6O_NEW_POSIX_TIMEZONE);
ASSERT_TRUE(returned_opt_posix_timezone.option_);
{
returned_subnet = cbptr_->getSubnet6(ServerSelector::ALL(),
subnet->getID());
ASSERT_TRUE(returned_subnet);
- const PoolPtr returned_pd_pool2 =
- returned_subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:a:10::"));
+ const PoolPtr returned_pd_pool2 = returned_subnet->getPool(Lease::TYPE_PD,
+ IOAddress("2001:db8:a:10::"));
ASSERT_TRUE(returned_pd_pool2);
// Option should be gone.
opt_posix_timezone);
returned_network = cbptr_->getSharedNetwork6(ServerSelector::ALL(),
- shared_network->getName());
+ shared_network->getName());
ASSERT_TRUE(returned_network);
OptionDescriptor returned_opt_posix_timezone =
void
GenericConfigBackendDHCPv6Test::subnetOptionIdOrderTest() {
- // Add a network with two pools with two options each.
+ // Add a subnet with two pools with two options each.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), test_subnets_[1]));
EXPECT_EQ(2, countRows("dhcp6_pool"));
EXPECT_EQ(4, countRows("dhcp6_options"));
- // Add second subnet with a single option. The number of options in the database
+ // Add a second subnet with a single option. The number of options in the database
// should now be 3.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), test_subnets_[2]));
EXPECT_EQ(2, countRows("dhcp6_pool"));
// Insert two shared networks. We insert level1 without options first,
// then level2.
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- level1_no_options));
+ level1_no_options));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- level2));
+ level2));
// Fetch all shared networks.
SharedNetwork6Collection networks =
cbptr_->getAllSharedNetworks6(ServerSelector::ALL());
}
ASSERT_NO_THROW_LOG(cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(),
- level1_options));
+ level1_options));
// Fetch all shared networks.
networks = cbptr_->getAllSharedNetworks6(ServerSelector::ALL());
EXPECT_EQ("foobar", (*(classes_list->begin() + 2))->getName());
// Move the third class between the first and second class.
- ASSERT_NO_THROW(cbptr_->createUpdateClientClass6(ServerSelector::ONE("server1"), class3, "foo"));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateClientClass6(ServerSelector::ONE("server1"), class3, "foo"));
// Ensure that the classes order has changed.
client_classes = cbptr_->getAllClientClasses6(ServerSelector::ONE("server1"));
// Update the foobar class without specifying its position. It should not
// be moved.
- ASSERT_NO_THROW(cbptr_->createUpdateClientClass6(ServerSelector::ONE("server1"), class3, ""));
+ ASSERT_NO_THROW_LOG(cbptr_->createUpdateClientClass6(ServerSelector::ONE("server1"), class3, ""));
client_classes = cbptr_->getAllClientClasses6(ServerSelector::ONE("server1"));
classes_list = client_classes.getClasses();
// Add classes.
auto class1 = test_client_classes_[0];
ASSERT_NO_THROW_LOG(class1->getCfgOption()->add(test_options_[0]->option_,
- test_options_[0]->persistent_,
- test_options_[0]->space_name_));
+ test_options_[0]->persistent_,
+ test_options_[0]->space_name_));
ASSERT_NO_THROW_LOG(class1->getCfgOption()->add(test_options_[1]->option_,
- test_options_[1]->persistent_,
- test_options_[1]->space_name_));
-
+ test_options_[1]->persistent_,
+ test_options_[1]->space_name_));
ASSERT_NO_THROW_LOG(cbptr_->createUpdateClientClass6(ServerSelector::ALL(), class1, ""));
auto class2 = test_client_classes_[1];
// Fetch the same class using different server selectors.
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ANY(),
- class1->getName()));
+ class1->getName()));
EXPECT_TRUE(client_class);
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ONE("server1"),
- class1->getName()));
+ class1->getName()));
EXPECT_TRUE(client_class);
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::UNASSIGNED(),
- class1->getName()));
+ class1->getName()));
EXPECT_FALSE(client_class);
// Fetch the second client class using different selectors. This time the
// class should not be returned for the ALL server selector because it is
// associated with the server1.
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ALL(),
- class2->getName()));
+ class2->getName()));
EXPECT_FALSE(client_class);
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ANY(),
- class2->getName()));
+ class2->getName()));
EXPECT_TRUE(client_class);
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ONE("server1"),
- class2->getName()));
+ class2->getName()));
EXPECT_TRUE(client_class);
ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::UNASSIGNED(),
- class2->getName()));
+ class2->getName()));
EXPECT_FALSE(client_class);
}
// Add class with two options and two option definitions.
auto class1 = test_client_classes_[0];
ASSERT_NO_THROW_LOG(class1->getCfgOption()->add(test_options_[0]->option_,
- test_options_[0]->persistent_,
- test_options_[0]->space_name_));
+ test_options_[0]->persistent_,
+ test_options_[0]->space_name_));
ASSERT_NO_THROW_LOG(class1->getCfgOption()->add(test_options_[1]->option_,
- test_options_[1]->persistent_,
- test_options_[1]->space_name_));
+ test_options_[1]->persistent_,
+ test_options_[1]->space_name_));
auto cfg_option_def = boost::make_shared<CfgOptionDef>();
class1->setCfgOptionDef(cfg_option_def);
ASSERT_NO_THROW_LOG(class1->getCfgOptionDef()->add(test_option_defs_[0]));
ASSERT_TRUE(client_class->getCfgOptionDef());
auto returned_def_foo = client_class->getCfgOptionDef()->get(test_option_defs_[0]->getOptionSpaceName(),
test_option_defs_[0]->getCode());
-
ASSERT_TRUE(returned_def_foo);
EXPECT_EQ(1234, returned_def_foo->getCode());
EXPECT_EQ("foo", returned_def_foo->getName());
uint64_t result;
ASSERT_NO_THROW_LOG(result = cbptr_->deleteClientClass6(ServerSelector::ONE("server1"),
- class2->getName()));
+ class2->getName()));
EXPECT_EQ(1, result);
{
SCOPED_TRACE("client class bar is deleted");
}
ASSERT_NO_THROW_LOG(result = cbptr_->deleteClientClass6(ServerSelector::ONE("server2"),
- class3->getName()));
+ class3->getName()));
EXPECT_EQ(1, result);
{
SCOPED_TRACE("client class foobar is deleted");
}
ASSERT_NO_THROW_LOG(result = cbptr_->deleteClientClass6(ServerSelector::ANY(),
- class1->getName()));
+ class1->getName()));
EXPECT_EQ(1, result);
{
SCOPED_TRACE("client class foo is deleted and no longer available for the server1");
/// @param server_tag Server tag for which the audit entries should be logged.
std::string logExistingAuditEntries(const std::string& server_tag);
+ /// @brief Tests that a backend of the given type can be instantiated.
+ ///
+ /// @param expected_type type of the back end created (i.e. "mysql",
+ /// "postgresql").
+ void getTypeTest(const std::string& expected_type);
+
+ /// @brief Verifies that a backend on the localhost can be instantiated.
+ void getHostTest();
+
+ /// @brief Verifies that a backend on the localhost port 0 can be instantiated.
+ void getPortTest();
+
/// @brief Tests that the new audit entry is added.
///
/// This method retrieves a collection of the existing audit entries and
const size_t new_entries_num = 1,
const size_t max_tested_entries = 65535);
- /// @brief Tests that a backend of the given type can be instantiated.
- ///
- /// @param expected_type type of the back end created (i.e. "mysql",
- /// "postgresql").
- void getTypeTest(const std::string& expected_type);
-
- /// @brief Verifies that a backend on the localhost can be instantiated.
- void getHostTest();
- /// @brief Verifies that a backend on the localhost port 0 can be instantiated.
- void getPortTest();
/// @brief This test verifies that the server can be added, updated and deleted.
void createUpdateDeleteServerTest();
- /// @brief This test verifies that it is possible to retrieve all servers from the
+ /// @brief This test verifies that it is possible to retrieve all servers from the
/// database and then delete all of them.
void getAndDeleteAllServersTest();
- /// @brief Thist test verifies that the global parameter can be added, updated and
+ /// @brief This test verifies that the global parameter can be added, updated and
/// deleted.
void createUpdateDeleteGlobalParameter6Test();
- /// @brief Thist test verifies that it is possible to differentiate between the
+ /// @brief This test verifies that it is possible to differentiate between the
/// global parameters by server tag and that the value specified for the
/// particular server overrides the value specified for all servers.
void globalParameters6WithServerTagsTest();
- /// @brief Thist test verifies that all global parameters can be retrieved and deleted.
+ /// @brief This test verifies that all global parameters can be retrieved and deleted.
void getAllGlobalParameters6Test();
- /// @brief Thist test verifies that modified global parameters can be retrieved.
+ /// @brief This test verifies that modified global parameters can be retrieved.
void getModifiedGlobalParameters6Test();
- /// Test that the NullKeyError message is correctly updated.
+ /// @brief Test that the NullKeyError message is correctly updated.
void nullKeyErrorTest();
- /// Test that ceateUpdateSubnet6 throws appropriate exceptions for various
+ /// @brief Test that createUpdateSubnet6 throws appropriate exceptions for various
/// server selectors.
void createUpdateSubnet6SelectorsTest();
- /// Test that subnet can be inserted, fetched, updated and then fetched again.
+ /// @brief Test that subnet can be inserted, fetched, updated and then fetched again.
void getSubnet6Test();
- /// Test that getSubnet6 by ID throws appropriate exceptions for various server
+ /// @brief Test that getSubnet6 by ID throws appropriate exceptions for various server
/// selectors.
void getSubnet6byIdSelectorsTest();
- /// Test that the information about unspecified optional parameters gets
+ /// @brief Test that the information about unspecified optional parameters gets
/// propagated to the database.
void getSubnet6WithOptionalUnspecifiedTest();
- /// Test that subnet can be associated with a shared network.
+ /// @brief Test that subnet can be associated with a shared network.
void getSubnet6SharedNetworkTest();
- /// Test that subnet can be fetched by prefix.
+ /// @brief Test that subnet can be fetched by prefix.
void getSubnet6ByPrefixTest();
- /// Test that getSubnet6 by prefix throws appropriate exceptions for various server
+ /// @brief Test that getSubnet6 by prefix throws appropriate exceptions for various server
/// selectors.
void getSubnet6byPrefixSelectorsTest();
- /// Test that all subnets can be fetched and then deleted.
+ /// @brief Test that all subnets can be fetched and then deleted.
void getAllSubnets6Test();
- /// Test that getAllSubnets6 throws appropriate exceptions for various
+ /// @brief Test that getAllSubnets6 throws appropriate exceptions for various
/// server selectors.
void getAllSubnets6SelectorsTest();
- /// Test that subnets with different server associations are returned.
+ /// @brief Test that subnets with different server associations are returned.
void getAllSubnets6WithServerTagsTest();
- /// Test that selected subnet can be deleted.
+ /// @brief Test that getModifiedSubnets6 throws appropriate exceptions for various
+ /// server selectors.
+ void getModifiedSubnets6SelectorsTest();
+
+ /// @brief Test that selected subnet can be deleted.
void deleteSubnet6Test();
- /// Test that deleteSubnet6 by ID throws appropriate exceptions for various
+ /// @brief Test that deleteSubnet6 by ID throws appropriate exceptions for various
/// server selectors.
void deleteSubnet6ByIdSelectorsTest();
- /// Test that deleteSubnet6 by prefix throws appropriate exceptions for various
+ /// @brief Test that deleteSubnet6 by prefix throws appropriate exceptions for various
/// server selectors.
void deleteSubnet6ByPrefixSelectorsTest();
- /// Test that deleteAllSubnets6 throws appropriate exceptions for various
+ /// @brief Test that deleteAllSubnets6 throws appropriate exceptions for various
/// server selectors.
void deleteAllSubnets6SelectorsTest();
- /// Test that it is possible to retrieve and delete orphaned subnet.
+ /// @brief Test that it is possible to retrieve and delete orphaned subnet.
void unassignedSubnet6Test();
- /// Test that subnets modified after given time can be fetched.
+ /// @brief Test that subnets modified after given time can be fetched.
void getModifiedSubnets6Test();
- /// Test that getModifiedSubnets6 throws appropriate exceptions for various
- /// server selectors.
- void getModifiedSubnets6SelectorsTest();
-
- /// Test that lifetimes in subnets are handled as expected.
+ /// @brief Test that lifetimes in subnets are handled as expected.
void subnetLifetimeTest();
- /// Test that subnets belonging to a shared network can be retrieved.
+ /// @brief Test that subnets belonging to a shared network can be retrieved.
void getSharedNetworkSubnets6Test();
- /// Test that pools are properly updated as a result a subnet update.
+ /// @brief Test that pools are properly updated as a result a subnet update.
void subnetUpdatePoolsTest();
- /// Test that deleting a subnet triggers deletion of the options associated
+ /// @brief Test that deleting a subnet triggers deletion of the options associated
/// with the subnet and pools.
void subnetOptionsTest();
- /// Test that shared network can be inserted, fetched, updated and then
+ /// @brief Test that shared network can be inserted, fetched, updated and then
/// fetched again.
void getSharedNetwork6Test();
- /// Test that getSharedNetwork6 throws appropriate exceptions for various
+ /// @brief Test that getSharedNetwork6 throws appropriate exceptions for various
/// server selectors.
void getSharedNetwork6SelectorsTest();
- /// Test that shared network may be created and updated and the server tags
+ /// @brief Test that shared network may be created and updated and the server tags
/// are properly assigned to it.
void createUpdateSharedNetwork6Test();
- /// Test that createUpdateSharedNetwork6 throws appropriate exceptions for various
+ /// @brief Test that createUpdateSharedNetwork6 throws appropriate exceptions for various
/// server selectors.
void createUpdateSharedNetwork6SelectorsTest();
- /// Test that the information about unspecified optional parameters gets
+ /// @brief Test that the information about unspecified optional parameters gets
/// propagated to the database.
void getSharedNetwork6WithOptionalUnspecifiedTest();
- /// Test that deleteSharedNetworkSubnets6 with not ANY selector throw.
+ /// @brief Test that deleteSharedNetworkSubnets6 with not ANY selector throw.
void deleteSharedNetworkSubnets6Test();
- /// Test that all shared networks can be fetched.
+ /// @brief Test that all shared networks can be fetched.
void getAllSharedNetworks6Test();
- /// Test that getAllSharedNetworks6 throws appropriate exceptions for various
+ /// @brief Test that getAllSharedNetworks6 throws appropriate exceptions for various
/// server selectors.
void getAllSharedNetworks6SelectorsTest();
- /// Test that shared networks with different server associations are returned.
+ /// @brief Test that shared networks with different server associations are returned.
void getAllSharedNetworks6WithServerTagsTest();
- /// Test that shared networks modified after given time can be fetched.
+ /// @brief Test that shared networks modified after given time can be fetched.
void getModifiedSharedNetworks6Test();
- /// Test that getModifiedSharedNetworks6 throws appropriate exceptions for various
+ /// @brief Test that getModifiedSharedNetworks6 throws appropriate exceptions for various
/// server selectors.
void getModifiedSharedNetworks6SelectorsTest();
- /// Test that selected shared network can be deleted.
+ /// @brief Test that selected shared network can be deleted.
void deleteSharedNetwork6Test();
- /// Test that deleteSharedNetwork6 throws appropriate exceptions for various
+ /// @brief Test that deleteSharedNetwork6 throws appropriate exceptions for various
/// server selectors.
void deleteSharedNetwork6SelectorsTest();
- /// Test that deleteAllSharedNetworks6 throws appropriate exceptions for various
+ /// @brief Test that deleteAllSharedNetworks6 throws appropriate exceptions for various
/// server selectors.
void deleteAllSharedNetworks6SelectorsTest();
- /// Test that it is possible to retrieve and delete orphaned shared network.
+ /// @brief Test that it is possible to retrieve and delete orphaned shared network.
void unassignedSharedNetworkTest();
- /// Test that lifetimes in shared networks are handled as expected.
+ /// @brief Test that lifetimes in shared networks are handled as expected.
void sharedNetworkLifetimeTest();
- /// Test that deleting a shared network triggers deletion of the options
+ /// @brief Test that deleting a shared network triggers deletion of the options
/// associated with the shared network.
void sharedNetworkOptionsTest();
- /// Test that option definition can be inserted, fetched, updated and then
+ /// @brief Test that option definition can be inserted, fetched, updated and then
/// fetched again.
void getOptionDef6Test();
- /// @brief Thist test verifies that it is possible to differentiate between the
+ /// @brief This test verifies that it is possible to differentiate between the
/// option definitions by server tag and that the option definition
/// specified for the particular server overrides the definition for
/// all servers.
void optionDefs6WithServerTagsTest();
- /// Test that all option definitions can be fetched.
+ /// @brief Test that all option definitions can be fetched.
void getAllOptionDefs6Test();
- /// Test that option definitions modified after given time can be fetched.
+ /// @brief Test that option definitions modified after given time can be fetched.
void getModifiedOptionDefs6Test();
- /// @brief Thist test verifies that global option can be added, updated and deleted.
+ /// @brief This test verifies that global option can be added, updated and deleted.
void createUpdateDeleteOption6Test();
- /// @brief Thist test verifies that it is possible to differentiate between the
+ /// @brief This test verifies that it is possible to differentiate between the
/// global options by server tag and that the option specified for the
/// particular server overrides the value specified for all servers.
void globalOptions6WithServerTagsTest();
- /// @brief Thist test verifies that all global options can be retrieved.
+ /// @brief This test verifies that all global options can be retrieved.
void getAllOptions6Test();
- /// @brief Thist test verifies that modified global options can be retrieved.
+ /// @brief This test verifies that modified global options can be retrieved.
void getModifiedOptions6Test();
- /// @brief Thist test verifies that subnet level option can be added, updated and
+ /// @brief This test verifies that subnet level option can be added, updated and
/// deleted.
void createUpdateDeleteSubnetOption6Test();
- /// @brief Thist test verifies that option can be inserted, updated and deleted
+ /// @brief This test verifies that option can be inserted, updated and deleted
/// from the pool.
void createUpdateDeletePoolOption6Test();
- /// @brief Thist test verifies that option can be inserted, updated and deleted
+ /// @brief This test verifies that option can be inserted, updated and deleted
/// from the pd pool.
void createUpdateDeletePdPoolOption6Test();
- /// @brief Thist test verifies that shared network level option can be added,
+ /// @brief This test verifies that shared network level option can be added,
/// updated and deleted.
void createUpdateDeleteSharedNetworkOption6Test();
- /// @brief Thist test verifies that option id values in one subnet do
+ /// @brief This test verifies that option id values in one subnet do
/// not impact options returned in subsequent subnets when
/// fetching subnets from the backend.
void subnetOptionIdOrderTest();
- /// @brief Thist test verifies that option id values in one shared network do
+ /// @brief This test verifies that option id values in one shared network do
/// not impact options returned in subsequent shared networks when
/// fetching shared networks from the backend.
void sharedNetworkOptionIdOrderTest();
- /// @brief Thist test verifies that it is possible to create client classes, update them
+ /// @brief This test verifies that it is possible to create client classes, update them
/// and retrieve all classes for a given server.
void setAndGetAllClientClasses6Test();
- /// @brief Thist test verifies that a single class can be retrieved from the database.
+ /// @brief This test verifies that a single class can be retrieved from the database.
void getClientClass6Test();
- /// @brief Thist test verifies that client class specific DHCP options can be
+ /// @brief This test verifies that client class specific DHCP options can be
/// modified during the class update.
void createUpdateClientClass6OptionsTest();
- /// @brief Thist test verifies that modified client classes can be retrieved from the database.
+ /// @brief This test verifies that modified client classes can be retrieved from the database.
void getModifiedClientClasses6Test();
- /// @brief Thist test verifies that a specified client class can be deleted.
+ /// @brief This test verifies that a specified client class can be deleted.
void deleteClientClass6Test();
- /// @brief Thist test verifies that all client classes can be deleted using
+ /// @brief This test verifies that all client classes can be deleted using
/// a specified server selector.
void deleteAllClientClasses6Test();
- /// @brief Thist test verifies that client class dependencies are tracked when the
+ /// @brief This test verifies that client class dependencies are tracked when the
/// classes are added to the database. It verifies that an attempt to update
/// a class violating the dependencies results in an error.
void clientClassDependencies6Test();
- /// @brief Thist test verifies that audit entries can be retrieved from a given
+ /// @brief This test verifies that audit entries can be retrieved from a given
/// timestamp and id including when two entries can get the same timestamp.
/// (either it is a common even and this should catch it, or it is a rare
/// event and it does not matter).