chiark / gitweb /
changelog: start 0.6.8
[secnet.git] / mtest / t-userv
1 #! /usr/bin/tclsh
2 # This file is part of secnet.
3 # See LICENCE and this file CREDITS for full list of copyright holders.
4 # SPDX-License-Identifier: GPL-3.0-or-later
5 # There is NO WARRANTY.
6
7 source mtest/common.tcl
8
9 #----- success test -----
10
11 set good [list Uuser Ginside -u \
12           mtest/header.sites $tmp/groupfiles $tmp/out.sites Ginside \
13           < mtest/Ginside.sites]
14
15 eval run-mss-userv $good
16
17 diff-output e-userv out .sites
18
19 #----- argument parser does not look for args beyond header -----
20
21 set env(LC_MESSAGES) C
22
23 set try [lreplace $good 4 4 --misparse-test]
24
25 if {![catch {
26     eval run-mss-userv $try
27 } emsg]} {
28     error "should have failed"
29 } else {
30     switch -glob $emsg {
31         {*unrecognized arguments: --misparse-test*} {
32             error "misparsed!"
33         }
34         {*No such file or directory: '--misparse-test/TGinside'*} {
35         }
36         * {
37             error "huh ? $emsg"
38         }
39     }
40 }
41
42 #----- wrong group is rejected -----
43
44 set bad [lreplace $good 1 1 Gwrong]
45
46 if {![catch {
47     eval run-mss-userv $bad
48 } emsg]} {
49     error "should have failed"
50 } else {
51     switch -glob $emsg {
52         {*caller not in group Ginside*} { }
53         * { error "huh ? $emsg" }
54     }
55 }
56
57 #----- resulting sites file is processable -----
58
59 eval run-mss $tmp/out.sites >$tmp/out.conf
60
61 diff-mss-sites-conf mtest/e-userv.conf $tmp/out.conf
62
63 #----- works without group in `location' line -----
64
65 set testgf $tmp/Ginside.no-group
66
67 exec sed < mtest/Ginside.sites > $testgf {/^location / s/ root$//}
68
69 set testargs [lreplace $good end end $testgf]
70 eval run-mss-userv $testargs