create command: remove race condition...
[gitolite.git] / t / writable.t
bloba649323b0c1aa8507a88d1203364f46cbea2b125
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 # this is hardcoded; change it if needed
6 use lib "src/lib";
7 use Gitolite::Test;
8 use Cwd;
9 my $workdir = getcwd();
11 # 'gitolite writable' command
12 # ----------------------------------------------------------------------
14 my $sf = ".gitolite.down";
16 try "plan 66";
17 try "DEF POK = !/DENIED/; !/failed to push/";
19 # delete the down file
20 unlink "$ENV{HOME}/$sf";
22 # add foo, bar/..* repos to the config and push
23 confreset;confadd '
24 repo foo
25 RW = u1
26 R = u2
28 repo bar/..*
29 C = u2 u4 u6
30 RW = CREATOR u3
33 try "ADMIN_PUSH set1; !/FATAL/" or die text();
35 try "
36 # clone and push to foo
37 CLONE u1 foo; ok
38 cd foo; ok
39 tc f1; ok
40 PUSH u1 master; ok; /new branch/
42 # auto-clone and push to bar/u2
43 cd ..
44 CLONE u2 bar/u2; ok; /appear to have cloned an empty/
45 /Initialized empty/
46 cd u2;
47 tc f2
48 PUSH u2 master; ok;
50 # disable site with some message
51 gitolite writable \@all off testing site-wide disable; ok
53 # try push foo and see fail + message
54 cd ../foo; ok
55 tc f3; ok
56 PUSH u1; !ok; /testing site-wide disable/
57 # try push bar/u2 and ...
58 cd ../u2; ok
59 tc f4; ok
60 PUSH u2; !ok; /testing site-wide disable/
62 # try auto-create push bar/u4 and this works!!
63 cd ..
64 CLONE u4 bar/u4; ok; /appear to have cloned an empty/
65 /Initialized empty/
66 !/testing site-wide disable/
67 cd u4; ok
69 # enable site
70 gitolite writable \@all on; ok
72 # try same 3 again
74 # try push foo and see fail + message
75 cd ../foo; ok
76 tc g3; ok
77 PUSH u1; ok; /master -> master/
78 # try push bar/u2 and ...
79 cd ../u2; ok
80 tc g4; ok
81 PUSH u2; ok; /master -> master/
83 # try auto-create push bar/u4 and this works!!
84 cd ..
85 CLONE u6 bar/u6; ok; /appear to have cloned an empty/
86 /Initialized empty/
87 !/testing site-wide disable/
88 cd u6; ok
90 # disable just foo
91 gitolite writable foo off foo down
93 # try push foo and see the message
94 cd ../foo; ok
95 tc g3; ok
96 PUSH u1; !ok; /foo down/
97 !/testing site-wide disable/
98 # push bar/u2 ok
99 cd ../u2
100 tc g4
101 PUSH u2; ok; /master -> master/
103 # enable foo, disable bar/u2
104 gitolite writable foo on
105 gitolite writable bar/u2 off the bar is closed
107 # try both
108 cd ../foo; ok
109 tc h3; ok
110 PUSH u1; ok; /master -> master/
111 # push bar/u2 ok
112 cd ../u2
113 tc h4
114 PUSH u2; !ok; /the bar is closed/
116 ssh u3 writable bar/u2 on; !ok; /you are not authorized/
117 ssh u3 writable \@all on; !ok; /you are not authorized/
119 ssh u2 writable bar/u2 on; ok
120 ssh u2 writable \@all on; !ok; /you are not authorized/
122 ssh admin writable \@all on;