Mercurial > hg-stable
changeset 3426:bb00a5a92c30
Add a test for the acl extension
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 16 Oct 2006 15:38:53 -0300 |
parents | ec6f400cff4d |
children | 6bd676ee8b99 |
files | tests/test-acl tests/test-acl.out |
diffstat | 2 files changed, 575 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-acl Mon Oct 16 15:38:53 2006 -0300 @@ -0,0 +1,104 @@ +#!/bin/sh + +do_push() +{ + user=$1 + shift + + echo "Pushing as user $user" + echo 'hgrc = """' + sed -e 1,2d b/.hg/hgrc + echo '"""' + if [ -e acl.config ]; then + echo 'acl.config = """' + cat acl.config + echo '"""' + fi + LOGNAME=$user hg --cwd a --debug push ../b + hg --cwd b rollback + hg --cwd b --quiet tip + echo +} + +hg init a +cd a +mkdir foo foo/Bar quux +echo 'in foo' > foo/file.txt +echo 'in foo/Bar' > foo/Bar/file.txt +echo 'in quux' > quux/file.py +hg add +hg ci -m 'add files' -d '1000000 0' +echo >> foo/file.txt +hg ci -m 'change foo/file' -d '1000001 0' +echo >> foo/Bar/file.txt +hg ci -m 'change foo/Bar/file' -d '1000002 0' +echo >> quux/file.py +hg ci -m 'change quux/file' -d '1000003 0' +hg tip --quiet + +cd .. +hg clone -r 0 a b + +echo '[extensions]' >> $HGRCPATH +echo 'hgext.acl =' >> $HGRCPATH + +config=b/.hg/hgrc + +echo + +echo 'Extension disabled for lack of a hook' +do_push fred + +echo '[hooks]' >> $config +echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config + +echo 'Extension disabled for lack of acl.sources' +do_push fred + +echo 'No [acl.allow]/[acl.deny]' +echo '[acl]' >> $config +echo 'sources = push' >> $config +do_push fred + +echo 'Empty [acl.allow]' +echo '[acl.allow]' >> $config +do_push fred + +echo 'fred is allowed inside foo/' +echo 'foo/** = fred' >> $config +do_push fred + +echo 'Empty [acl.deny]' +echo '[acl.deny]' >> $config +do_push barney + +echo 'fred is allowed inside foo/, but not foo/bar/ (case matters)' +echo 'foo/bar/** = fred' >> $config +do_push fred + +echo 'fred is allowed inside foo/, but not foo/Bar/' +echo 'foo/Bar/** = fred' >> $config +do_push fred + +echo 'barney is not mentioned => not allowed anywhere' +do_push barney + +echo 'barney is allowed everywhere' +echo '[acl.allow]' >> $config +echo '** = barney' >> $config +do_push barney + +echo 'wilma can change files with a .txt extension' +echo '**/*.txt = wilma' >> $config +do_push wilma + +echo 'file specified by acl.config does not exist' +echo '[acl]' >> $config +echo 'config = ../acl.config' >> $config +do_push barney + +echo 'betty is allowed inside foo/ by a acl.config file' +echo '[acl.allow]' >> acl.config +echo 'foo/** = betty' >> acl.config +do_push betty +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-acl.out Mon Oct 16 15:38:53 2006 -0300 @@ -0,0 +1,471 @@ +adding foo/Bar/file.txt +adding foo/file.txt +adding quux/file.py +3:911600dab2ae +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 3 changes to 3 files +3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Extension disabled for lack of a hook +Pushing as user fred +hgrc = """ +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +rolling back last transaction +0:6675d58eff77 + +Extension disabled for lack of acl.sources +Pushing as user fred +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow not enabled +acl: acl.deny not enabled +acl: changes have source "push" - skipping +rolling back last transaction +0:6675d58eff77 + +No [acl.allow]/[acl.deny] +Pushing as user fred +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow not enabled +acl: acl.deny not enabled +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: allowing changeset 911600dab2ae +rolling back last transaction +0:6675d58eff77 + +Empty [acl.allow] +Pushing as user fred +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 0 entries for user fred +acl: acl.deny not enabled +acl: user fred not allowed on foo/file.txt +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374 +abort: acl: access denied for changeset ef1ea85a6374 +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +fred is allowed inside foo/ +Pushing as user fred +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user fred +acl: acl.deny not enabled +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: user fred not allowed on quux/file.py +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae +abort: acl: access denied for changeset 911600dab2ae +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +Empty [acl.deny] +Pushing as user barney +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 0 entries for user barney +acl: acl.deny enabled, 0 entries for user barney +acl: user barney not allowed on foo/file.txt +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374 +abort: acl: access denied for changeset ef1ea85a6374 +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +fred is allowed inside foo/, but not foo/bar/ (case matters) +Pushing as user fred +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user fred +acl: acl.deny enabled, 1 entries for user fred +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: user fred not allowed on quux/file.py +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae +abort: acl: access denied for changeset 911600dab2ae +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +fred is allowed inside foo/, but not foo/Bar/ +Pushing as user fred +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +foo/Bar/** = fred +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user fred +acl: acl.deny enabled, 2 entries for user fred +acl: allowing changeset ef1ea85a6374 +acl: user fred denied on foo/Bar/file.txt +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset f9cafe1212c8 +abort: acl: access denied for changeset f9cafe1212c8 +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +barney is not mentioned => not allowed anywhere +Pushing as user barney +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +foo/Bar/** = fred +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 0 entries for user barney +acl: acl.deny enabled, 0 entries for user barney +acl: user barney not allowed on foo/file.txt +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374 +abort: acl: access denied for changeset ef1ea85a6374 +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +barney is allowed everywhere +Pushing as user barney +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +foo/Bar/** = fred +[acl.allow] +** = barney +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user barney +acl: acl.deny enabled, 0 entries for user barney +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: allowing changeset 911600dab2ae +rolling back last transaction +0:6675d58eff77 + +wilma can change files with a .txt extension +Pushing as user wilma +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +foo/Bar/** = fred +[acl.allow] +** = barney +**/*.txt = wilma +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user wilma +acl: acl.deny enabled, 0 entries for user wilma +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: user wilma not allowed on quux/file.py +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae +abort: acl: access denied for changeset 911600dab2ae +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 + +file specified by acl.config does not exist +Pushing as user barney +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +foo/Bar/** = fred +[acl.allow] +** = barney +**/*.txt = wilma +[acl] +config = ../acl.config +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user barney +acl: acl.deny enabled, 0 entries for user barney +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: allowing changeset 911600dab2ae +rolling back last transaction +0:6675d58eff77 + +betty is allowed inside foo/ by a acl.config file +Pushing as user betty +hgrc = """ +[hooks] +pretxnchangegroup.acl = python:hgext.acl.hook +[acl] +sources = push +[acl.allow] +foo/** = fred +[acl.deny] +foo/bar/** = fred +foo/Bar/** = fred +[acl.allow] +** = barney +**/*.txt = wilma +[acl] +config = ../acl.config +""" +acl.config = """ +[acl.allow] +foo/** = betty +""" +pushing to ../b +searching for changes +common changesets up to 6675d58eff77 +adding changesets +add changeset ef1ea85a6374 +add changeset f9cafe1212c8 +add changeset 911600dab2ae +adding manifests +adding file changes +adding foo/Bar/file.txt revisions +adding foo/file.txt revisions +adding quux/file.py revisions +added 3 changesets with 3 changes to 3 files +calling hook pretxnchangegroup.acl: hgext.acl.hook +acl: acl.allow enabled, 1 entries for user betty +acl: acl.deny enabled, 0 entries for user betty +acl: allowing changeset ef1ea85a6374 +acl: allowing changeset f9cafe1212c8 +acl: user betty not allowed on quux/file.py +error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae +abort: acl: access denied for changeset 911600dab2ae +transaction abort! +rollback completed +no rollback information available +0:6675d58eff77 +