]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[481-remote-subnet4-set-inconsistent-work-when-id-subnet-is-duplicated] Added tests...
authorFrancis Dupont <fdupont@isc.org>
Fri, 1 Mar 2019 22:55:36 +0000 (23:55 +0100)
committerFrancis Dupont <fdupont@isc.org>
Tue, 12 Mar 2019 22:20:47 +0000 (18:20 -0400)
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in

index 53ea779cd0f65a165ae39b1420589539150cf1e9..eeea6e9aef7a323268f694855f05f8fd65eae730 100644 (file)
@@ -633,6 +633,25 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getSubnet4) {
                           AuditEntry::ModificationType::UPDATE,
                           "subnet set");
     }
+
+    // Insert another subnet.
+    cbptr_->createUpdateSubnet4(ServerSelector::ALL(), test_subnets_[2]);
+
+    // Fetch this subnet by prefix and verify it matches.
+    returned_subnet = cbptr_->getSubnet4(ServerSelector::ALL(),
+                                        test_subnets_[2]->toText());
+    ASSERT_TRUE(returned_subnet);
+    EXPECT_EQ(test_subnets_[2]->toElement()->str(), returned_subnet->toElement()->str());
+
+    // Update the the subnet in the database (both use the same prefix).
+    subnet2.reset(new Subnet4(IOAddress("192.0.3.0"), 24, 30, 40, 60, 8192));
+    cbptr_->createUpdateSubnet4(ServerSelector::ALL(),  subnet2);
+
+    // Fetch again and verify.
+    returned_subnet = cbptr_->getSubnet4(ServerSelector::ALL(),
+                                        test_subnets_[2]->toText());
+    ASSERT_TRUE(returned_subnet);
+    EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
 }
 
 // Test that the information about unspecified optional parameters gets
index 1e01cdcfa124e5c134a384755c11adc37d44d694..6ca8a3eead626b1a7bdf93be917b059b5ff3da82 100644 (file)
@@ -1908,6 +1908,23 @@ ALTER TABLE dhcp6_shared_network_server
     REFERENCES dhcp6_shared_network (id)
     ON DELETE CASCADE ON UPDATE NO ACTION;
 
+-- Update dhcp4_subnet_server and dhcp6_subnet_server to allow update
+-- on the prefix too.
+
+ALTER TABLE dhcp4_subnet_server
+    DROP FOREIGN KEY fk_dhcp4_subnet_server_subnet_id;
+ALTER TABLE dhcp4_subnet_server
+    ADD CONSTRAINT fk_dhcp4_subnet_server_subnet_id FOREIGN KEY (subnet_id)
+    REFERENCES dhcp4_subnet (subnet_id)
+    ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE dhcp6_subnet_server
+    DROP FOREIGN KEY fk_dhcp6_subnet_server_subnet_id;
+ALTER TABLE dhcp6_subnet_server
+    ADD CONSTRAINT fk_dhcp6_subnet_server_subnet_id FOREIGN KEY (subnet_id)
+    REFERENCES dhcp6_subnet (subnet_id)
+    ON DELETE CASCADE ON UPDATE CASCADE;
+
 -- -----------------------------------------------------
 -- Table `dhcp6_audit_revision`
 -- -----------------------------------------------------
index c76e94d09385f83e59715ea84dadf3e78d989cda..959f4b823a0111b49d502408e6803e3cf681954a 100644 (file)
@@ -590,6 +590,23 @@ ALTER TABLE dhcp6_shared_network_server
     REFERENCES dhcp6_shared_network (id)
     ON DELETE CASCADE ON UPDATE NO ACTION;
 
+-- Update dhcp4_subnet_server and dhcp6_subnet_server to allow update
+-- on the prefix too.
+
+ALTER TABLE dhcp4_subnet_server
+    DROP FOREIGN KEY fk_dhcp4_subnet_server_subnet_id;
+ALTER TABLE dhcp4_subnet_server
+    ADD CONSTRAINT fk_dhcp4_subnet_server_subnet_id FOREIGN KEY (subnet_id)
+    REFERENCES dhcp4_subnet (subnet_id)
+    ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE dhcp6_subnet_server
+    DROP FOREIGN KEY fk_dhcp6_subnet_server_subnet_id;
+ALTER TABLE dhcp6_subnet_server
+    ADD CONSTRAINT fk_dhcp6_subnet_server_subnet_id FOREIGN KEY (subnet_id)
+    REFERENCES dhcp6_subnet (subnet_id)
+    ON DELETE CASCADE ON UPDATE CASCADE;
+
 -- -----------------------------------------------------
 -- Table dhcp6_audit_revision
 -- -----------------------------------------------------