(minor) validate all role names, not just the first line!

If you use a role name that was not in GL_WILDREPOS_PERM_CATS, it will
get caught later when someone whom youhave given that role tries to
access the repo (look for another occurrence of the same error message
as this one).

So there's no access violation but it would be nice to be told upfront
that it won't work.
g2
Sitaram Chamarty 2012-01-26 06:12:15 +05:30
parent 7e81458f04
commit c59bf16942
3 changed files with 15 additions and 9 deletions

View File

@ -400,7 +400,7 @@ sub get_set_perms
# convert R and RW to the actual category names in the config file
$perms =~ s/^\s*R /READERS /mg;
$perms =~ s/^\s*RW /WRITERS /mg;
for my $g ($perms =~ /^\s*(\S+)/g) {
for my $g ($perms =~ /^\s*(\S+)/gm) {
die "invalid permission category $g\n" unless $GL_WILDREPOS_PERM_CATS =~ /(^|\s)$g(\s|$)/;
}
print "New perms are:\n";

View File

@ -1,5 +1,6 @@
# vim: syn=sh:
# vim: ft=sh:
# test gl-perms categories
tsh pwd || die '## tsh not installed?'
for bc in 0 1
do
@ -111,15 +112,20 @@ do
expect "W access for foo/u1/u1r1 DENIED to u2"
name "add invalid category MANAGERS"
echo MANAGERS u2 | runlocal ssh u1 setperms foo/u1/u1r1
expect "invalid permission category MANAGERS"
tsh "
( echo READERS u6\; echo MANAGERS u2 ) | ssh u1 setperms foo/u1/u1r1;
!ok; /invalid permission category MANAGERS/
"
name "add u2 to now valid MANAGERS"
echo "\$GL_WILDREPOS_PERM_CATS = 'READERS WRITERS MANAGERS';" | addrc
echo MANAGERS u2 | runlocal ssh u1 setperms foo/u1/u1r1
notexpect "invalid permission category MANAGERS"
expect "New perms are:"
expect "MANAGERS u2"
tsh "
( echo READERS u6\; echo MANAGERS u2 ) | ssh u1 setperms foo/u1/u1r1;
ok; !/invalid permission category MANAGERS/
/New perms are:/
/READERS u6/
/MANAGERS u2/
"
runlocal git fetch
runlocal git reset --hard origin/master

View File

@ -162,4 +162,4 @@ do
done
# this keeps changing as we add tests
echo 1..3157
echo 1..3163