GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sqlite/test/auth.test at master · mackyle/sqlite Expand file tree/ Copy pathauth.testMore file actions 2703 lines (2629 loc) · 66.2 KB / Copy pathauth.testFile metadata and controls2703 lines (2629 loc) · 66.2 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 # 2003 April 4 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the sqlite3_set_authorizer() API # and related functionality. # # $Id: auth.test,v 1.46 2009/07/02 18:40:35 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # disable this test if the SQLITE_OMIT_AUTHORIZATION macro is # defined during compilation. if {[catch {db auth {}} msg]} { finish_test return } rename proc proc_real proc_real proc {name arguments script} { proc_real $name $arguments $script if {$name=="auth"} { db authorizer ::auth } } do_test auth-1.1.1 { db close set ::DB [sqlite3 db test.db] proc authx {code arg1 arg2 arg3 arg4 args} {return SQLITE_DENY} proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK } db authorizer ::authx # EVIDENCE-OF: R-03993-24285 Only a single authorizer can be in place on # a database connection at a time. Each call to sqlite3_set_authorizer # overrides the previous call. # # The authx authorizer above is overridden by the auth authorizer below # authx is never invoked. db authorizer ::auth catchsql {CREATE TABLE t1(a,b,c)} } {1 {not authorized}} do_test auth-1.1.2 { db errorcode } {23} do_test auth-1.1.3 { db authorizer } {::auth} do_test auth-1.1.4 { # Ticket #896. catchsql { SELECT x; } } {1 {no such column: x}} do_test auth-1.2 { execsql {SELECT name FROM sqlite_master} } {} # EVIDENCE-OF: R-04452-49349 When the callback returns SQLITE_DENY, the # sqlite3_prepare_v2() or equivalent call that triggered the authorizer # will fail with an error message explaining that access is denied. do_test auth-1.3.1 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } 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 {} main {}} do_test auth-1.4 { execsql {SELECT name FROM sqlite_master} } {} ifcapable tempdb { do_test auth-1.5 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TEMP TABLE t1(a,b,c)} } {1 {not authorized}} do_test auth-1.6 { execsql {SELECT name FROM temp.sqlite_master} } {} do_test auth-1.7.1 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TEMP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TEMP TABLE t1(a,b,c)} } {1 {not authorized}} do_test auth-1.7.2 { set ::authargs } {t1 {} temp {}} do_test auth-1.8 { execsql {SELECT name FROM sqlite_temp_master} } {} } do_test auth-1.9 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE TABLE t1(a,b,c)} } {0 {}} do_test auth-1.10 { execsql {SELECT name FROM sqlite_master} } {} do_test auth-1.11 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE TABLE t1(a,b,c)} } {0 {}} do_test auth-1.12 { execsql {SELECT name FROM sqlite_master} } {} ifcapable tempdb { do_test auth-1.13 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE TEMP TABLE t1(a,b,c)} } {0 {}} do_test auth-1.14 { execsql {SELECT name FROM temp.sqlite_master} } {} do_test auth-1.15 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TEMP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE TEMP TABLE t1(a,b,c)} } {0 {}} do_test auth-1.16 { execsql {SELECT name FROM sqlite_temp_master} } {} do_test auth-1.17 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TEMP TABLE t1(a,b,c)} } {0 {}} do_test auth-1.18 { execsql {SELECT name FROM sqlite_temp_master} } {t1} } do_test auth-1.19.1 { set ::authargs {} proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TEMP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TABLE t2(a,b,c)} } {0 {}} do_test auth-1.19.2 { set ::authargs } {} do_test auth-1.20 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.21.1 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {DROP TABLE t2} } {1 {not authorized}} do_test auth-1.21.2 { set ::authargs } {t2 {} main {}} do_test auth-1.22 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.23.1 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP TABLE t2} } {0 {}} do_test auth-1.23.2 { set ::authargs } {t2 {} main {}} do_test auth-1.24 { execsql {SELECT name FROM sqlite_master} } {t2} ifcapable tempdb { do_test auth-1.25 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TEMP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {DROP TABLE t1} } {1 {not authorized}} do_test auth-1.26 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.27 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TEMP_TABLE"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP TABLE t1} } {0 {}} do_test auth-1.28 { execsql {SELECT name FROM sqlite_temp_master} } {t1} } do_test auth-1.29 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="t2"} { return SQLITE_DENY } return SQLITE_OK } catchsql {INSERT INTO t2 VALUES(1,2,3)} } {1 {not authorized}} do_test auth-1.30 { execsql {SELECT * FROM t2} } {} do_test auth-1.31 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="t2"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {INSERT INTO t2 VALUES(1,2,3)} } {0 {}} do_test auth-1.32 { execsql {SELECT * FROM t2} } {} do_test auth-1.33 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="t1"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {INSERT INTO t2 VALUES(1,2,3)} } {0 {}} do_test auth-1.34 { execsql {SELECT * FROM t2} } {1 2 3} do_test auth-1.35.1 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_DENY } return SQLITE_OK } catchsql {SELECT * FROM t2} } {1 {access to t2.b is prohibited}} ifcapable attach { do_test auth-1.35.2 { execsql {ATTACH DATABASE 'test.db' AS two} catchsql {SELECT * FROM two.t2} } {1 {access to two.t2.b is prohibited}} execsql {DETACH DATABASE two} } # EVIDENCE-OF: R-38392-49970 If the action code is SQLITE_READ and the # callback returns SQLITE_IGNORE then the prepared statement statement # is constructed to substitute a NULL value in place of the table column # that would have been read if SQLITE_OK had been returned. do_test auth-1.36 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {SELECT * FROM t2} } {0 {1 {} 3}} do_test auth-1.37 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {SELECT * FROM t2 WHERE b=2} } {0 {}} do_test auth-1.38 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="a"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {SELECT * FROM t2 WHERE b=2} } {0 {{} 2 3}} do_test auth-1.39 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {SELECT * FROM t2 WHERE b IS NULL} } {0 {1 {} 3}} do_test auth-1.40 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_DENY } return SQLITE_OK } catchsql {SELECT a,c FROM t2 WHERE b IS NULL} } {1 {access to t2.b is prohibited}} do_test auth-1.41 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} { return SQLITE_DENY } return SQLITE_OK } catchsql {UPDATE t2 SET a=11} } {0 {}} do_test auth-1.42 { execsql {SELECT * FROM t2} } {11 2 3} do_test auth-1.43 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} { return SQLITE_DENY } return SQLITE_OK } catchsql {UPDATE t2 SET b=22, c=33} } {1 {not authorized}} do_test auth-1.44 { execsql {SELECT * FROM t2} } {11 2 3} do_test auth-1.45 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {UPDATE t2 SET b=22, c=33} } {0 {}} do_test auth-1.46 { execsql {SELECT * FROM t2} } {11 2 33} do_test auth-1.47 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="t2"} { return SQLITE_DENY } return SQLITE_OK } catchsql {DELETE FROM t2 WHERE a=11} } {1 {not authorized}} do_test auth-1.48 { execsql {SELECT * FROM t2} } {11 2 33} do_test auth-1.49 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="t2"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DELETE FROM t2 WHERE a=11} } {0 {}} do_test auth-1.50 { execsql {SELECT * FROM t2} } {} do_test auth-1.50.2 { execsql {INSERT INTO t2 VALUES(11, 2, 33)} } {} do_test auth-1.51 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_SELECT"} { return SQLITE_DENY } return SQLITE_OK } catchsql {SELECT * FROM t2} } {1 {not authorized}} do_test auth-1.52 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_SELECT"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {SELECT * FROM t2} } {0 {}} do_test auth-1.53 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_SELECT"} { return SQLITE_OK } return SQLITE_OK } catchsql {SELECT * FROM t2} } {0 {11 2 33}} # Update for version 3: There used to be a handful of test here that # tested the authorisation callback with the COPY command. The following # test makes the same database modifications as they used to. do_test auth-1.54 { execsql {INSERT INTO t2 VALUES(7, 8, 9);} } {} do_test auth-1.55 { execsql {SELECT * FROM t2} } {11 2 33 7 8 9} do_test auth-1.63 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql {DROP TABLE t2} } {1 {not authorized}} do_test auth-1.64 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.65 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="t2"} { return SQLITE_DENY } return SQLITE_OK } catchsql {DROP TABLE t2} } {1 {not authorized}} do_test auth-1.66 { execsql {SELECT name FROM sqlite_master} } {t2} ifcapable tempdb { do_test auth-1.67 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql {DROP TABLE t1} } {1 {not authorized}} do_test auth-1.68 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.69 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="t1"} { return SQLITE_DENY } return SQLITE_OK } catchsql {DROP TABLE t1} } {1 {not authorized}} do_test auth-1.70 { execsql {SELECT name FROM sqlite_temp_master} } {t1} } do_test auth-1.71 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP TABLE t2} } {0 {}} do_test auth-1.72 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.73 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="t2"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP TABLE t2} } {0 {}} do_test auth-1.74 { execsql {SELECT name FROM sqlite_master} } {t2} ifcapable tempdb { do_test auth-1.75 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP TABLE t1} } {0 {}} do_test auth-1.76 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.77 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="t1"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP TABLE t1} } {0 {}} do_test auth-1.78 { execsql {SELECT name FROM temp.sqlite_master} } {t1} } # Test cases auth-1.79 to auth-1.124 test creating and dropping views. # Omit these if the library was compiled with views omitted. ifcapable view { do_test auth-1.79 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} } {1 {not authorized}} do_test auth-1.80 { set ::authargs } {v1 {} main {}} do_test auth-1.81 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.82 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} } {0 {}} do_test auth-1.83 { set ::authargs } {v1 {} main {}} do_test auth-1.84 { execsql {SELECT name FROM sqlite_master} } {t2} ifcapable tempdb { do_test auth-1.85 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TEMP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} } {1 {not authorized}} do_test auth-1.86 { set ::authargs } {v1 {} temp {}} do_test auth-1.87 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.88 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TEMP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} } {0 {}} do_test auth-1.89 { set ::authargs } {v1 {} temp {}} do_test auth-1.90 { execsql {SELECT name FROM temp.sqlite_master} } {t1} } do_test auth-1.91 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} } {1 {not authorized}} do_test auth-1.92 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.93 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} } {0 {}} do_test auth-1.94 { execsql {SELECT name FROM sqlite_master} } {t2} ifcapable tempdb { do_test auth-1.95 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} } {1 {not authorized}} do_test auth-1.96 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.97 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} } {0 {}} do_test auth-1.98 { execsql {SELECT name FROM sqlite_temp_master} } {t1} } do_test auth-1.99 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql { CREATE VIEW v2 AS SELECT a+1,b+1 FROM t2; DROP VIEW v2 } } {1 {not authorized}} do_test auth-1.100 { execsql {SELECT name FROM sqlite_master} } {t2 v2} do_test auth-1.101 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {DROP VIEW v2} } {1 {not authorized}} do_test auth-1.102 { set ::authargs } {v2 {} main {}} do_test auth-1.103 { execsql {SELECT name FROM sqlite_master} } {t2 v2} do_test auth-1.104 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP VIEW v2} } {0 {}} do_test auth-1.105 { execsql {SELECT name FROM sqlite_master} } {t2 v2} do_test auth-1.106 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP VIEW v2} } {0 {}} do_test auth-1.107 { set ::authargs } {v2 {} main {}} do_test auth-1.108 { execsql {SELECT name FROM sqlite_master} } {t2 v2} do_test auth-1.109 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_OK } return SQLITE_OK } catchsql {DROP VIEW v2} } {0 {}} do_test auth-1.110 { set ::authargs } {v2 {} main {}} do_test auth-1.111 { execsql {SELECT name FROM sqlite_master} } {t2} ifcapable tempdb { do_test auth-1.112 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql { CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1; DROP VIEW v1 } } {1 {not authorized}} do_test auth-1.113 { execsql {SELECT name FROM temp.sqlite_master} } {t1 v1} do_test auth-1.114 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TEMP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql {DROP VIEW v1} } {1 {not authorized}} do_test auth-1.115 { set ::authargs } {v1 {} temp {}} do_test auth-1.116 { execsql {SELECT name FROM sqlite_temp_master} } {t1 v1} do_test auth-1.117 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP VIEW v1} } {0 {}} do_test auth-1.118 { execsql {SELECT name FROM sqlite_temp_master} } {t1 v1} do_test auth-1.119 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TEMP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql {DROP VIEW v1} } {0 {}} do_test auth-1.120 { set ::authargs } {v1 {} temp {}} do_test auth-1.121 { execsql {SELECT name FROM temp.sqlite_master} } {t1 v1} do_test auth-1.122 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_DROP_TEMP_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_OK } return SQLITE_OK } catchsql {DROP VIEW v1} } {0 {}} do_test auth-1.123 { set ::authargs } {v1 {} temp {}} do_test auth-1.124 { execsql {SELECT name FROM sqlite_temp_master} } {t1} } } ;# ifcapable view # Test cases auth-1.125 to auth-1.176 test creating and dropping triggers. # Omit these if the library was compiled with triggers omitted. # ifcapable trigger&&tempdb { do_test auth-1.125 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TRIGGER"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql { CREATE TRIGGER r2 DELETE on t2 BEGIN SELECT NULL; END; } } {1 {not authorized}} do_test auth-1.126 { set ::authargs } {r2 t2 main {}} do_test auth-1.127 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.128 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK } catchsql { CREATE TRIGGER r2 DELETE on t2 BEGIN SELECT NULL; END; } } {1 {not authorized}} do_test auth-1.129 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.130 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TRIGGER"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_IGNORE } return SQLITE_OK } catchsql { CREATE TRIGGER r2 DELETE on t2 BEGIN SELECT NULL; END; } } {0 {}} do_test auth-1.131 { set ::authargs } {r2 t2 main {}} do_test auth-1.132 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.133 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_IGNORE } return SQLITE_OK } catchsql { CREATE TRIGGER r2 DELETE on t2 BEGIN SELECT NULL; END; } } {0 {}} do_test auth-1.134 { execsql {SELECT name FROM sqlite_master} } {t2} do_test auth-1.135 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TRIGGER"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_OK } return SQLITE_OK } catchsql { CREATE TABLE tx(id); CREATE TRIGGER r2 AFTER INSERT ON t2 BEGIN INSERT INTO tx VALUES(NEW.rowid); END; } } {0 {}} do_test auth-1.136.1 { set ::authargs } {r2 t2 main {}} do_test auth-1.136.2 { execsql { SELECT name FROM sqlite_master WHERE type='trigger' } } {r2} do_test auth-1.136.3 { proc auth {code arg1 arg2 arg3 arg4 args} { lappend ::authargs $code $arg1 $arg2 $arg3 $arg4 return SQLITE_OK } set ::authargs {} execsql { INSERT INTO t2 VALUES(1,2,3); } set ::authargs } {SQLITE_INSERT t2 {} main {} SQLITE_INSERT tx {} main r2 SQLITE_READ t2 ROWID main r2} do_test auth-1.136.4 { execsql { SELECT * FROM tx; } } {3} do_test auth-1.137 { execsql {SELECT name FROM sqlite_master} } {t2 tx r2} do_test auth-1.138 { proc auth {code arg1 arg2 arg3 arg4 args} { if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK } catchsql { CREATE TRIGGER r1 DELETE on t1 BEGIN SELECT NULL; END; } } {1 {not authorized}} do_test auth-1.139 { set ::authargs } {r1 t1 temp {}} do_test auth-1.140 { execsql {SELECT name FROM temp.sqlite_master} } {t1} do_test auth-1.141 { |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |