diff options
author | Jan Mercl <0xjnml@gmail.com> | 2020-07-26 22:36:18 +0200 |
---|---|---|
committer | Jan Mercl <0xjnml@gmail.com> | 2020-07-26 22:36:18 +0200 |
commit | b406626c64313ae348996c243a0a05d3f6ed2c3c (patch) | |
tree | 0eaae4fa6348b150568725e6f2ec0b4c4203b5f8 /testdata/tcl/alterauth.test | |
parent | d8d9f40ce80062793349c0ea47520b6878312f4a (diff) |
release v1.4.0-beta1v1.4.0-beta1
Diffstat (limited to 'testdata/tcl/alterauth.test')
-rw-r--r-- | testdata/tcl/alterauth.test | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/testdata/tcl/alterauth.test b/testdata/tcl/alterauth.test new file mode 100644 index 0000000..12645b3 --- /dev/null +++ b/testdata/tcl/alterauth.test @@ -0,0 +1,72 @@ +# 2018 September 2 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# + +set testdir [file dirname $argv0] + +source $testdir/tester.tcl + +# If SQLITE_OMIT_ALTERTABLE is defined, omit this file. +ifcapable !altertable { + finish_test + return +} +set testprefix alterauth + +set ::auth [list] +proc xAuth {type args} { + if {$type == "SQLITE_ALTER_TABLE"} { + lappend ::auth [concat $type [lrange $args 0 3]] + } + return SQLITE_OK +} +db auth xAuth + +do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); } + +do_test 1.1 { + set ::auth [list] + execsql { ALTER TABLE t1 RENAME TO t2 } + set ::auth +} {{SQLITE_ALTER_TABLE main t1 {} {}}} + +do_test 1.2 { + set ::auth [list] + execsql { ALTER TABLE t2 RENAME c TO ccc } + set ::auth +} {{SQLITE_ALTER_TABLE main t2 {} {}}} + +do_test 1.3 { + set ::auth [list] + execsql { ALTER TABLE t2 ADD COLUMN d } + set ::auth +} {{SQLITE_ALTER_TABLE main t2 {} {}}} + +proc xAuth {type args} { + if {$type == "SQLITE_ALTER_TABLE"} { + return SQLITE_DENY + } + return SQLITE_OK +} + +do_test 2.1 { + catchsql { ALTER TABLE t2 RENAME TO t3 } +} {1 {not authorized}} + +do_test 2.2 { + catchsql { ALTER TABLE t2 RENAME d TO ddd } +} {1 {not authorized}} + +do_test 2.3 { + catchsql { ALTER TABLE t2 ADD COLUMN e } +} {1 {not authorized}} + +finish_test |