From 112500028ef1d14cadb8a73a7b8f8fd26366231e Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 14 Apr 2023 18:00:03 +0000 Subject: [PATCH] Further tests for fts5 secure-delete mode. FossilOrigin-Name: c5a47063b7971868ebbb3f0718434dd6bd22d01c43697f48941df9aae3885abc --- ext/fts5/test/fts5secure3.test | 8 +++- ext/fts5/test/fts5secure4.test | 82 ++++++++++++++++++++++++++++++++++ manifest | 14 +++--- manifest.uuid | 2 +- 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/ext/fts5/test/fts5secure3.test b/ext/fts5/test/fts5secure3.test index 70c2028df6..bc56e08200 100644 --- a/ext/fts5/test/fts5secure3.test +++ b/ext/fts5/test/fts5secure3.test @@ -9,6 +9,8 @@ # #************************************************************************* # +# TESTRUNNER: slow +# source [file join [file dirname [info script]] fts5_common.tcl] ifcapable !fts5 { finish_test ; return } @@ -142,8 +144,10 @@ foreach ii [lshuffle [db eval {SELECT rowid FROM fff}]] { DELETE FROM fff WHERE rowid=$ii; } #if {$iTest==1} { dump fff } - do_execsql_test 3.1.$iTest.$ii.ic { - INSERT INTO fff(fff) VALUES('integrity-check'); + if {($iTest % 20)==0} { + do_execsql_test 3.1.$iTest.$ii.ic { + INSERT INTO fff(fff) VALUES('integrity-check'); + } } #if {$iTest==1} { break } incr iTest diff --git a/ext/fts5/test/fts5secure4.test b/ext/fts5/test/fts5secure4.test index b6a3be5e5b..48d9242b6b 100644 --- a/ext/fts5/test/fts5secure4.test +++ b/ext/fts5/test/fts5secure4.test @@ -14,6 +14,10 @@ source [file join [file dirname [info script]] fts5_common.tcl] return_if_no_fts5 set ::testprefix fts5secure4 +#------------------------------------------------------------------------- +# Test using the 'delete' command to attempt to delete a token that +# is not present in the index in secure-delete mode. +# do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, b, content=x1); @@ -49,6 +53,84 @@ do_execsql_test 1.6 { INSERT INTO t1(t1) VALUES('integrity-check'); } +#------------------------------------------------------------------------- +# Test using secure-delete with detail=none or detail=col. +# +foreach {tn d} {1 full 2 none 3 column} { + reset_db + do_execsql_test 2.$tn.1 " + CREATE VIRTUAL TABLE x1 USING fts5(xx, yy, zz, detail=$d, prefix='1,2'); + INSERT INTO x1(x1, rank) VALUES('pgsz', 64); + " + + do_execsql_test 2.$tn.2 { + BEGIN; + INSERT INTO x1 VALUES('a b c', 'd e f', 'a b c'); + INSERT INTO x1 VALUES('a b c', 'd e f', 'a b c'); + INSERT INTO x1 VALUES('a b c', 'd e f', 'a b c'); + INSERT INTO x1 VALUES('a b c', 'd e f', 'a b c'); + INSERT INTO x1 VALUES('a b c', 'd e f', 'a b c'); + COMMIT; + } + + do_execsql_test 2.$tn.3 { + DELETE FROM x1 WHERE rowid IN (2, 4, 6); + INSERT INTO x1(x1) VALUES('integrity-check'); + } + + do_execsql_test 2.$tn.4 { + DELETE FROM x1 WHERE rowid IN (1, 3, 5); + INSERT INTO x1(x1) VALUES('integrity-check'); + } + + do_execsql_test 2.$tn.5 { + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 + ) + INSERT INTO x1 + SELECT 'seems to be', 'used brew to', 'everything is working' FROM s + UNION ALL + SELECT 'used brew to', 'everything is working', 'seems to be' FROM s + UNION ALL + SELECT 'everything is working', 'seems to be', 'used brew to' FROM s + UNION ALL + SELECT 'abc', 'zzz', 'a b c d' + UNION ALL + SELECT 'z', 'z', 'z' FROM s + } + + do_test 2.$tn.6 { + for {set i 300} {$i > 200} {incr i -1} { + execsql { + DELETE FROM x1 WHERE rowid=$i; + INSERT INTO x1(x1) VALUES('integrity-check'); + } + } + } {} + + do_test 2.$tn.7 { + for {set i 1} {$i < 100} {incr i} { + execsql { + DELETE FROM x1 WHERE rowid=$i; + INSERT INTO x1(x1) VALUES('integrity-check'); + } + } + } {} + + do_test 2.$tn.8 { + foreach i [db eval {SELECT rowid FROM x1}] { + execsql { + DELETE FROM x1 WHERE rowid=$i; + INSERT INTO x1(x1) VALUES('integrity-check'); + } + } + } {} + + do_execsql_test 2.$tn.9 { + SELECT * FROM x1 + } {} +} + finish_test diff --git a/manifest b/manifest index 889cc1e34b..44ea6b43cb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\sOOM\stest\sfor\sthe\snew\scode\son\sthis\sbranch. -D 2023-04-14T17:00:29.247 +C Further\stests\sfor\sfts5\ssecure-delete\smode. +D 2023-04-14T18:00:03.868 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -189,8 +189,8 @@ F ext/fts5/test/fts5rowid.test b8790ec170a8dc1942a15aef3db926a5f3061b1ff17101300 F ext/fts5/test/fts5savepoint.test fc02929f238d02a22df4172625704e029f7c1e0e92e332d654375690f8e6e43f F ext/fts5/test/fts5secure.test 214a561519d1b1817f146efd1057e2a97cc896e75c2accc77157d874154bda64 F ext/fts5/test/fts5secure2.test 2e961d7eef939f294c56b5d895cac7f1c3a60b934ee2cfd5e5e620bdf1ba6bbc -F ext/fts5/test/fts5secure3.test fd73b98a6e11038960b84109fed42f9e0a098a31338c94d07c163244d4bd7254 -F ext/fts5/test/fts5secure4.test 3eed9eaece133fa4921b4383b13f71db1c0e415324cd86bb9dc5ac91609d5776 +F ext/fts5/test/fts5secure3.test c7e1080a6912f2a3ac68f2e05b88b72a99de38543509b2bbf427cac5c9c1c610 +F ext/fts5/test/fts5secure4.test 17ac602024db3953401c3e51ad8e03de3b972c1770554585f63812ca4083550e F ext/fts5/test/fts5securefault.test d18e3cab7a3c4a66f44812202e1b0ea0b4bd0f9ee766951749737cfbab100e7e F ext/fts5/test/fts5simple.test a298670508c1458b88ce6030440f26a30673931884eb5f4094ac1773b3ba217b F ext/fts5/test/fts5simple2.test 258a1b0c590409bfa5271e872c79572b319d2a56554d0585f68f146a0da603f0 @@ -2057,8 +2057,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0268d1a59316d169927cbd4c562725e46a9023b7d7123ade911c12203e222adf -R d8f750d5cff7a2eb655ae379ef3df034 +P 846ae7e099ce67dab6b5df0ad5648a01d7bf7f2acf8312d817ed8505d4ea5aec +R 288b188c0f389f12eebf550efb7220b6 U dan -Z babd8fc4a31fce6ad5175a62742eb085 +Z 9dffa1950ad50c2fc3482bbd0532371a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 294d07f50b..72e3e9e1e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -846ae7e099ce67dab6b5df0ad5648a01d7bf7f2acf8312d817ed8505d4ea5aec \ No newline at end of file +c5a47063b7971868ebbb3f0718434dd6bd22d01c43697f48941df9aae3885abc \ No newline at end of file