Fossil

Check-in [5915e6f4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further enhancements to TH1 permissions testing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5915e6f4d4c7eabb47638d537b012349cae98fe9
User & Date: mistachkin 2016-08-18 02:11:59
Context
2016-08-18
02:22
Since the intent of the TH1 'hascap' command is that all specified permissions are required (i.e. the first missing permission should stop further checks), correct the loop invariant. check-in: 1c0b1a58 user: mistachkin tags: trunk
02:11
Further enhancements to TH1 permissions testing. check-in: 5915e6f4 user: mistachkin tags: trunk
01:52
Add more environment variables to the 'test_env' page. check-in: 33561a22 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/th_main.c.

2399
2400
2401
2402
2403
2404
2405

2406
2407
2408
2409

2410
2411
2412
2413
2414
2415
2416
2417
....
2447
2448
2449
2450
2451
2452
2453

2454
2455
2456
2457

2458
2459
2460
2461
2462
2463
2464
2465
....
2498
2499
2500
2501
2502
2503
2504

2505
2506
2507
2508

2509
2510
2511
2512
2513
2514
2515
2516
  fullHttpReply = find_option("http", 0, 0)!=0;
  if( fullHttpReply ) forceCgi = 1;
  if( forceCgi ) Th_ForceCgi(fullHttpReply);
  if( find_option("open-config", 0, 0)!=0 ){
    Th_OpenConfig(1);
  }
  if( find_option("set-anon-caps", 0, 0)!=0 ){

    login_set_capabilities("sx", LOGIN_ANON);
    g.useLocalauth = 1;
  }
  if( find_option("set-user-caps", 0, 0)!=0 ){

    login_set_capabilities("sx", 0);
    g.useLocalauth = 1;
  }
  verify_all_options();
  if( g.argc<3 ){
    usage("FILE");
  }
  blob_zero(&in);
................................................................................
  fullHttpReply = find_option("http", 0, 0)!=0;
  if( fullHttpReply ) forceCgi = 1;
  if( forceCgi ) Th_ForceCgi(fullHttpReply);
  if( find_option("open-config", 0, 0)!=0 ){
    Th_OpenConfig(1);
  }
  if( find_option("set-anon-caps", 0, 0)!=0 ){

    login_set_capabilities("sx", LOGIN_ANON);
    g.useLocalauth = 1;
  }
  if( find_option("set-user-caps", 0, 0)!=0 ){

    login_set_capabilities("sx", 0);
    g.useLocalauth = 1;
  }
  verify_all_options();
  if( g.argc!=3 ){
    usage("script");
  }
  Th_FossilInit(TH_INIT_DEFAULT);
................................................................................
  fullHttpReply = find_option("http", 0, 0)!=0;
  if( fullHttpReply ) forceCgi = 1;
  if( forceCgi ) Th_ForceCgi(fullHttpReply);
  if( find_option("open-config", 0, 0)!=0 ){
    Th_OpenConfig(1);
  }
  if( find_option("set-anon-caps", 0, 0)!=0 ){

    login_set_capabilities("sx", LOGIN_ANON);
    g.useLocalauth = 1;
  }
  if( find_option("set-user-caps", 0, 0)!=0 ){

    login_set_capabilities("sx", 0);
    g.useLocalauth = 1;
  }
  verify_all_options();
  if( g.argc!=3 ){
    usage("file");
  }
  blob_zero(&in);







>
|



>
|







 







>
|



>
|







 







>
|



>
|







2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
....
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
....
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
  fullHttpReply = find_option("http", 0, 0)!=0;
  if( fullHttpReply ) forceCgi = 1;
  if( forceCgi ) Th_ForceCgi(fullHttpReply);
  if( find_option("open-config", 0, 0)!=0 ){
    Th_OpenConfig(1);
  }
  if( find_option("set-anon-caps", 0, 0)!=0 ){
    const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
    login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
    g.useLocalauth = 1;
  }
  if( find_option("set-user-caps", 0, 0)!=0 ){
    const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
    login_set_capabilities(zCap ? zCap : "sx", 0);
    g.useLocalauth = 1;
  }
  verify_all_options();
  if( g.argc<3 ){
    usage("FILE");
  }
  blob_zero(&in);
................................................................................
  fullHttpReply = find_option("http", 0, 0)!=0;
  if( fullHttpReply ) forceCgi = 1;
  if( forceCgi ) Th_ForceCgi(fullHttpReply);
  if( find_option("open-config", 0, 0)!=0 ){
    Th_OpenConfig(1);
  }
  if( find_option("set-anon-caps", 0, 0)!=0 ){
    const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
    login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
    g.useLocalauth = 1;
  }
  if( find_option("set-user-caps", 0, 0)!=0 ){
    const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
    login_set_capabilities(zCap ? zCap : "sx", 0);
    g.useLocalauth = 1;
  }
  verify_all_options();
  if( g.argc!=3 ){
    usage("script");
  }
  Th_FossilInit(TH_INIT_DEFAULT);
................................................................................
  fullHttpReply = find_option("http", 0, 0)!=0;
  if( fullHttpReply ) forceCgi = 1;
  if( forceCgi ) Th_ForceCgi(fullHttpReply);
  if( find_option("open-config", 0, 0)!=0 ){
    Th_OpenConfig(1);
  }
  if( find_option("set-anon-caps", 0, 0)!=0 ){
    const char *zCap = fossil_getenv("TH1_TEST_ANON_CAPS");
    login_set_capabilities(zCap ? zCap : "sx", LOGIN_ANON);
    g.useLocalauth = 1;
  }
  if( find_option("set-user-caps", 0, 0)!=0 ){
    const char *zCap = fossil_getenv("TH1_TEST_USER_CAPS");
    login_set_capabilities(zCap ? zCap : "sx", 0);
    g.useLocalauth = 1;
  }
  verify_all_options();
  if( g.argc!=3 ){
    usage("file");
  }
  blob_zero(&in);

Changes to test/th1.test.

568
569
570
571
572
573
574





575
576
577





578
579
580





581
582
583
584
585
586
587
...
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

  fossil test-th-eval "anoncap $perm"
  test th1-anoncap-no-$perm-1 {$RESULT eq {0}}

  run_in_checkout {
    fossil test-th-eval --set-user-caps "anycap $perm"
    test th1-anycap-yes-$perm-1 {$RESULT eq {1}}






    fossil test-th-eval --set-user-caps "hascap $perm"
    test th1-hascap-yes-$perm-1 {$RESULT eq {1}}






    fossil test-th-eval --set-anon-caps "anoncap $perm"
    test th1-anoncap-yes-$perm-1 {$RESULT eq {1}}





  }
}

