5 # this is hardcoded; change it if needed
9 # put this after ::Easy because it chdirs away from where you were and the
10 # 'use lib "src"', not being absolute, fails
12 # smoke tests for Easy.pm
13 # ----------------------------------------------------------------------
14 # for a change these are actual perl tests, so not much call for tsh here,
15 # although I still need the basic infrastructure for setting up the repos and
16 # I still can't intermix this with perl's Test.pm or Test::More etc
17 sub ok
{ (+shift) ?
print "ok\n" : print "not ok\n"; }
18 sub nok
{ (+shift) ?
print "not ok\n" : print "ok\n"; }
19 sub msg
{ return unless $ENV{D
}; print STDERR
"#" . +shift . "\n"; }
24 cat $ENV{HOME}/.gitolite.rc
25 perl s/GIT_CONFIG_KEYS.*/GIT_CONFIG_KEYS => '.*',/
26 put $ENV{HOME}/.gitolite.rc
29 # basic push admin repo
32 RW+ VREF/NAME/ = admin
33 RW+ VREF/NAME/u5/ = u5
56 try
"ADMIN_PUSH set1; !/FATAL/" or die text
();
58 # valid_user() -- an internal function but still worth testing by itself first
59 eval { Gitolite
::Easy
::valid_user
(); };
60 ok
($@
=~ /FATAL.*GL_USER not set/);
62 eval { Gitolite
::Easy
::valid_user
(); };
63 nok
($@
=~ /FATAL.*GL_USER not set/);
67 $ENV{GL_USER
} = "admin"; ok
(is_admin
());
68 $ENV{GL_USER
} = "u5"; ok
(is_admin
());
69 $ENV{GL_USER
} = "u2"; nok
(is_admin
());
71 # is_super_admin -- not sure how useful it is right now
72 msg
('is_super_admin');
73 $ENV{GL_USER
} = "admin"; ok
( is_super_admin
() );
74 $ENV{GL_USER
} = "u5"; nok
( is_super_admin
() );
75 $ENV{GL_USER
} = "u2"; nok
( is_super_admin
() );
79 $ENV{GL_USER
} = "u1"; ok
( in_group
('oddguys') ); nok
( in_group
('evensout') );
80 $ENV{GL_USER
} = "u3"; ok
( in_group
('oddguys') ); nok
( in_group
('evensout') );
81 $ENV{GL_USER
} = "u4"; nok
( in_group
('oddguys') ); ok
( in_group
('evensout') );
82 $ENV{GL_USER
} = "u2"; nok
( in_group
('oddguys') ); ok
( in_group
('evensout') );
86 try
("glt ls-remote u4 cc/u4; /Initialized empty.*cc/u4/");
87 $ENV{GL_USER
} = "u3"; nok
( owns
("cc/u3") ); nok
( owns
("cc/u4") );
88 $ENV{GL_USER
} = "u4"; nok
( owns
("cc/u3") ); ok
( owns
("cc/u4") );
89 $ENV{GL_USER
} = "u5"; nok
( owns
("cc/u3") ); nok
( owns
("cc/u4") );
93 $ENV{GL_USER
} = "u1"; ok
(can_read
("aa"));
94 $ENV{GL_USER
} = "u2"; ok
(can_read
("aa"));
95 $ENV{GL_USER
} = "u3"; nok
(can_read
("aa"));
96 $ENV{GL_USER
} = "u4"; ok
(can_read
("aa"));
98 $ENV{GL_USER
} = "u1"; nok
(can_read
("bb"));
99 $ENV{GL_USER
} = "u2"; nok
(can_read
("bb"));
100 $ENV{GL_USER
} = "u3"; nok
(can_read
("bb"));
101 $ENV{GL_USER
} = "u4"; nok
(can_read
("bb"));
103 $ENV{GL_USER
} = "u3"; nok
(can_read
("cc/u3"));
104 $ENV{GL_USER
} = "u4"; nok
(can_read
("cc/u3"));
105 $ENV{GL_USER
} = "u5"; nok
(can_read
("cc/u3"));
106 $ENV{GL_USER
} = "u6"; nok
(can_read
("cc/u3"));
108 $ENV{GL_USER
} = "u3"; nok
(can_read
("cc/u4"));
109 $ENV{GL_USER
} = "u4"; ok
(can_read
("cc/u4"));
110 $ENV{GL_USER
} = "u5"; ok
(can_read
("cc/u4"));
111 $ENV{GL_USER
} = "u6"; ok
(can_read
("cc/u4"));
115 $ENV{GL_USER
} = "u1"; ok
(can_write
("aa"));
116 $ENV{GL_USER
} = "u2"; ok
(can_write
("aa"));
117 $ENV{GL_USER
} = "u3"; nok
(can_write
("aa"));
118 $ENV{GL_USER
} = "u4"; nok
(can_write
("aa"));
120 $ENV{GL_USER
} = "u1"; ok
(can_write
("aa", "+"));
121 $ENV{GL_USER
} = "u2"; nok
(can_write
("aa", "+"));
122 $ENV{GL_USER
} = "u3"; nok
(can_write
("aa", "+"));
123 $ENV{GL_USER
} = "u4"; nok
(can_write
("aa", "+"));
125 $ENV{GL_USER
} = "u1"; nok
(can_write
("bb"));
126 $ENV{GL_USER
} = "u2"; nok
(can_write
("bb"));
127 $ENV{GL_USER
} = "u3"; nok
(can_write
("bb"));
128 $ENV{GL_USER
} = "u4"; nok
(can_write
("bb"));
130 $ENV{GL_USER
} = "u3"; nok
(can_write
("cc/u3"));
131 $ENV{GL_USER
} = "u4"; nok
(can_write
("cc/u3"));
132 $ENV{GL_USER
} = "u5"; nok
(can_write
("cc/u3"));
133 $ENV{GL_USER
} = "u6"; nok
(can_write
("cc/u3"));
135 $ENV{GL_USER
} = "u3"; nok
(can_write
("cc/u4"));
136 $ENV{GL_USER
} = "u4"; ok
(can_write
("cc/u4"));
137 $ENV{GL_USER
} = "u5"; ok
(can_write
("cc/u4"));
138 $ENV{GL_USER
} = "u6"; nok
(can_write
("cc/u4"));
140 $ENV{GL_USER
} = "u3"; nok
(can_write
("cc/u4", "+"));
141 $ENV{GL_USER
} = "u4"; ok
(can_write
("cc/u4", "+"));
142 $ENV{GL_USER
} = "u5"; ok
(can_write
("cc/u4", "+"));
143 $ENV{GL_USER
} = "u6"; nok
(can_write
("cc/u4", "+"));
146 try
("glt ls-remote u4 cc/sub/one; /Initialized empty.*cc/sub/one/");
147 try
("glt ls-remote u4 cc/two; /Initialized empty.*cc/two/");
150 @a = config
("aa", "fo..aa"); ok
($a[0] eq 'for.aa' and $a[1] eq '1');
151 @a = config
("aa", "for.aa"); ok
($a[0] eq 'for.aa' and $a[1] eq '1');
152 @a = config
("aa", "fo\\..aa"); ok
(scalar(@a) == 0);
154 @a = config
("aa", "fo..cc"); ok
(scalar(@a) == 0);
155 @a = config
("aa", "for.cc"); ok
(scalar(@a) == 0);
156 @a = config
("aa", "fo\\..cc"); ok
(scalar(@a) == 0);
158 @a = config
("bb", "fo..aa"); ok
(scalar(@a) == 0);
159 @a = config
("bb", "for.aa"); ok
(scalar(@a) == 0);
160 @a = config
("bb", "fo\\..aa"); ok
(scalar(@a) == 0);
162 @a = config
("cc/u4", "fo..aa"); ok
(scalar(@a) == 0);
163 @a = config
("cc/u4", "for.aa"); ok
(scalar(@a) == 0);
164 @a = config
("cc/u4", "fo\\..aa"); ok
(scalar(@a) == 0);
166 @a = config
("cc/u4", "fo..cc"); ok
($a[0] eq 'for.cc' and $a[1] eq '1');
167 @a = config
("cc/u4", "for.cc"); ok
($a[0] eq 'for.cc' and $a[1] eq '1');
168 @a = config
("cc/u4", "fo\\..cc"); ok
(scalar(@a) == 0);
170 @a = config
("cc/two", "fo..cc"); ok
($a[0] eq 'for.cc' and $a[1] eq '1');
171 @a = config
("cc/two", "for.cc"); ok
($a[0] eq 'for.cc' and $a[1] eq '1');
172 @a = config
("cc/two", "fo\\..cc"); ok
(scalar(@a) == 0);
174 @a = config
("cc/sub/one", "fo..cc"); ok
($a[0] eq 'for.cc' and $a[1] eq '1');
175 @a = config
("cc/sub/one", "for.cc"); ok
($a[0] eq 'for.cc' and $a[1] eq '1');
176 @a = config
("cc/sub/one", "fo\\..cc"); ok
(scalar(@a) == 0);
178 @a = config
("cc/sub/one", "su..cc"); ok
($a[0] eq 'sub.cc' and $a[1] eq '1');
179 @a = config
("cc/sub/one", "sub.cc"); ok
($a[0] eq 'sub.cc' and $a[1] eq '1');
180 @a = config
("cc/sub/one", "su\\..cc"); ok
(scalar(@a) == 0);