def test_htaccess_export_ok_repo_missing(): # configured but not created yet; before first push tmp = maketemp() cfg = RawConfigParser() cfg.add_section('gitosis') cfg.set('gitosis', 'repositories', tmp) cfg.add_section('repo foo') cfg.set('repo foo', 'daemon', 'yes') htaccess.gen_htaccess(config=cfg) assert not os.path.exists(os.path.join(tmp, 'foo')) assert not os.path.exists(os.path.join(tmp, 'foo.git'))
def test_htaccess_export_ok_all(): tmp = maketemp() path = os.path.join(tmp, 'foo.git') os.mkdir(path) writeFile(htaccess.htaccess_path(path), '') cfg = RawConfigParser() cfg.add_section('gitosis') cfg.set('gitosis', 'repositories', tmp) cfg.add_section('group all') cfg.set('group all', 'readonly', 'foo') htaccess.gen_htaccess(config=cfg) exported(path, None)
def test_htaccess_export_ok_denied_even_not_configured(): # repositories not mentioned in config also get touched; this is # to avoid security trouble, otherwise we might expose (or # continue to expose) old repositories removed from config tmp = maketemp() path = os.path.join(tmp, 'foo.git') os.mkdir(path) writeFile(htaccess.htaccess_path(path), '') cfg = RawConfigParser() cfg.add_section('gitosis') cfg.set('gitosis', 'repositories', tmp) htaccess.gen_htaccess(config=cfg) exported(path, '''\ Order allow,deny Deny from all ''')
def test_htaccess_export_ok_subdirs(): tmp = maketemp() foo = os.path.join(tmp, 'foo') os.mkdir(foo) path = os.path.join(foo, 'bar.git') os.mkdir(path) cfg = RawConfigParser() cfg.add_section('gitosis') cfg.set('gitosis', 'repositories', tmp) cfg.add_section('group some') cfg.set('group some', 'writable', 'foo/bar') cfg.add_section('user jdoe') cfg.set('user jdoe', 'readonly', 'foo/bar') htaccess.gen_htaccess(config=cfg) exported(path, '''\ Require user jdoe Require group some ''')