##// END OF EJS Templates
test-acl: don't use $PWD...
Mads Kiilerich -
r11461:2b83c26b stable
parent child Browse files
Show More
@@ -1,176 +1,176
1 1 #!/bin/sh
2 2
3 3 do_push()
4 4 {
5 5 user=$1
6 6 shift
7 7
8 8 echo "Pushing as user $user"
9 9 echo 'hgrc = """'
10 10 sed -e 1,2d b/.hg/hgrc | grep -v fakegroups.py
11 11 echo '"""'
12 12 if test -f acl.config; then
13 13 echo 'acl.config = """'
14 14 cat acl.config
15 15 echo '"""'
16 16 fi
17 17 # On AIX /etc/profile sets LOGNAME read-only. So
18 18 # LOGNAME=$user hg --cws a --debug push ../b
19 19 # fails with "This variable is read only."
20 20 # Use env to work around this.
21 21 env LOGNAME=$user hg --cwd a --debug push ../b
22 22 hg --cwd b rollback
23 23 hg --cwd b --quiet tip
24 24 echo
25 25 }
26 26
27 27 init_config()
28 28 {
29 29 cat > fakegroups.py <<EOF
30 30 from hgext import acl
31 31 def fakegetusers(ui, group):
32 32 try:
33 33 return acl._getusersorig(ui, group)
34 34 except:
35 35 return ["fred", "betty"]
36 36 acl._getusersorig = acl._getusers
37 37 acl._getusers = fakegetusers
38 38 EOF
39 39
40 40 rm -f acl.config
41 41 cat > $config <<EOF
42 42 [hooks]
43 43 pretxnchangegroup.acl = python:hgext.acl.hook
44 44 [acl]
45 45 sources = push
46 46 [extensions]
47 f=$PWD/fakegroups.py
47 f=`pwd`/fakegroups.py
48 48 EOF
49 49 }
50 50
51 51 hg init a
52 52 cd a
53 53 mkdir foo foo/Bar quux
54 54 echo 'in foo' > foo/file.txt
55 55 echo 'in foo/Bar' > foo/Bar/file.txt
56 56 echo 'in quux' > quux/file.py
57 57 hg add -q
58 58 hg ci -m 'add files' -d '1000000 0'
59 59 echo >> foo/file.txt
60 60 hg ci -m 'change foo/file' -d '1000001 0'
61 61 echo >> foo/Bar/file.txt
62 62 hg ci -m 'change foo/Bar/file' -d '1000002 0'
63 63 echo >> quux/file.py
64 64 hg ci -m 'change quux/file' -d '1000003 0'
65 65 hg tip --quiet
66 66
67 67 cd ..
68 68 hg clone -r 0 a b
69 69
70 70 echo '[extensions]' >> $HGRCPATH
71 71 echo 'acl =' >> $HGRCPATH
72 72
73 73 config=b/.hg/hgrc
74 74
75 75 echo
76 76
77 77 echo 'Extension disabled for lack of a hook'
78 78 do_push fred
79 79
80 80 echo '[hooks]' >> $config
81 81 echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config
82 82
83 83 echo 'Extension disabled for lack of acl.sources'
84 84 do_push fred
85 85
86 86 echo 'No [acl.allow]/[acl.deny]'
87 87 echo '[acl]' >> $config
88 88 echo 'sources = push' >> $config
89 89 do_push fred
90 90
91 91 echo 'Empty [acl.allow]'
92 92 echo '[acl.allow]' >> $config
93 93 do_push fred
94 94
95 95 echo 'fred is allowed inside foo/'
96 96 echo 'foo/** = fred' >> $config
97 97 do_push fred
98 98
99 99 echo 'Empty [acl.deny]'
100 100 echo '[acl.deny]' >> $config
101 101 do_push barney
102 102
103 103 echo 'fred is allowed inside foo/, but not foo/bar/ (case matters)'
104 104 echo 'foo/bar/** = fred' >> $config
105 105 do_push fred
106 106
107 107 echo 'fred is allowed inside foo/, but not foo/Bar/'
108 108 echo 'foo/Bar/** = fred' >> $config
109 109 do_push fred
110 110
111 111 echo 'barney is not mentioned => not allowed anywhere'
112 112 do_push barney
113 113
114 114 echo 'barney is allowed everywhere'
115 115 echo '[acl.allow]' >> $config
116 116 echo '** = barney' >> $config
117 117 do_push barney
118 118
119 119 echo 'wilma can change files with a .txt extension'
120 120 echo '**/*.txt = wilma' >> $config
121 121 do_push wilma
122 122
123 123 echo 'file specified by acl.config does not exist'
124 124 echo '[acl]' >> $config
125 125 echo 'config = ../acl.config' >> $config
126 126 do_push barney
127 127
128 128 echo 'betty is allowed inside foo/ by a acl.config file'
129 129 echo '[acl.allow]' >> acl.config
130 130 echo 'foo/** = betty' >> acl.config
131 131 do_push betty
132 132
133 133 echo 'acl.config can set only [acl.allow]/[acl.deny]'
134 134 echo '[hooks]' >> acl.config
135 135 echo 'changegroup.acl = false' >> acl.config
136 136 do_push barney
137 137
138 138 # asterisk
139 139
140 140 init_config
141 141
142 142 echo 'asterisk test'
143 143 echo '[acl.allow]' >> $config
144 144 echo "** = fred" >> $config
145 145 echo "fred is always allowed"
146 146 do_push fred
147 147
148 148 echo '[acl.deny]' >> $config
149 149 echo "foo/Bar/** = *" >> $config
150 150 echo "no one is allowed inside foo/Bar/"
151 151 do_push fred
152 152
153 153 # Groups
154 154
155 155 init_config
156 156
157 157 echo 'OS-level groups'
158 158 echo '[acl.allow]' >> $config
159 159 echo "** = @group1" >> $config
160 160 echo "@group1 is always allowed"
161 161 do_push fred
162 162
163 163 echo '[acl.deny]' >> $config
164 164 echo "foo/Bar/** = @group1" >> $config
165 165 echo "@group is allowed inside anything but foo/Bar/"
166 166 do_push fred
167 167
168 168 echo 'Invalid group'
169 169 # Disable the fakegroups trick to get real failures
170 170 grep -v fakegroups $config > config.tmp
171 171 mv config.tmp $config
172 172 echo '[acl.allow]' >> $config
173 173 echo "** = @unlikelytoexist" >> $config
174 174 do_push fred 2>&1 | grep unlikelytoexist
175 175
176 176 true
General Comments 0
You need to be logged in to leave comments. Login now