Update tests in returning1.test to account for [c7896e88].
[sqlite.git] / test / alterauth.test
blob12645b36f0826103413d152eb4943c8bca06bc92
1 # 2018 September 2
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #*************************************************************************
13 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
17 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
18 ifcapable !altertable {
19   finish_test
20   return
22 set testprefix alterauth
24 set ::auth [list]
25 proc xAuth {type args} {
26   if {$type == "SQLITE_ALTER_TABLE"} {
27     lappend ::auth [concat $type [lrange $args 0 3]]
28   }
29   return SQLITE_OK
31 db auth xAuth
33 do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); }
35 do_test 1.1 {
36   set ::auth [list]
37   execsql { ALTER TABLE t1 RENAME TO t2 }
38   set ::auth
39 } {{SQLITE_ALTER_TABLE main t1 {} {}}}
41 do_test 1.2 {
42   set ::auth [list]
43   execsql { ALTER TABLE t2 RENAME c TO ccc }
44   set ::auth
45 } {{SQLITE_ALTER_TABLE main t2 {} {}}}
47 do_test 1.3 {
48   set ::auth [list]
49   execsql { ALTER TABLE t2 ADD COLUMN d }
50   set ::auth
51 } {{SQLITE_ALTER_TABLE main t2 {} {}}}
53 proc xAuth {type args} {
54   if {$type == "SQLITE_ALTER_TABLE"} {
55     return SQLITE_DENY
56   }
57   return SQLITE_OK
60 do_test 2.1 {
61   catchsql { ALTER TABLE t2 RENAME TO t3 }
62 } {1 {not authorized}}
64 do_test 2.2 {
65   catchsql { ALTER TABLE t2 RENAME d TO ddd }
66 } {1 {not authorized}}
68 do_test 2.3 {
69   catchsql { ALTER TABLE t2 ADD COLUMN e }
70 } {1 {not authorized}}
72 finish_test