Fossil SCM

Further enhancements to TH1 permissions testing.

mistachkin 2016-08-18 02:11 trunk
Commit 5915e6f4d4c7eabb47638d537b012349cae98fe9
+12 -6
--- src/th_main.c
+++ src/th_main.c
@@ -2401,15 +2401,17 @@
24012401
if( forceCgi ) Th_ForceCgi(fullHttpReply);
24022402
if( find_option("open-config", 0, 0)!=0 ){
24032403
Th_OpenConfig(1);
24042404
}
24052405
if( find_option("set-anon-caps", 0, 0)!=0 ){
2406
- login_set_capabilities("sx", LOGIN_ANON);
2406
+ const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
2407
+ login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
24072408
g.useLocalauth = 1;
24082409
}
24092410
if( find_option("set-user-caps", 0, 0)!=0 ){
2410
- login_set_capabilities("sx", 0);
2411
+ const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
2412
+ login_set_capabilities(zCap ? zCap : "sx", 0);
24112413
g.useLocalauth = 1;
24122414
}
24132415
verify_all_options();
24142416
if( g.argc<3 ){
24152417
usage("FILE");
@@ -2449,15 +2451,17 @@
24492451
if( forceCgi ) Th_ForceCgi(fullHttpReply);
24502452
if( find_option("open-config", 0, 0)!=0 ){
24512453
Th_OpenConfig(1);
24522454
}
24532455
if( find_option("set-anon-caps", 0, 0)!=0 ){
2454
- login_set_capabilities("sx", LOGIN_ANON);
2456
+ const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
2457
+ login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
24552458
g.useLocalauth = 1;
24562459
}
24572460
if( find_option("set-user-caps", 0, 0)!=0 ){
2458
- login_set_capabilities("sx", 0);
2461
+ const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
2462
+ login_set_capabilities(zCap ? zCap : "sx", 0);
24592463
g.useLocalauth = 1;
24602464
}
24612465
verify_all_options();
24622466
if( g.argc!=3 ){
24632467
usage("script");
@@ -2500,15 +2504,17 @@
25002504
if( forceCgi ) Th_ForceCgi(fullHttpReply);
25012505
if( find_option("open-config", 0, 0)!=0 ){
25022506
Th_OpenConfig(1);
25032507
}
25042508
if( find_option("set-anon-caps", 0, 0)!=0 ){
2505
- login_set_capabilities("sx", LOGIN_ANON);
2509
+ const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
2510
+ login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
25062511
g.useLocalauth = 1;
25072512
}
25082513
if( find_option("set-user-caps", 0, 0)!=0 ){
2509
- login_set_capabilities("sx", 0);
2514
+ const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
2515
+ login_set_capabilities(zCap ? zCap : "sx", 0);
25102516
g.useLocalauth = 1;
25112517
}
25122518
verify_all_options();
25132519
if( g.argc!=3 ){
25142520
usage("file");
25152521
--- src/th_main.c
+++ src/th_main.c
@@ -2401,15 +2401,17 @@
2401 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2402 if( find_option("open-config", 0, 0)!=0 ){
2403 Th_OpenConfig(1);
2404 }
2405 if( find_option("set-anon-caps", 0, 0)!=0 ){
2406 login_set_capabilities("sx", LOGIN_ANON);
 
2407 g.useLocalauth = 1;
2408 }
2409 if( find_option("set-user-caps", 0, 0)!=0 ){
2410 login_set_capabilities("sx", 0);
 
2411 g.useLocalauth = 1;
2412 }
2413 verify_all_options();
2414 if( g.argc<3 ){
2415 usage("FILE");
@@ -2449,15 +2451,17 @@
2449 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2450 if( find_option("open-config", 0, 0)!=0 ){
2451 Th_OpenConfig(1);
2452 }
2453 if( find_option("set-anon-caps", 0, 0)!=0 ){
2454 login_set_capabilities("sx", LOGIN_ANON);
 
2455 g.useLocalauth = 1;
2456 }
2457 if( find_option("set-user-caps", 0, 0)!=0 ){
2458 login_set_capabilities("sx", 0);
 
2459 g.useLocalauth = 1;
2460 }
2461 verify_all_options();
2462 if( g.argc!=3 ){
2463 usage("script");
@@ -2500,15 +2504,17 @@
2500 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2501 if( find_option("open-config", 0, 0)!=0 ){
2502 Th_OpenConfig(1);
2503 }
2504 if( find_option("set-anon-caps", 0, 0)!=0 ){
2505 login_set_capabilities("sx", LOGIN_ANON);
 
2506 g.useLocalauth = 1;
2507 }
2508 if( find_option("set-user-caps", 0, 0)!=0 ){
2509 login_set_capabilities("sx", 0);
 
2510 g.useLocalauth = 1;
2511 }
2512 verify_all_options();
2513 if( g.argc!=3 ){
2514 usage("file");
2515
--- src/th_main.c
+++ src/th_main.c
@@ -2401,15 +2401,17 @@
2401 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2402 if( find_option("open-config", 0, 0)!=0 ){
2403 Th_OpenConfig(1);
2404 }
2405 if( find_option("set-anon-caps", 0, 0)!=0 ){
2406 const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
2407 login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
2408 g.useLocalauth = 1;
2409 }
2410 if( find_option("set-user-caps", 0, 0)!=0 ){
2411 const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
2412 login_set_capabilities(zCap ? zCap : "sx", 0);
2413 g.useLocalauth = 1;
2414 }
2415 verify_all_options();
2416 if( g.argc<3 ){
2417 usage("FILE");
@@ -2449,15 +2451,17 @@
2451 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2452 if( find_option("open-config", 0, 0)!=0 ){
2453 Th_OpenConfig(1);
2454 }
2455 if( find_option("set-anon-caps", 0, 0)!=0 ){
2456 const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
2457 login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
2458 g.useLocalauth = 1;
2459 }
2460 if( find_option("set-user-caps", 0, 0)!=0 ){
2461 const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
2462 login_set_capabilities(zCap ? zCap : "sx", 0);
2463 g.useLocalauth = 1;
2464 }
2465 verify_all_options();
2466 if( g.argc!=3 ){
2467 usage("script");
@@ -2500,15 +2504,17 @@
2504 if( forceCgi ) Th_ForceCgi(fullHttpReply);
2505 if( find_option("open-config", 0, 0)!=0 ){
2506 Th_OpenConfig(1);
2507 }
2508 if( find_option("set-anon-caps", 0, 0)!=0 ){
2509 const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
2510 login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
2511 g.useLocalauth = 1;
2512 }
2513 if( find_option("set-user-caps", 0, 0)!=0 ){
2514 const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
2515 login_set_capabilities(zCap ? zCap : "sx", 0);
2516 g.useLocalauth = 1;
2517 }
2518 verify_all_options();
2519 if( g.argc!=3 ){
2520 usage("file");
2521
--- test/th1.test
+++ test/th1.test
@@ -570,16 +570,31 @@
570570
test th1-anoncap-no-$perm-1 {$RESULT eq {0}}
571571
572572
run_in_checkout {
573573
fossil test-th-eval --set-user-caps "anycap $perm"
574574
test th1-anycap-yes-$perm-1 {$RESULT eq {1}}
575
+
576
+ set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission.
577
+ fossil test-th-eval --set-user-caps "anycap $perm"
578
+ test th1-anycap-no-$perm-1 {$RESULT eq {0}}
579
+ unset ::env(TH1_TEST_USER_CAPS)
575580
576581
fossil test-th-eval --set-user-caps "hascap $perm"
577582
test th1-hascap-yes-$perm-1 {$RESULT eq {1}}
583
+
584
+ set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission.
585
+ fossil test-th-eval --set-user-caps "hascap $perm"
586
+ test th1-hascap-no-$perm-1 {$RESULT eq {0}}
587
+ unset ::env(TH1_TEST_USER_CAPS)
578588
579589
fossil test-th-eval --set-anon-caps "anoncap $perm"
580590
test th1-anoncap-yes-$perm-1 {$RESULT eq {1}}
591
+
592
+ set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission.
593
+ fossil test-th-eval --set-anon-caps "anoncap $perm"
594
+ test th1-anoncap-no-$perm-1 {$RESULT eq {0}}
595
+ unset ::env(TH1_TEST_ANON_CAPS)
581596
}
582597
}
583598
584599
###############################################################################
585600
@@ -609,22 +624,47 @@
609624
###############################################################################
610625
611626
run_in_checkout {
612627
fossil test-th-eval --set-user-caps "anycap oh"
613628
test th1-anycap-yes-multiple-1 {$RESULT eq {1}}
629
+
630
+ set ::env(TH1_TEST_USER_CAPS) o
631
+ fossil test-th-eval --set-user-caps "anycap oh"
632
+ test th1-anycap-yes-multiple-2 {$RESULT eq {1}}
633
+ unset ::env(TH1_TEST_USER_CAPS)
614634
615635
fossil test-th-eval --set-user-caps "hascap oh"
616636
test th1-hascap-yes-multiple-1 {$RESULT eq {1}}
637
+
638
+ set ::env(TH1_TEST_USER_CAPS) o
639
+ fossil test-th-eval --set-user-caps "hascap oh"
640
+ test th1-hascap-no-multiple-3 {$RESULT eq {0}}
641
+ unset ::env(TH1_TEST_USER_CAPS)
617642
618643
fossil test-th-eval --set-user-caps "hascap o h"
619644
test th1-hascap-yes-multiple-2 {$RESULT eq {1}}
645
+
646
+ set ::env(TH1_TEST_USER_CAPS) o
647
+ fossil test-th-eval --set-user-caps "hascap o h"
648
+ test th1-hascap-no-multiple-4 {$RESULT eq {0}}
649
+ unset ::env(TH1_TEST_USER_CAPS)
620650
621651
fossil test-th-eval --set-anon-caps "anoncap oh"
622652
test th1-anoncap-yes-multiple-1 {$RESULT eq {1}}
653
+
654
+ set ::env(TH1_TEST_ANON_CAPS) o
655
+ fossil test-th-eval --set-anon-caps "anoncap oh"
656
+ test th1-anoncap-no-multiple-3 {$RESULT eq {0}}
657
+ unset ::env(TH1_TEST_ANON_CAPS)
623658
624659
fossil test-th-eval --set-anon-caps "anoncap o h"
625660
test th1-anoncap-yes-multiple-2 {$RESULT eq {1}}
661
+
662
+ set ::env(TH1_TEST_ANON_CAPS) o
663
+ fossil test-th-eval --set-anon-caps "anoncap o h"
664
+ test th1-anoncap-no-multiple-4 {$RESULT eq {0}}
665
+ unset ::env(TH1_TEST_ANON_CAPS)
626666
}
627667
628668
###############################################################################
629669
630670
run_in_checkout {
631671
--- test/th1.test
+++ test/th1.test
@@ -570,16 +570,31 @@
570 test th1-anoncap-no-$perm-1 {$RESULT eq {0}}
571
572 run_in_checkout {
573 fossil test-th-eval --set-user-caps "anycap $perm"
574 test th1-anycap-yes-$perm-1 {$RESULT eq {1}}
 
 
 
 
 
575
576 fossil test-th-eval --set-user-caps "hascap $perm"
577 test th1-hascap-yes-$perm-1 {$RESULT eq {1}}
 
 
 
 
 
578
579 fossil test-th-eval --set-anon-caps "anoncap $perm"
580 test th1-anoncap-yes-$perm-1 {$RESULT eq {1}}
 
 
 
 
 
581 }
582 }
583
584 ###############################################################################
585
@@ -609,22 +624,47 @@
609 ###############################################################################
610
611 run_in_checkout {
612 fossil test-th-eval --set-user-caps "anycap oh"
613 test th1-anycap-yes-multiple-1 {$RESULT eq {1}}
 
 
 
 
 
614
615 fossil test-th-eval --set-user-caps "hascap oh"
616 test th1-hascap-yes-multiple-1 {$RESULT eq {1}}
 
 
 
 
 
617
618 fossil test-th-eval --set-user-caps "hascap o h"
619 test th1-hascap-yes-multiple-2 {$RESULT eq {1}}
 
 
 
 
 
620
621 fossil test-th-eval --set-anon-caps "anoncap oh"
622 test th1-anoncap-yes-multiple-1 {$RESULT eq {1}}
 
 
 
 
 
623
624 fossil test-th-eval --set-anon-caps "anoncap o h"
625 test th1-anoncap-yes-multiple-2 {$RESULT eq {1}}
 
 
 
 
 
626 }
627
628 ###############################################################################
629
630 run_in_checkout {
631
--- test/th1.test
+++ test/th1.test
@@ -570,16 +570,31 @@
570 test th1-anoncap-no-$perm-1 {$RESULT eq {0}}
571
572 run_in_checkout {
573 fossil test-th-eval --set-user-caps "anycap $perm"
574 test th1-anycap-yes-$perm-1 {$RESULT eq {1}}
575
576 set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission.
577 fossil test-th-eval --set-user-caps "anycap $perm"
578 test th1-anycap-no-$perm-1 {$RESULT eq {0}}
579 unset ::env(TH1_TEST_USER_CAPS)
580
581 fossil test-th-eval --set-user-caps "hascap $perm"
582 test th1-hascap-yes-$perm-1 {$RESULT eq {1}}
583
584 set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission.
585 fossil test-th-eval --set-user-caps "hascap $perm"
586 test th1-hascap-no-$perm-1 {$RESULT eq {0}}
587 unset ::env(TH1_TEST_USER_CAPS)
588
589 fossil test-th-eval --set-anon-caps "anoncap $perm"
590 test th1-anoncap-yes-$perm-1 {$RESULT eq {1}}
591
592 set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission.
593 fossil test-th-eval --set-anon-caps "anoncap $perm"
594 test th1-anoncap-no-$perm-1 {$RESULT eq {0}}
595 unset ::env(TH1_TEST_ANON_CAPS)
596 }
597 }
598
599 ###############################################################################
600
@@ -609,22 +624,47 @@
624 ###############################################################################
625
626 run_in_checkout {
627 fossil test-th-eval --set-user-caps "anycap oh"
628 test th1-anycap-yes-multiple-1 {$RESULT eq {1}}
629
630 set ::env(TH1_TEST_USER_CAPS) o
631 fossil test-th-eval --set-user-caps "anycap oh"
632 test th1-anycap-yes-multiple-2 {$RESULT eq {1}}
633 unset ::env(TH1_TEST_USER_CAPS)
634
635 fossil test-th-eval --set-user-caps "hascap oh"
636 test th1-hascap-yes-multiple-1 {$RESULT eq {1}}
637
638 set ::env(TH1_TEST_USER_CAPS) o
639 fossil test-th-eval --set-user-caps "hascap oh"
640 test th1-hascap-no-multiple-3 {$RESULT eq {0}}
641 unset ::env(TH1_TEST_USER_CAPS)
642
643 fossil test-th-eval --set-user-caps "hascap o h"
644 test th1-hascap-yes-multiple-2 {$RESULT eq {1}}
645
646 set ::env(TH1_TEST_USER_CAPS) o
647 fossil test-th-eval --set-user-caps "hascap o h"
648 test th1-hascap-no-multiple-4 {$RESULT eq {0}}
649 unset ::env(TH1_TEST_USER_CAPS)
650
651 fossil test-th-eval --set-anon-caps "anoncap oh"
652 test th1-anoncap-yes-multiple-1 {$RESULT eq {1}}
653
654 set ::env(TH1_TEST_ANON_CAPS) o
655 fossil test-th-eval --set-anon-caps "anoncap oh"
656 test th1-anoncap-no-multiple-3 {$RESULT eq {0}}
657 unset ::env(TH1_TEST_ANON_CAPS)
658
659 fossil test-th-eval --set-anon-caps "anoncap o h"
660 test th1-anoncap-yes-multiple-2 {$RESULT eq {1}}
661
662 set ::env(TH1_TEST_ANON_CAPS) o
663 fossil test-th-eval --set-anon-caps "anoncap o h"
664 test th1-anoncap-no-multiple-4 {$RESULT eq {0}}
665 unset ::env(TH1_TEST_ANON_CAPS)
666 }
667
668 ###############################################################################
669
670 run_in_checkout {
671
--- www/env-opts.md
+++ www/env-opts.md
@@ -258,10 +258,18 @@
258258
`TH1_ENABLE_HOOKS`: Override the local or global setting `tcl-hooks`
259259
to enable TH1 hooks in fossil.
260260
261261
`TH1_ENABLE_TCL`: Override the local or global setting `tcl` to enable
262262
Tcl in fossil.
263
+
264
+`TH1_TEST_ANON_CAPS`: Override the default anonymous permissions used
265
+when processing the `--set-anon-caps` option for the `test-th-eval`,
266
+`test-th-render`, and `test-th-source` test commands.
267
+
268
+`TH1_TEST_USER_CAPS`: Override the default user permissions used when
269
+processing the `--set-user-caps` option for the `test-th-eval`,
270
+`test-th-render`, and `test-th-source` test commands.
263271
264272
`TMP`: On Windows, the location of temporary files. The first
265273
environment variable found in the environment that names an existing
266274
directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
267275
directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
268276
--- www/env-opts.md
+++ www/env-opts.md
@@ -258,10 +258,18 @@
258 `TH1_ENABLE_HOOKS`: Override the local or global setting `tcl-hooks`
259 to enable TH1 hooks in fossil.
260
261 `TH1_ENABLE_TCL`: Override the local or global setting `tcl` to enable
262 Tcl in fossil.
 
 
 
 
 
 
 
 
263
264 `TMP`: On Windows, the location of temporary files. The first
265 environment variable found in the environment that names an existing
266 directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
267 directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
268
--- www/env-opts.md
+++ www/env-opts.md
@@ -258,10 +258,18 @@
258 `TH1_ENABLE_HOOKS`: Override the local or global setting `tcl-hooks`
259 to enable TH1 hooks in fossil.
260
261 `TH1_ENABLE_TCL`: Override the local or global setting `tcl` to enable
262 Tcl in fossil.
263
264 `TH1_TEST_ANON_CAPS`: Override the default anonymous permissions used
265 when processing the `--set-anon-caps` option for the `test-th-eval`,
266 `test-th-render`, and `test-th-source` test commands.
267
268 `TH1_TEST_USER_CAPS`: Override the default user permissions used when
269 processing the `--set-user-caps` option for the `test-th-eval`,
270 `test-th-render`, and `test-th-source` test commands.
271
272 `TMP`: On Windows, the location of temporary files. The first
273 environment variable found in the environment that names an existing
274 directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
275 directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
276

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button