###############################################################################

fossil test-th-eval "anycap oh"
test th1-anycap-no-multiple-1 {$RESULT eq {0}}
................................................................................
test th1-anoncap-no-multiple-2 {$RESULT eq {0}}

###############################################################################

run_in_checkout {
  fossil test-th-eval --set-user-caps "anycap oh"
  test th1-anycap-yes-multiple-1 {$RESULT eq {1}}






  fossil test-th-eval --set-user-caps "hascap oh"
  test th1-hascap-yes-multiple-1 {$RESULT eq {1}}






  fossil test-th-eval --set-user-caps "hascap o h"
  test th1-hascap-yes-multiple-2 {$RESULT eq {1}}






  fossil test-th-eval --set-anon-caps "anoncap oh"
  test th1-anoncap-yes-multiple-1 {$RESULT eq {1}}






  fossil test-th-eval --set-anon-caps "anoncap o h"
  test th1-anoncap-yes-multiple-2 {$RESULT eq {1}}





}

###############################################################################

run_in_checkout {
  # NOTE: The "1" here forces the checkout to be opened.
  fossil test-th-eval "checkout 1"







>
>
>
>
>



>
>
>
>
>



>
>
>
>
>







 







>
>
>
>
>



>
>
>
>
>



>
>
>
>
>



>
>
>
>
>



>
>
>
>
>







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
...
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

  fossil test-th-eval "anoncap $perm"
  test th1-anoncap-no-$perm-1 {$RESULT eq {0}}

  run_in_checkout {
    fossil test-th-eval --set-user-caps "anycap $perm"
    test th1-anycap-yes-$perm-1 {$RESULT eq {1}}

    set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission.
    fossil test-th-eval --set-user-caps "anycap $perm"
    test th1-anycap-no-$perm-1 {$RESULT eq {0}}
    unset ::env(TH1_TEST_USER_CAPS)

    fossil test-th-eval --set-user-caps "hascap $perm"
    test th1-hascap-yes-$perm-1 {$RESULT eq {1}}

    set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission.
    fossil test-th-eval --set-user-caps "hascap $perm"
    test th1-hascap-no-$perm-1 {$RESULT eq {0}}
    unset ::env(TH1_TEST_USER_CAPS)

    fossil test-th-eval --set-anon-caps "anoncap $perm"
    test th1-anoncap-yes-$perm-1 {$RESULT eq {1}}

    set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission.
    fossil test-th-eval --set-anon-caps "anoncap $perm"
    test th1-anoncap-no-$perm-1 {$RESULT eq {0}}
    unset ::env(TH1_TEST_ANON_CAPS)
  }
}

