Enhance the sqlite3_user_add() interface to initialize the user

authentication logic.  Add test cases for the extra argument on the
end of the authorizer callback.

FossilOrigin-Name: 842c6da8f1a62bd13a1b4089a98b0835a46a2285
This commit is contained in:
drh
2014-09-11 16:19:31 +00:00
parent a000ca681a
commit 7883ecfcd4
7 changed files with 52 additions and 25 deletions
+19 -3
View File
@@ -209,14 +209,14 @@ do_test userauth01-1.51 {
do_test userauth01-1.60 {
forcedelete test3.db
sqlite3 db3 test3.db
sqlite3_user_add db3 alice xyzzy-alice 1
} {SQLITE_OK}
do_test userauth01-1.61 {
db3 eval {
CREATE TABLE t3(a,b,c); INSERT INTO t3 VALUES(1,2,3);
SELECT * FROM t3;
}
} {1 2 3}
do_test userauth01-1.61 {
sqlite3_user_add db3 alice xyzzy-alice 1
} {SQLITE_OK}
do_test userauth01-1.62 {
db eval {
ATTACH 'test3.db' AS aux;
@@ -238,4 +238,20 @@ do_test userauth01-1.65 {
db eval {PRAGMA database_list}
} {~/test3.db/}
# The sqlite3_set_authorizer() callback is modified to take a 7th parameter
# which is the username of the currently logged in user, or NULL for a
# no-authentication-required database.
#
proc auth {args} {
lappend ::authargs $args
return SQLITE_OK
}
do_test authuser01-2.1 {
unset -nocomplain ::authargs
db auth auth
db eval {SELECT x FROM t1}
set ::authargs
} {/SQLITE_SELECT {} {} {} {} alice/}
finish_test