comparison tests/test-acl @ 3432:bb00a5a92c30

Add a test for the acl extension
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 16 Oct 2006 15:38:53 -0300
parents
children f29989e9746e
comparison
equal deleted inserted replaced
3431:ec6f400cff4d 3432:bb00a5a92c30
1 #!/bin/sh
2
3 do_push()
4 {
5 user=$1
6 shift
7
8 echo "Pushing as user $user"
9 echo 'hgrc = """'
10 sed -e 1,2d b/.hg/hgrc
11 echo '"""'
12 if [ -e acl.config ]; then
13 echo 'acl.config = """'
14 cat acl.config
15 echo '"""'
16 fi
17 LOGNAME=$user hg --cwd a --debug push ../b
18 hg --cwd b rollback
19 hg --cwd b --quiet tip
20 echo
21 }
22
23 hg init a
24 cd a
25 mkdir foo foo/Bar quux
26 echo 'in foo' > foo/file.txt
27 echo 'in foo/Bar' > foo/Bar/file.txt
28 echo 'in quux' > quux/file.py
29 hg add
30 hg ci -m 'add files' -d '1000000 0'
31 echo >> foo/file.txt
32 hg ci -m 'change foo/file' -d '1000001 0'
33 echo >> foo/Bar/file.txt
34 hg ci -m 'change foo/Bar/file' -d '1000002 0'
35 echo >> quux/file.py
36 hg ci -m 'change quux/file' -d '1000003 0'
37 hg tip --quiet
38
39 cd ..
40 hg clone -r 0 a b
41
42 echo '[extensions]' >> $HGRCPATH
43 echo 'hgext.acl =' >> $HGRCPATH
44
45 config=b/.hg/hgrc
46
47 echo
48
49 echo 'Extension disabled for lack of a hook'
50 do_push fred
51
52 echo '[hooks]' >> $config
53 echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config
54
55 echo 'Extension disabled for lack of acl.sources'
56 do_push fred
57
58 echo 'No [acl.allow]/[acl.deny]'
59 echo '[acl]' >> $config
60 echo 'sources = push' >> $config
61 do_push fred
62
63 echo 'Empty [acl.allow]'
64 echo '[acl.allow]' >> $config
65 do_push fred
66
67 echo 'fred is allowed inside foo/'
68 echo 'foo/** = fred' >> $config
69 do_push fred
70
71 echo 'Empty [acl.deny]'
72 echo '[acl.deny]' >> $config
73 do_push barney
74
75 echo 'fred is allowed inside foo/, but not foo/bar/ (case matters)'
76 echo 'foo/bar/** = fred' >> $config
77 do_push fred
78
79 echo 'fred is allowed inside foo/, but not foo/Bar/'
80 echo 'foo/Bar/** = fred' >> $config
81 do_push fred
82
83 echo 'barney is not mentioned => not allowed anywhere'
84 do_push barney
85
86 echo 'barney is allowed everywhere'
87 echo '[acl.allow]' >> $config
88 echo '** = barney' >> $config
89 do_push barney
90
91 echo 'wilma can change files with a .txt extension'
92 echo '**/*.txt = wilma' >> $config
93 do_push wilma
94
95 echo 'file specified by acl.config does not exist'
96 echo '[acl]' >> $config
97 echo 'config = ../acl.config' >> $config
98 do_push barney
99
100 echo 'betty is allowed inside foo/ by a acl.config file'
101 echo '[acl.allow]' >> acl.config
102 echo 'foo/** = betty' >> acl.config
103 do_push betty
104