diff options
author | Tommi Virtanen <tv@eagain.net> | 2007-05-30 13:57:31 +0300 |
---|---|---|
committer | Tommi Virtanen <tv@eagain.net> | 2007-06-04 14:16:26 +0300 |
commit | bd1ee4fc013f169f1c052dc763c3e9ed602502c9 (patch) | |
tree | 04e054b5fe52efb1e801c4098d44bcc9359433d0 /gitosis/test/test_access.py | |
download | gitosis-dakkar-bd1ee4fc013f169f1c052dc763c3e9ed602502c9.tar.gz gitosis-dakkar-bd1ee4fc013f169f1c052dc763c3e9ed602502c9.tar.bz2 gitosis-dakkar-bd1ee4fc013f169f1c052dc763c3e9ed602502c9.zip |
Initial import.
Diffstat (limited to 'gitosis/test/test_access.py')
-rw-r--r-- | gitosis/test/test_access.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/gitosis/test/test_access.py b/gitosis/test/test_access.py new file mode 100644 index 0000000..00b1fe8 --- /dev/null +++ b/gitosis/test/test_access.py @@ -0,0 +1,79 @@ +from nose.tools import eq_ as eq + +from ConfigParser import RawConfigParser + +from gitosis import access + +def test_write_no_simple(): + cfg = RawConfigParser() + eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'), + None) + +def test_write_yes_simple(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'writable', 'foo/bar') + eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'), + 'foo/bar') + +def test_write_no_simple_wouldHaveReadonly(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'readonly', 'foo/bar') + eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'), + None) + +def test_write_yes_map(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'map writable foo/bar', 'quux/thud') + eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'), + 'quux/thud') + +def test_write_no_map_wouldHaveReadonly(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'map readonly foo/bar', 'quux/thud') + eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'), + None) + +def test_read_no_simple(): + cfg = RawConfigParser() + eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'), + None) + +def test_read_yes_simple(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'readonly', 'foo/bar') + eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'), + 'foo/bar') + +def test_read_yes_simple_wouldHaveWritable(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'writable', 'foo/bar') + eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'), + None) + +def test_read_yes_map(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'map readonly foo/bar', 'quux/thud') + eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'), + 'quux/thud') + +def test_read_yes_map_wouldHaveWritable(): + cfg = RawConfigParser() + cfg.add_section('group fooers') + cfg.set('group fooers', 'members', 'jdoe') + cfg.set('group fooers', 'map writable foo/bar', 'quux/thud') + eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'), + None) |