5 # this is hardcoded; change it if needed
11 # ----------------------------------------------------------------------
34 try
"ADMIN_PUSH info; !/FATAL/" or die text
();
36 /Initialized.*empty.*t1.git/
37 /Initialized.*empty.*t2.git/
38 /Initialized.*empty.*t3.git/
41 my $href; # semi-global (or at least file scoped lexical!)
43 # testing for info -json is a bit unusual. The actual tests are done within
44 # this test script itself, and we send Tsh just enough for it to decide if
45 # it's 'ok' or 'not ok' and print that.
47 try
"glt info u1 -json; ok";
48 $href = from_json
(text
());
52 perm
('foo/..*', 'r w C');
53 perm
('testing', 'R W c');
59 try
"glt info u2 -json; ok";
60 $href = from_json
(text
());
61 perm
('foo/..*', 'r w c');
62 perm
('testing', 'R W c');
68 try
"glt info u3 -json; ok";
69 $href = from_json
(text
());
70 perm
('foo/..*', 'R W c');
71 perm
('testing', 'R W c');
77 try
"glt info u4 -json; ok";
78 $href = from_json
(text
());
79 perm
('foo/..*', 'r w c');
80 perm
('testing', 'R W c');
86 try
"glt info u5 -json; ok";
87 $href = from_json
(text
());
88 perm
('foo/..*', 'r w c');
89 perm
('testing', 'R W c');
95 try
"glt info u6 -json; ok";
96 $href = from_json
(text
());
97 perm
('foo/..*', 'r w c');
98 perm
('testing', 'R W c');
103 try
"## ls-remote foo/one";
104 try
"glt ls-remote u1 file:///foo/one; ok";
107 try
"glt info u1 -json; ok; !/creator..:/";
108 $href = from_json
(text
());
109 perm
('foo/..*', 'r w C');
110 perm
('foo/one', 'R W c');
111 test_creator
('foo/one', 'u1', 'undef');
114 try
"glt info u2 -json; ok; !/creator..:/";
115 $href = from_json
(text
());
116 perm
('foo/..*', 'r w c');
117 perm
('foo/one', 'r w c');
118 test_creator
('foo/one', 'u1', 'undef');
121 try
"glt info u3 -json; ok; !/creator..:/";
122 $href = from_json
(text
());
123 perm
('foo/..*', 'R W c');
124 perm
('foo/one', 'R W c');
125 test_creator
('foo/one', 'u1', 'undef');
127 try
("## with -lc now");
130 try
"glt info u1 -lc -json; ok";
131 $href = from_json
(text
());
132 perm
('foo/..*', 'r w C');
133 perm
('foo/one', 'R W c');
134 test_creator
('foo/one', 'u1', 1);
137 try
"glt info u2 -lc -json; ok";
138 $href = from_json
(text
());
139 perm
('foo/..*', 'r w c');
140 perm
('foo/one', 'r w c');
141 test_creator
('foo/one', 'u1', 'undef');
144 try
"glt info u3 -lc -json; ok";
145 $href = from_json
(text
());
146 perm
('foo/..*', 'R W c');
147 perm
('foo/one', 'R W c');
148 test_creator
('foo/one', 'u1', 1);
150 # ----------------------------------------------------------------------
152 # test perms given repo and expected perms. (lowercase r/w/c means NOT
153 # expected, uppercase means expected)
155 my ($repo, $aa) = @_;
156 for my $aa1 (split ' ', $aa) {
158 if ($aa1 =~ /[a-z]/) {
159 $exp = 'undef'; # we can't use 0, though I'd like to
162 my $perm = $href->{repos
}{$repo}{perms
}{$aa1} || 'undef';
163 try
'perl $_ = "' . $perm . '"; /' . $exp . '/';
167 # test versions in greeting string
170 my $res = ( $href->{GL_USER
} eq $glu ?
1 : 'undef' );
171 try
'perl $_ = "' . $res . '"; /1/';
172 $res = ( $href->{gitolite_version
} =~ /^v3.[5-9]/ ?
1 : 'undef' );
173 try
'perl $_ = "' . $res . '"; /1/';
174 $res = ( $href->{git_version
} =~ /^1.[6-9]|^2./ ?
1 : 'undef' );
175 try
'perl $_ = "' . $res . '"; /1/';
180 my ($r, $c, $exp) = @_;
181 my $res = ( ($href->{repos
}{$r}{creator
} || '') eq $c ?
1 : 'undef' );
182 try
'perl $_ = "' . $res . '"; /' . $exp . '/';