mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
The sqlite_exec() function now returns SQLITE_AUTH when authorization fails.
Ticket #231. (CVS 857) FossilOrigin-Name: d93c1aeb544a5b1056424945eb43854213b30e50
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script testing the sqlite_set_authorizer() API.
|
||||
#
|
||||
# $Id: auth.test,v 1.4 2003/01/14 13:48:21 drh Exp $
|
||||
# $Id: auth.test,v 1.5 2003/01/31 17:21:50 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -19,7 +19,7 @@ source $testdir/tester.tcl
|
||||
|
||||
if {[info command sqlite_set_authorizer]!=""} {
|
||||
|
||||
do_test auth-1.1 {
|
||||
do_test auth-1.1.1 {
|
||||
db close
|
||||
set ::DB [sqlite db test.db]
|
||||
proc auth {code arg1 arg2} {
|
||||
@ -31,6 +31,9 @@ do_test auth-1.1 {
|
||||
sqlite_set_authorizer $::DB ::auth
|
||||
catchsql {CREATE TABLE t1(a,b,c)}
|
||||
} {1 {not authorized}}
|
||||
do_test auth-1.1.2 {
|
||||
db errorcode
|
||||
} {23}
|
||||
do_test auth-1.2 {
|
||||
execsql {SELECT name FROM sqlite_master}
|
||||
} {}
|
||||
@ -45,6 +48,9 @@ do_test auth-1.3.1 {
|
||||
catchsql {CREATE TABLE t1(a,b,c)}
|
||||
} {1 {not authorized}}
|
||||
do_test auth-1.3.2 {
|
||||
db errorcode
|
||||
} {23}
|
||||
do_test auth-1.3.3 {
|
||||
set ::authargs
|
||||
} {t1 {}}
|
||||
do_test auth-1.4 {
|
||||
@ -1612,7 +1618,7 @@ do_test auth-2.8 {
|
||||
}
|
||||
catchsql {SELECT ROWID,b,c FROM t2}
|
||||
} {0 {{} 2 33 {} 8 9}}
|
||||
do_test auth-2.9 {
|
||||
do_test auth-2.9.1 {
|
||||
proc auth {code arg1 arg2} {
|
||||
if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="ROWID"} {
|
||||
return bogus
|
||||
@ -1621,6 +1627,9 @@ do_test auth-2.9 {
|
||||
}
|
||||
catchsql {SELECT ROWID,b,c FROM t2}
|
||||
} {1 {illegal return value (999) from the authorization function - should be SQLITE_OK, SQLITE_IGNORE, or SQLITE_DENY}}
|
||||
do_test auth-2.9.2 {
|
||||
db errorcode
|
||||
} {21}
|
||||
do_test auth-2.10 {
|
||||
proc auth {code arg1 arg2} {
|
||||
if {$code=="SQLITE_SELECT"} {
|
||||
|
@ -15,7 +15,7 @@
|
||||
# interface is pretty well tested. This file contains some addition
|
||||
# tests for fringe issues that the main test suite does not cover.
|
||||
#
|
||||
# $Id: tclsqlite.test,v 1.8 2002/09/14 13:47:33 drh Exp $
|
||||
# $Id: tclsqlite.test,v 1.9 2003/01/31 17:21:51 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -29,7 +29,7 @@ do_test tcl-1.1 {
|
||||
do_test tcl-1.2 {
|
||||
set v [catch {db bogus} msg]
|
||||
lappend v $msg
|
||||
} {1 {bad option "bogus": must be busy, changes, close, complete, eval, function, last_insert_rowid, open_aux_file, or timeout}}
|
||||
} {1 {bad option "bogus": must be busy, changes, close, complete, errorcode, eval, function, last_insert_rowid, open_aux_file, or timeout}}
|
||||
do_test tcl-1.3 {
|
||||
execsql {CREATE TABLE t1(a int, b int)}
|
||||
execsql {INSERT INTO t1 VALUES(10,20)}
|
||||
|
Reference in New Issue
Block a user