Ejemplo n.º 1
0
def test_git_daemon_export_ok_allowed_all():
    tmp = maketemp()

    for repo in ["foo.git", "quux.git", "thud.git"]:
        path = os.path.join(tmp, repo)
        os.mkdir(path)

    # try to provoke an invalid allow
    writeFile(gitdaemon.export_ok_path(os.path.join(tmp, "thud.git")), "")

    cfg = RawConfigParser()
    cfg.add_section("gitosis")
    cfg.set("gitosis", "repositories", tmp)
    cfg.set("gitosis", "daemon-if-all", "yes")
    cfg.add_section("group all")
    cfg.set("group all", "readonly", "foo")
    cfg.add_section("group boo")
    cfg.set("group boo", "members", "@all")
    cfg.set("group boo", "readonly", "quux thud")
    cfg.add_section("repo thud")
    # this is still hidden
    cfg.set("repo thud", "daemon", "no")
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(os.path.join(tmp, "foo.git")), True)
    eq(exported(os.path.join(tmp, "quux.git")), True)
    eq(exported(os.path.join(tmp, "thud.git")), False)
Ejemplo n.º 2
0
def test_git_daemon_export_ok_allowed_global():
    tmp = maketemp()

    for repo in [
            'foo.git',
            'quux.git',
            'thud.git',
    ]:
        path = os.path.join(tmp, repo)
        os.mkdir(path)

    # try to provoke an invalid allow
    writeFile(gitdaemon.export_ok_path(os.path.join(tmp, 'thud.git')), '')

    cfg = RawConfigParser()
    cfg.add_section('gitosis')
    cfg.set('gitosis', 'repositories', tmp)
    cfg.set('gitosis', 'daemon', 'yes')
    cfg.add_section('repo foo')
    cfg.add_section('repo quux')
    # same as default, no effect
    cfg.set('repo quux', 'daemon', 'yes')
    cfg.add_section('repo thud')
    # this is still hidden
    cfg.set('repo thud', 'daemon', 'no')
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(os.path.join(tmp, 'foo.git')), True)
    eq(exported(os.path.join(tmp, 'quux.git')), True)
    eq(exported(os.path.join(tmp, 'thud.git')), False)
Ejemplo n.º 3
0
def test_git_daemon_export_ok_allowed_global():
    tmp = maketemp()

    for repo in ["foo.git", "quux.git", "thud.git"]:
        path = os.path.join(tmp, repo)
        os.mkdir(path)

    # try to provoke an invalid allow
    writeFile(gitdaemon.export_ok_path(os.path.join(tmp, "thud.git")), "")

    cfg = RawConfigParser()
    cfg.add_section("gitosis")
    cfg.set("gitosis", "repositories", tmp)
    cfg.set("gitosis", "daemon", "yes")
    cfg.add_section("repo foo")
    cfg.add_section("repo quux")
    # same as default, no effect
    cfg.set("repo quux", "daemon", "yes")
    cfg.add_section("repo thud")
    # this is still hidden
    cfg.set("repo thud", "daemon", "no")
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(os.path.join(tmp, "foo.git")), True)
    eq(exported(os.path.join(tmp, "quux.git")), True)
    eq(exported(os.path.join(tmp, "thud.git")), False)
Ejemplo n.º 4
0
def test_git_daemon_export_ok_allowed_all():
    tmp = maketemp()

    for repo in [
            'foo.git',
            'quux.git',
            'thud.git',
    ]:
        path = os.path.join(tmp, repo)
        os.mkdir(path)

    # try to provoke an invalid allow
    writeFile(gitdaemon.export_ok_path(os.path.join(tmp, 'thud.git')), '')

    cfg = RawConfigParser()
    cfg.add_section('gitosis')
    cfg.set('gitosis', 'repositories', tmp)
    cfg.set('gitosis', 'daemon-if-all', 'yes')
    cfg.add_section('group all')
    cfg.set('group all', 'readonly', 'foo')
    cfg.add_section('group boo')
    cfg.set('group boo', 'members', '@all')
    cfg.set('group boo', 'readonly', 'quux thud')
    cfg.add_section('repo thud')
    # this is still hidden
    cfg.set('repo thud', 'daemon', 'no')
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(os.path.join(tmp, 'foo.git')), True)
    eq(exported(os.path.join(tmp, 'quux.git')), True)
    eq(exported(os.path.join(tmp, 'thud.git')), False)
Ejemplo n.º 5
0
def test_git_daemon_export_ok_denied_default():
    tmp = maketemp()
    path = os.path.join(tmp, 'foo.git')
    os.mkdir(path)
    writeFile(gitdaemon.export_ok_path(path), '')
    cfg = RawConfigParser()
    cfg.add_section('gitosis')
    cfg.set('gitosis', 'repositories', tmp)
    cfg.add_section('repo foo')
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(path), False)
Ejemplo n.º 6
0
def test_git_daemon_export_ok_denied_default():
    tmp = maketemp()
    path = os.path.join(tmp, "foo.git")
    os.mkdir(path)
    writeFile(gitdaemon.export_ok_path(path), "")
    cfg = RawConfigParser()
    cfg.add_section("gitosis")
    cfg.set("gitosis", "repositories", tmp)
    cfg.add_section("repo foo")
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(path), False)
Ejemplo n.º 7
0
def test_git_daemon_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(gitdaemon.export_ok_path(path), '')
    cfg = RawConfigParser()
    cfg.add_section('gitosis')
    cfg.set('gitosis', 'repositories', tmp)
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(path), False)
Ejemplo n.º 8
0
def test_git_daemon_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(gitdaemon.export_ok_path(path), "")
    cfg = RawConfigParser()
    cfg.add_section("gitosis")
    cfg.set("gitosis", "repositories", tmp)
    gitdaemon.set_export_ok(config=cfg)
    eq(exported(path), False)
Ejemplo n.º 9
0
def exported(path):
    assert os.path.isdir(path)
    p = gitdaemon.export_ok_path(path)
    return os.path.exists(p)
Ejemplo n.º 10
0
def exported(path):
    assert os.path.isdir(path)
    p = gitdaemon.export_ok_path(path)
    return os.path.exists(p)