/ Check-in [00940265b1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add new test file "alterauth.test".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 00940265b18a3cf848602e1e0b3edbd935cb4309ef91a34b0d5746a258a47ae6
User & Date: dan 2018-09-06 16:24:23
Context
2018-09-06
16:47
Fix harmless compiler warning. check-in: 88b39c46c1 user: mistachkin tags: trunk
16:47
Fix a problem causing SQLITE_OMIT_VIRTUALTABLE builds to fail. check-in: 18beabc848 user: dan tags: trunk
16:24
Add new test file "alterauth.test". check-in: 00940265b1 user: dan tags: trunk
16:20
Add an "ALTER TABLE RENAME COLUMN" command. Upgrade "ALTER TABLE RENAME TABLE" so that it modifies references to the renamed table embedded in SQL view and trigger definitions. check-in: 4da5998314 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/alterauth.test.

            1  +# 2018 September 2
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            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.
            9  +#
           10  +#*************************************************************************
           11  +#
           12  +
           13  +set testdir [file dirname $argv0]
           14  +
           15  +source $testdir/tester.tcl
           16  +
           17  +# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
           18  +ifcapable !altertable {
           19  +  finish_test
           20  +  return
           21  +}
           22  +set testprefix alterauth
           23  +
           24  +set ::auth [list]
           25  +proc xAuth {type args} {
           26  +  if {$type == "SQLITE_ALTER_TABLE"} {
           27  +    lappend ::auth [concat $type $args]
           28  +  }
           29  +  return SQLITE_OK
           30  +}
           31  +db auth xAuth
           32  +
           33  +do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); }
           34  +
           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 {} {}}}
           40  +
           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 {} {}}}
           46  +
           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 {} {}}}
           52  +
           53  +proc xAuth {type args} {
           54  +  if {$type == "SQLITE_ALTER_TABLE"} {
           55  +    return SQLITE_DENY
           56  +  }
           57  +  return SQLITE_OK
           58  +}
           59  +
           60  +do_test 2.1 {
           61  +  catchsql { ALTER TABLE t2 RENAME TO t3 }
           62  +} {1 {not authorized}}
           63  +
           64  +do_test 2.2 {
           65  +  catchsql { ALTER TABLE t2 RENAME d TO ddd }
           66  +} {1 {not authorized}}
           67  +
           68  +do_test 2.3 {
           69  +  catchsql { ALTER TABLE t2 ADD COLUMN e }
           70  +} {1 {not authorized}}
           71  +
           72  +finish_test