###############################################################################

fossil test-th-eval "anycap oh"
test th1-anycap-no-multiple-1 {$RESULT eq {0}}
................................................................................
test th1-anoncap-no-multiple-2 {$RESULT eq {0}}

###############################################################################

run_in_checkout {
  fossil test-th-eval --set-user-caps "anycap oh"
  test th1-anycap-yes-multiple-1 {$RESULT eq {1}}

  set ::env(TH1_TEST_USER_CAPS) o
  fossil test-th-eval --set-user-caps "anycap oh"
  test th1-anycap-yes-multiple-2 {$RESULT eq {1}}
  unset ::env(TH1_TEST_USER_CAPS)

  fossil test-th-eval --set-user-caps "hascap oh"
  test th1-hascap-yes-multiple-1 {$RESULT eq {1}}

  set ::env(TH1_TEST_USER_CAPS) o
  fossil test-th-eval --set-user-caps "hascap oh"
  test th1-hascap-no-multiple-3 {$RESULT eq {0}}
  unset ::env(TH1_TEST_USER_CAPS)

  fossil test-th-eval --set-user-caps "hascap o h"
  test th1-hascap-yes-multiple-2 {$RESULT eq {1}}

  set ::env(TH1_TEST_USER_CAPS) o
  fossil test-th-eval --set-user-caps "hascap o h"
  test th1-hascap-no-multiple-4 {$RESULT eq {0}}
  unset ::env(TH1_TEST_USER_CAPS)

  fossil test-th-eval --set-anon-caps "anoncap oh"
  test th1-anoncap-yes-multiple-1 {$RESULT eq {1}}

  set ::env(TH1_TEST_ANON_CAPS) o
  fossil test-th-eval --set-anon-caps "anoncap oh"
  test th1-anoncap-no-multiple-3 {$RESULT eq {0}}
  unset ::env(TH1_TEST_ANON_CAPS)

  fossil test-th-eval --set-anon-caps "anoncap o h"
  test th1-anoncap-yes-multiple-2 {$RESULT eq {1}}

  set ::env(TH1_TEST_ANON_CAPS) o
  fossil test-th-eval --set-anon-caps "anoncap o h"
  test th1-anoncap-no-multiple-4 {$RESULT eq {0}}
  unset ::env(TH1_TEST_ANON_CAPS)
}

###############################################################################

run_in_checkout {
  # NOTE: The "1" here forces the checkout to be opened.
  fossil test-th-eval "checkout 1"

Changes to www/env-opts.md.

256
257
258
259
260
261
262








263
264
265
266
267
268
269
to enable TH1 documents in fossil.

`TH1_ENABLE_HOOKS`: Override the local or global setting `tcl-hooks`
to enable TH1 hooks in fossil.

`TH1_ENABLE_TCL`: Override the local or global setting `tcl` to enable
Tcl in fossil.









`TMP`: On Windows, the location of temporary files. The first
environment variable found in the environment that names an existing
directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
directory (aka `.`) is the temporary folder.








>
>
>
>
>
>
>
>







256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
to enable TH1 documents in fossil.

`TH1_ENABLE_HOOKS`: Override the local or global setting `tcl-hooks`
to enable TH1 hooks in fossil.

`TH1_ENABLE_TCL`: Override the local or global setting `tcl` to enable
Tcl in fossil.

`TH1_TEST_ANON_CAPS`: Override the default anonymous permissions used
when processing the `--set-anon-caps` option for the `test-th-eval`,
`test-th-render`, and `test-th-source` test commands.

`TH1_TEST_USER_CAPS`: Override the default user permissions used when
processing the `--set-user-caps` option for the `test-th-eval`,
`test-th-render`, and `test-th-source` test commands.

`TMP`: On Windows, the location of temporary files. The first
environment variable found in the environment that names an existing
directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
directory (aka `.`) is the temporary folder.