mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[1891] implemented sqlite3 deleteNSEC3RecordInZone.
This commit is contained in:
@@ -75,7 +75,8 @@ enum StatementID {
|
||||
NSEC3_LAST = 18,
|
||||
ADD_NSEC3_RECORD = 19,
|
||||
DEL_ZONE_NSEC3_RECORDS = 20,
|
||||
NUM_STATEMENTS = 21
|
||||
DEL_NSEC3_RECORD = 21,
|
||||
NUM_STATEMENTS = 22
|
||||
};
|
||||
|
||||
const char* const text_statements[NUM_STATEMENTS] = {
|
||||
@@ -154,7 +155,10 @@ const char* const text_statements[NUM_STATEMENTS] = {
|
||||
"INSERT INTO nsec3 (zone_id, hash, owner, ttl, rdtype, rdata) "
|
||||
"VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
||||
// DEL_ZONE_NSEC3_RECORDS: delete all NSEC3-related records from the zone
|
||||
"DELETE FROM nsec3 WHERE zone_id=?1"
|
||||
"DELETE FROM nsec3 WHERE zone_id=?1",
|
||||
// DEL_NSEC3_RECORD: delete specified NSEC3-related records
|
||||
"DELETE FROM nsec3 WHERE zone_id=?1 AND hash=?2 "
|
||||
"AND rdtype=?3 AND rdata=?4"
|
||||
};
|
||||
|
||||
struct SQLite3Parameters {
|
||||
@@ -1191,9 +1195,13 @@ SQLite3Accessor::deleteRecordInZone(const string (¶ms)[DEL_PARAM_COUNT]) {
|
||||
|
||||
void
|
||||
SQLite3Accessor::deleteNSEC3RecordInZone(
|
||||
const string (&/*params*/)[DEL_PARAM_COUNT])
|
||||
const string (¶ms)[DEL_PARAM_COUNT])
|
||||
{
|
||||
isc_throw(NotImplemented, "not yet implemented");
|
||||
// TBD: no transaction check
|
||||
|
||||
doUpdate<const string (&)[DEL_PARAM_COUNT]>(
|
||||
*dbparameters_, DEL_NSEC3_RECORD, params,
|
||||
"delete NSEC3 record from zone");
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -742,7 +742,7 @@ const char* const deleted_data[] = {
|
||||
"foo.bar.example.com.", "A", "192.0.2.1"
|
||||
};
|
||||
const char* const nsec3_data[DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT] = {
|
||||
// example NSEC parameters. Using "apex_hash" just as a convenient
|
||||
// example NSEC3 parameters. Using "apex_hash" just as a convenient
|
||||
// shortcut; otherwise it has nothing to do with the zone apex for the
|
||||
// purpose of this test.
|
||||
apex_hash, "3600", "NSEC3",
|
||||
@@ -753,6 +753,11 @@ const char* const nsec3_sig_data[DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT] = {
|
||||
"NSEC3 5 3 3600 20000101000000 20000201000000 12345 "
|
||||
"example.com. FAKEFAKEFAKE"
|
||||
};
|
||||
const char* const nsec3_deleted_data[] = {
|
||||
// Delete parameters for nsec3_data
|
||||
apex_hash, nsec3_data[DatabaseAccessor::ADD_NSEC3_TYPE],
|
||||
nsec3_data[DatabaseAccessor::ADD_NSEC3_RDATA]
|
||||
};
|
||||
|
||||
class SQLite3Update : public SQLite3AccessorTest {
|
||||
protected:
|
||||
@@ -994,6 +999,7 @@ TEST_F(SQLite3Update, addNSEC3Record) {
|
||||
copy(nsec3_data, nsec3_data + DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT,
|
||||
add_nsec3_columns);
|
||||
accessor->addNSEC3RecordToZone(add_nsec3_columns);
|
||||
|
||||
// Add an RRSIG for NSEC3
|
||||
copy(nsec3_sig_data,
|
||||
nsec3_sig_data + DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT,
|
||||
@@ -1102,6 +1108,32 @@ TEST_F(SQLite3Update, deleteRecord) {
|
||||
checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
|
||||
}
|
||||
|
||||
TEST_F(SQLite3Update, deleteNSEC3Record) {
|
||||
// Similar to the previous test, but for NSEC3.
|
||||
zone_id = accessor->startUpdateZone("example.com.", false).second;
|
||||
checkNSEC3Records(*accessor, zone_id, apex_hash, empty_stored);
|
||||
|
||||
// We first need to add some record.
|
||||
copy(nsec3_data, nsec3_data + DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT,
|
||||
add_nsec3_columns);
|
||||
accessor->addNSEC3RecordToZone(add_nsec3_columns);
|
||||
|
||||
// Now it should exist.
|
||||
expected_stored.clear();
|
||||
expected_stored.push_back(nsec3_data);
|
||||
checkNSEC3Records(*accessor, zone_id, apex_hash, expected_stored);
|
||||
|
||||
// Delete it, and confirm that.
|
||||
copy(nsec3_deleted_data,
|
||||
nsec3_deleted_data + DatabaseAccessor::DEL_PARAM_COUNT, del_params);
|
||||
accessor->deleteNSEC3RecordInZone(del_params);
|
||||
checkNSEC3Records(*accessor, zone_id, apex_hash, empty_stored);
|
||||
|
||||
// Commit the change, and confirm the deleted data still isn't there.
|
||||
accessor->commit();
|
||||
checkNSEC3Records(*accessor, zone_id, apex_hash, empty_stored);
|
||||
}
|
||||
|
||||
TEST_F(SQLite3Update, deleteThenRollback) {
|
||||
zone_id = accessor->startUpdateZone("example.com.", false).second;
|
||||
|
||||
|
Reference in New Issue
Block a user