mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add authorization callbacks for REINDEX. (CVS 2148)
FossilOrigin-Name: 9f0d744ee4d99f44e88c6f799821791c3b5f31b6
This commit is contained in:
108
test/auth.test
108
test/auth.test
@ -12,7 +12,7 @@
|
||||
# focus of this script is testing the ATTACH and DETACH commands
|
||||
# and related functionality.
|
||||
#
|
||||
# $Id: auth.test,v 1.24 2004/11/23 10:13:03 danielk1977 Exp $
|
||||
# $Id: auth.test,v 1.25 2004/11/23 15:41:17 danielk1977 Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -1800,6 +1800,112 @@ catchsql {ALTER TABLE t2x RENAME TO t2}
|
||||
|
||||
} ;# ifcapable altertable
|
||||
|
||||
# Test the authorization callbacks for the REINDEX command.
|
||||
ifcapable reindex {
|
||||
|
||||
proc auth {code args} {
|
||||
if {$code=="SQLITE_REINDEX"} {
|
||||
set ::authargs [concat $::authargs $args]
|
||||
}
|
||||
return SQLITE_OK
|
||||
}
|
||||
db authorizer auth
|
||||
do_test auth-1.281 {
|
||||
execsql {
|
||||
CREATE TABLE t3(a PRIMARY KEY, b, c);
|
||||
CREATE INDEX t3_idx1 ON t3(c COLLATE BINARY);
|
||||
CREATE INDEX t3_idx2 ON t3(b COLLATE NOCASE);
|
||||
}
|
||||
} {}
|
||||
do_test auth-1.282 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX t3_idx1;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx1 {} main {}}
|
||||
do_test auth-1.283 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX BINARY;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx1 {} main {} sqlite_autoindex_t3_1 {} main {}}
|
||||
do_test auth-1.284 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX NOCASE;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx2 {} main {}}
|
||||
do_test auth-1.285 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX t3;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx2 {} main {} t3_idx1 {} main {} sqlite_autoindex_t3_1 {} main {}}
|
||||
do_test auth-1.286 {
|
||||
execsql {
|
||||
DROP TABLE t3;
|
||||
}
|
||||
} {}
|
||||
do_test auth-1.287 {
|
||||
execsql {
|
||||
CREATE TEMP TABLE t3(a PRIMARY KEY, b, c);
|
||||
CREATE INDEX t3_idx1 ON t3(c COLLATE BINARY);
|
||||
CREATE INDEX t3_idx2 ON t3(b COLLATE NOCASE);
|
||||
}
|
||||
} {}
|
||||
do_test auth-1.288 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX temp.t3_idx1;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx1 {} temp {}}
|
||||
do_test auth-1.289 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX BINARY;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx1 {} temp {} sqlite_autoindex_t3_1 {} temp {}}
|
||||
do_test auth-1.290 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX NOCASE;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx2 {} temp {}}
|
||||
do_test auth-1.291 {
|
||||
set ::authargs {}
|
||||
execsql {
|
||||
REINDEX temp.t3;
|
||||
}
|
||||
set ::authargs
|
||||
} {t3_idx2 {} temp {} t3_idx1 {} temp {} sqlite_autoindex_t3_1 {} temp {}}
|
||||
proc auth {code args} {
|
||||
if {$code=="SQLITE_REINDEX"} {
|
||||
set ::authargs [concat $::authargs $args]
|
||||
return SQLITE_DENY
|
||||
}
|
||||
return SQLITE_OK
|
||||
}
|
||||
do_test auth-1.292 {
|
||||
set ::authargs {}
|
||||
catchsql {
|
||||
REINDEX temp.t3;
|
||||
}
|
||||
} {1 {not authorized}}
|
||||
do_test auth-1.293 {
|
||||
execsql {
|
||||
DROP TABLE t3;
|
||||
}
|
||||
} {}
|
||||
|
||||
} ;# ifcapable reindex
|
||||
|
||||
|
||||
do_test auth-2.1 {
|
||||
proc auth {code arg1 arg2 arg3 arg4} {
|
||||
|
Reference in New Issue
Block a user