gitolite/t/t50-sequence-test
Sitaram Chamarty 047790140a custom perm categories in setperms (WARNING: PLEASE READ FULL COMMIT MESSAGE)
THE COMPILED CONFIG FILE FORMAT CHANGES WITH THIS VERSION.  PLEASE DO
NOT MIX VERSIONS OR DOWNGRADE.  Upgrading using normal gitolite upgrade
means should be fine, though.

Originally, we only allowed "R" and "RW" as categories of users supplied
to the `setperms` command.  These map respectively to "READERS" and
"WRITERS" in the access rules.

Now:

  - we prefer READERS instead of R and WRITERS instead of RW
  - we allow the admin to define other categories as she wishes
    (example: MANAGERS, TESTERS, etc).  These do not have abbreviations,
    however, so they must be supplied in full.

PLEASE, *PLEASE*, read the section in doc/wildcard-repositories.mkd for
more info.  This is a VERY powerful feature and if you're not careful
you could mess up the ACLs nicely.

Backward compat note: you can continue to use the "R" and "RW"
categories when running the "setperms" command, and gitolite will
internally convert them to READERS and WRITERS categories.

----

implementation notes:

  - new RC var called GL_WILDREPOS_PERM_CATS that is a space-sep list of
    the allowed categories in a gl-perms file; defaults to "R RW" if not
    specified

  - wild_repo_rights no longer returns $c, $r, $wC, where $r = $user if
    "R $user", $r = '@all' if "R @all", and similarly with $w and "RW".

    Instead it returns $c and a new hash that effectively gives the same
    info, but expanded to include any other valid categories (listed in
    GL_WILDREPOS_PERM_CATS)

  - consequently, the arguments that parse_acl takes also change the
    same way

  - (side note: R and RW are quietly converted to READERS and WRITERS;
    however, new categories that you define yourself do not have
    abbreviations)

  - setperms validates perms to make sure only allowed categories are
    used; however even if someone changed them behind the scenes,
    wild_repo_rights will also check.  This is necessary in case the
    admin tightened up GL_WILDREPOS_PERM_CATS after someone had already
    setperms-d his repos.

  - as a bonus, we eliminate all the post-Dumper shenanigans, at least
    for READERS and WRITERS.  Those two now look, to the compile script,
    just like any other usernames.
2010-11-06 21:03:34 +05:30

96 lines
2.2 KiB
Plaintext

# vim: syn=sh:
for bc in 0 1
do
cd $TESTDIR
$TESTDIR/rollback || die "rollback failed"
editrc GL_WILDREPOS 1
editrc GL_BIG_CONFIG $bc
# ----------
name "INTERNAL"
echo "
@staff = u1 u2 u3
@gfoo = foo/CREATOR/.+
repo @gfoo
C = u1
RW+ = CREATOR
RW = WRITERS
- = @staff
" | ugc
cd ~/td
runlocal git clone u1:foo/u1/bar
expect "Initialized empty Git repository in /home/gitolite-test/repositories/foo/u1/bar.git/"
cd bar
mdc u1file1
runlocal git push origin master
expect "To u1:foo/u1/bar"
expect "\[new branch\] master -> master"
echo RW u2 | runlocal ssh u1 setperms foo/u1/bar
runlocal ssh u1 getperms foo/u1/bar
expect "WRITERS u2"
name "expand"
runlocal ssh u2 expand
expect "R W .(u1).foo/u1/bar"
name "push"
cd ~/td
runlocal git clone u2:foo/u1/bar u2bar
expect "Cloning into u2bar..."
cd u2bar
mdc u2file1
runlocal git push
expect "master -> master"
notexpect "DENIED"
notexpect "failed to push"
name "INTERNAL"
cd $TESTDIR
$TESTDIR/rollback || die "rollback failed"
editrc GL_WILDREPOS 1
editrc GL_BIG_CONFIG $bc
# ----------
name "INTERNAL"
echo "
@staff = u1 u2 u3
@gfoo = foo/CREATOR/.+
repo @gfoo
C = u1
RW+ = CREATOR
- = @staff
RW = WRITERS
" | ugc -r
cd ~/td
runlocal git clone u1:foo/u1/bar
expect "Cloning into bar..."
cd bar
mdc u1file1
runlocal git push origin master
expect "To u1:foo/u1/bar"
expect "\[new branch\] master -> master"
echo RW u2 | runlocal ssh u1 setperms foo/u1/bar
runlocal ssh u1 getperms foo/u1/bar
expect "WRITERS u2"
name "expand"
runlocal ssh u2 expand
expect " R W .(u1).foo/u1/bar"
name "push"
cd ~/td
runlocal git clone u2:foo/u1/bar u2bar
expect "Cloning into u2bar..."
cd u2bar
mdc u2file1
runlocal git push
expect "remote: W refs/heads/master u2 DENIED by refs/.\*"
name INTERNAL
done