|
Pierre-Yves Chibon |
274e60 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
"""
|
|
Pierre-Yves Chibon |
274e60 |
(c) 2017 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
Authors:
|
|
Pierre-Yves Chibon |
274e60 |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
"""
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
626417 |
|
|
Pierre-Yves Chibon |
274e60 |
import datetime
|
|
Pierre-Yves Chibon |
274e60 |
import os
|
|
Pierre-Yves Chibon |
274e60 |
import shutil
|
|
Pierre-Yves Chibon |
274e60 |
import sys
|
|
Pierre-Yves Chibon |
274e60 |
import tempfile
|
|
Pierre-Yves Chibon |
274e60 |
import time
|
|
Pierre-Yves Chibon |
274e60 |
import unittest
|
|
Aurélien Bompard |
619e2a |
from io import open
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
import pygit2
|
|
Pierre-Yves Chibon |
274e60 |
from mock import patch, MagicMock
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
sys.path.insert(
|
|
Pierre-Yves Chibon |
73d120 |
0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
import pagure.lib.git
|
|
Pierre-Yves Chibon |
930073 |
import pagure.lib.query
|
|
Pierre-Yves Chibon |
274e60 |
import tests
|
|
Pierre-Yves Chibon |
274e60 |
from pagure.lib.repo import PagureRepo
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
CORE_CONFIG = """repo test
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/test
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/test
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/test
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo test2
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/test2
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/test2
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/test2
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou"""
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
class PagureLibGitoliteConfigtests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
274e60 |
""" Tests for pagure.lib.git """
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
maxDiff = None
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
274e60 |
def setUp(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Set up the environnment, ran before every tests. """
|
|
Pierre-Yves Chibon |
274e60 |
super(PagureLibGitoliteConfigtests, self).setUp()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
self.outputconf = os.path.join(self.path, "test_gitolite.conf")
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
self.preconf = os.path.join(self.path, "header_gitolite")
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.preconf, "w") as stream:
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("# this is a header that is manually added\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("@group1 = foo bar baz\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("@group2 = threebean puiterwijk kevin pingou\n")
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
self.postconf = os.path.join(self.path, "footer_gitolite")
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.postconf, "w", encoding="utf-8") as stream:
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("# end of generated configuration\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write(r"# \ó/")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("\n# end of footer\n")
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
def tearDown(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Tearn down the environnment, ran before every tests. """
|
|
Pierre-Yves Chibon |
274e60 |
super(PagureLibGitoliteConfigtests, self).tearDown()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
if os.path.exists(self.outputconf):
|
|
Pierre-Yves Chibon |
274e60 |
os.unlink(self.outputconf)
|
|
Pierre-Yves Chibon |
274e60 |
self.assertFalse(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
def test_write_gitolite_pre_post_projectNone(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Test the write_gitolite_acls function of pagure.lib.git with
|
|
Pierre-Yves Chibon |
274e60 |
a postconf set """
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
274e60 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
274e60 |
self.session,
|
|
Pierre-Yves Chibon |
274e60 |
self.outputconf,
|
|
Pierre-Yves Chibon |
274e60 |
project=None,
|
|
Pierre-Yves Chibon |
274e60 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
73d120 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
274e60 |
)
|
|
Pierre-Yves Chibon |
274e60 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "r") as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
exp = (
|
|
Pierre-Yves Chibon |
73d120 |
r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
274e60 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
274e60 |
%s
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
274e60 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
274e60 |
# \ó/
|
|
Pierre-Yves Chibon |
274e60 |
# end of footer
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
% CORE_CONFIG
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
274e60 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Lubomír Sedlář |
a25e58 |
def test_write_gitolite_pre_post_projectNone_to_existing_file(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Test the write_gitolite_acls function of pagure.lib.git with
|
|
Lubomír Sedlář |
a25e58 |
a postconf set with existing output file """
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
274e60 |
pass
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
274e60 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
274e60 |
self.session,
|
|
Pierre-Yves Chibon |
274e60 |
self.outputconf,
|
|
Pierre-Yves Chibon |
274e60 |
project=None,
|
|
Pierre-Yves Chibon |
274e60 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
73d120 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
274e60 |
)
|
|
Pierre-Yves Chibon |
274e60 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
with open(self.outputconf) as stream:
|
|
Pierre-Yves Chibon |
274e60 |
data = stream.read()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(data, "")
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
def test_write_gitolite_pre_post_project_1(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Test the write_gitolite_acls function of pagure.lib.git with
|
|
Pierre-Yves Chibon |
274e60 |
a postconf set """
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
274e60 |
pass
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
274e60 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
274e60 |
self.session,
|
|
Pierre-Yves Chibon |
274e60 |
self.outputconf,
|
|
Pierre-Yves Chibon |
274e60 |
project=-1,
|
|
Pierre-Yves Chibon |
274e60 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
73d120 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
274e60 |
)
|
|
Pierre-Yves Chibon |
274e60 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
exp = (
|
|
Pierre-Yves Chibon |
73d120 |
r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
274e60 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
274e60 |
%s
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
274e60 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
274e60 |
# \ó/
|
|
Pierre-Yves Chibon |
274e60 |
# end of footer
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
% CORE_CONFIG
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
274e60 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
def test_write_gitolite_pre_post_project_test(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Test the write_gitolite_acls function of pagure.lib.git with
|
|
Pierre-Yves Chibon |
274e60 |
a postconf set """
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
274e60 |
pass
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
274e60 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
274e60 |
self.session,
|
|
Pierre-Yves Chibon |
274e60 |
self.outputconf,
|
|
Pierre-Yves Chibon |
274e60 |
project=project,
|
|
Pierre-Yves Chibon |
274e60 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
73d120 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
274e60 |
)
|
|
Pierre-Yves Chibon |
274e60 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Karsten Hopp |
b310af |
exp = r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
274e60 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
274e60 |
repo test
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/test
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/test
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/test
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
274e60 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
274e60 |
# \ó/
|
|
Pierre-Yves Chibon |
274e60 |
# end of footer
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
274e60 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
def test_write_gitolite_pre_post_project_test_full_file(self):
|
|
Pierre-Yves Chibon |
274e60 |
""" Test the write_gitolite_acls function of pagure.lib.git with
|
|
Pierre-Yves Chibon |
274e60 |
a postconf set """
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
# Re-generate the gitolite config for all the projects
|
|
Pierre-Yves Chibon |
274e60 |
self.test_write_gitolite_pre_post_project_1()
|
|
Pierre-Yves Chibon |
274e60 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
274e60 |
project.user_id = 2
|
|
Pierre-Yves Chibon |
274e60 |
self.session.add(project)
|
|
Pierre-Yves Chibon |
274e60 |
self.session.commit()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_project(
|
|
Pierre-Yves Chibon |
274e60 |
self.session,
|
|
Pierre-Yves Chibon |
274e60 |
project=project,
|
|
Pierre-Yves Chibon |
73d120 |
new_user="pingou",
|
|
Pierre-Yves Chibon |
73d120 |
user="foo",
|
|
Pierre-Yves Chibon |
73d120 |
access="commit",
|
|
Pierre-Yves Chibon |
274e60 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User added")
|
|
Pierre-Yves Chibon |
274e60 |
self.session.commit()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
274e60 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
274e60 |
self.session,
|
|
Pierre-Yves Chibon |
274e60 |
self.outputconf,
|
|
Pierre-Yves Chibon |
274e60 |
project=project,
|
|
Pierre-Yves Chibon |
274e60 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
73d120 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
274e60 |
)
|
|
Pierre-Yves Chibon |
274e60 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Karsten Hopp |
b310af |
exp = r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
274e60 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
274e60 |
repo test2
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/test2
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/test2
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/test2
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/somenamespace/test3
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo test
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = foo
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo docs/test
|
|
Pierre-Yves Chibon |
274e60 |
R = @all
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = foo
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo tickets/test
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = foo
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
repo requests/test
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = foo
|
|
Pierre-Yves Chibon |
274e60 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
ccb160 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
ccb160 |
# \ó/
|
|
Pierre-Yves Chibon |
ccb160 |
# end of footer
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch.dict(
|
|
Pierre-Yves Chibon |
73d120 |
"pagure.config.config", {"ENABLE_DOCS": False, "ENABLE_TICKETS": False}
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Slavek Kabrda |
e28041 |
def test_write_gitolite_disabled_docs_tickets(self):
|
|
Slavek Kabrda |
e28041 |
""" Test the write_gitolite_acls function when docs and tickets
|
|
Slavek Kabrda |
e28041 |
are disabled """
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
# Re-generate the gitolite config for all the projects
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Slavek Kabrda |
e28041 |
project.user_id = 2
|
|
Slavek Kabrda |
e28041 |
self.session.add(project)
|
|
Slavek Kabrda |
e28041 |
self.session.commit()
|
|
Slavek Kabrda |
e28041 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_project(
|
|
Slavek Kabrda |
e28041 |
self.session,
|
|
Slavek Kabrda |
e28041 |
project=project,
|
|
Pierre-Yves Chibon |
73d120 |
new_user="pingou",
|
|
Pierre-Yves Chibon |
73d120 |
user="foo",
|
|
Pierre-Yves Chibon |
73d120 |
access="commit",
|
|
Slavek Kabrda |
e28041 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User added")
|
|
Slavek Kabrda |
e28041 |
self.session.commit()
|
|
Slavek Kabrda |
e28041 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Slavek Kabrda |
e28041 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, self.outputconf, project=project
|
|
Slavek Kabrda |
e28041 |
)
|
|
Slavek Kabrda |
e28041 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
exp = """repo test
|
|
Slavek Kabrda |
e28041 |
R = @all
|
|
Slavek Kabrda |
e28041 |
RW+ = foo
|
|
Slavek Kabrda |
e28041 |
RW+ = pingou
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
repo requests/test
|
|
Slavek Kabrda |
e28041 |
RW+ = foo
|
|
Slavek Kabrda |
e28041 |
RW+ = pingou
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
repo test2
|
|
Slavek Kabrda |
e28041 |
R = @all
|
|
Slavek Kabrda |
e28041 |
RW+ = pingou
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
repo requests/test2
|
|
Slavek Kabrda |
e28041 |
RW+ = pingou
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
repo somenamespace/test3
|
|
Slavek Kabrda |
e28041 |
R = @all
|
|
Slavek Kabrda |
e28041 |
RW+ = pingou
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
repo requests/somenamespace/test3
|
|
Slavek Kabrda |
e28041 |
RW+ = pingou
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
# end of body
|
|
Slavek Kabrda |
e28041 |
"""
|
|
Slavek Kabrda |
e28041 |
self.assertEqual(data, exp)
|
|
Slavek Kabrda |
e28041 |
|
|
Slavek Kabrda |
e28041 |
|
|
Pierre-Yves Chibon |
ccb160 |
class PagureLibGitoliteGroupConfigtests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Tests for generating the gitolite configuration file for a group
|
|
Pierre-Yves Chibon |
ccb160 |
change
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
"""
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
maxDiff = None
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
def setUp(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Set up the environnment, ran before every tests. """
|
|
Pierre-Yves Chibon |
ccb160 |
super(PagureLibGitoliteGroupConfigtests, self).setUp()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.add_group(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
73d120 |
group_name="grp",
|
|
Pierre-Yves Chibon |
73d120 |
display_name="grp group",
|
|
Pierre-Yves Chibon |
ccb160 |
description=None,
|
|
Pierre-Yves Chibon |
73d120 |
group_type="user",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Pierre-Yves Chibon |
ccb160 |
is_admin=False,
|
|
Pierre-Yves Chibon |
ccb160 |
blacklist=[],
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.add_group(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
73d120 |
group_name="grp2",
|
|
Pierre-Yves Chibon |
73d120 |
display_name="grp2 group",
|
|
Pierre-Yves Chibon |
ccb160 |
description=None,
|
|
Pierre-Yves Chibon |
73d120 |
group_type="user",
|
|
Pierre-Yves Chibon |
73d120 |
user="foo",
|
|
Pierre-Yves Chibon |
ccb160 |
is_admin=False,
|
|
Pierre-Yves Chibon |
ccb160 |
blacklist=[],
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.session.commit()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
self.outputconf = os.path.join(self.path, "test_gitolite.conf")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
self.preconf = os.path.join(self.path, "header_gitolite")
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.preconf, "w") as stream:
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("# this is a header that is manually added\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("@group1 = foo bar baz\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("@group2 = threebean puiterwijk kevin pingou\n")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
self.postconf = os.path.join(self.path, "footer_gitolite")
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.postconf, "w") as stream:
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("# end of generated configuration\n")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write(r"# \ó/")
|
|
Pierre-Yves Chibon |
73d120 |
stream.write("\n# end of footer\n")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
def tearDown(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Tearn down the environnment, ran before every tests. """
|
|
Pierre-Yves Chibon |
ccb160 |
super(PagureLibGitoliteGroupConfigtests, self).tearDown()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
if os.path.exists(self.outputconf):
|
|
Pierre-Yves Chibon |
ccb160 |
os.unlink(self.outputconf)
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertFalse(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
def test_write_gitolite_project_test_group(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Test the write_gitolite_acls when updating a single group. """
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
ccb160 |
pass
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
group = pagure.lib.query.search_groups(self.session, group_name="grp")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
ccb160 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
ccb160 |
self.outputconf,
|
|
Pierre-Yves Chibon |
ccb160 |
project=project,
|
|
Pierre-Yves Chibon |
ccb160 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
ccb160 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
ccb160 |
group=group,
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Karsten Hopp |
b310af |
exp = r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
ccb160 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
ccb160 |
@grp = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo test
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo docs/test
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo tickets/test
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo requests/test
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
ccb160 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
ccb160 |
# \ó/
|
|
Pierre-Yves Chibon |
ccb160 |
# end of footer
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
def test_write_gitolite_project_test_all_groups(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Test the write_gitolite_acls when updating all groups. """
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
ccb160 |
pass
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
ccb160 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
ccb160 |
self.outputconf,
|
|
Pierre-Yves Chibon |
ccb160 |
project=project,
|
|
Pierre-Yves Chibon |
ccb160 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
ccb160 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Karsten Hopp |
b310af |
exp = r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
ccb160 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
ccb160 |
@grp = pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
ccb160 |
# end of groups
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo test
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo docs/test
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo tickets/test
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo requests/test
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
ccb160 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
ccb160 |
# \ó/
|
|
Pierre-Yves Chibon |
ccb160 |
# end of footer
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
def test_write_gitolite_project_all_projects_groups(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Test the generating the entire gitolite config. """
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
ccb160 |
pass
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
ccb160 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
ccb160 |
self.outputconf,
|
|
Pierre-Yves Chibon |
ccb160 |
project=-1,
|
|
Pierre-Yves Chibon |
ccb160 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
ccb160 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
exp = (
|
|
Pierre-Yves Chibon |
73d120 |
r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
ccb160 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
ccb160 |
@grp = pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
ccb160 |
# end of groups
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
%s
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
ccb160 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
ccb160 |
# \ó/
|
|
Pierre-Yves Chibon |
ccb160 |
# end of footer
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
% CORE_CONFIG
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
def test_write_gitolite_project_all_projects_one_group(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Test the generating the entire gitolite config. """
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# Generate the full gitolite config that we will update
|
|
Pierre-Yves Chibon |
ccb160 |
self.test_write_gitolite_project_all_projects_groups()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
group = pagure.lib.query.search_groups(self.session, group_name="grp")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# Let's add `foo` to `grp` so something changes
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_group(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
73d120 |
username="foo",
|
|
Pierre-Yves Chibon |
ccb160 |
group=group,
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Pierre-Yves Chibon |
ccb160 |
is_admin=False,
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User `foo` added to the group `grp`.")
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# Let's add `foo` to `test` so the project changes as well
|
|
Pierre-Yves Chibon |
930073 |
msg = pagure.lib.query.add_user_to_project(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
ccb160 |
project=project,
|
|
Pierre-Yves Chibon |
73d120 |
new_user="foo",
|
|
Pierre-Yves Chibon |
73d120 |
user="pingou",
|
|
Pierre-Yves Chibon |
73d120 |
access="commit",
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(msg, "User added")
|
|
Pierre-Yves Chibon |
ccb160 |
self.session.commit()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
ccb160 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
ccb160 |
self.outputconf,
|
|
Pierre-Yves Chibon |
ccb160 |
project=project,
|
|
Pierre-Yves Chibon |
ccb160 |
group=group,
|
|
Pierre-Yves Chibon |
ccb160 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
ccb160 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Karsten Hopp |
b310af |
exp = r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
ccb160 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
ccb160 |
@grp = foo pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
ccb160 |
# end of groups
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo test2
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo docs/test2
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo tickets/test2
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo requests/test2
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo somenamespace/test3
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo docs/somenamespace/test3
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo tickets/somenamespace/test3
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo requests/somenamespace/test3
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo test
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = foo
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo docs/test
|
|
Pierre-Yves Chibon |
ccb160 |
R = @all
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = foo
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo tickets/test
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = foo
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
repo requests/test
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
ccb160 |
RW+ = foo
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
274e60 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
274e60 |
# \ó/
|
|
Pierre-Yves Chibon |
274e60 |
# end of footer
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
274e60 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
274e60 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
ccb160 |
def test_write_gitolite_delete_group(self):
|
|
Pierre-Yves Chibon |
ccb160 |
""" Test the updating the gitolite config after having
|
|
Pierre-Yves Chibon |
ccb160 |
deleted a group.
|
|
Pierre-Yves Chibon |
ccb160 |
"""
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# Generate the full gitolite config that we will update
|
|
Pierre-Yves Chibon |
ccb160 |
self.test_write_gitolite_project_all_projects_groups()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# Delete the group `grp`
|
|
Pierre-Yves Chibon |
930073 |
self.assertEqual(len(pagure.lib.query.search_groups(self.session)), 2)
|
|
Pierre-Yves Chibon |
73d120 |
group = pagure.lib.query.search_groups(self.session, group_name="grp")
|
|
Pierre-Yves Chibon |
ccb160 |
self.session.delete(group)
|
|
Pierre-Yves Chibon |
ccb160 |
self.session.commit()
|
|
Pierre-Yves Chibon |
930073 |
self.assertEqual(len(pagure.lib.query.search_groups(self.session)), 1)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
ccb160 |
helper.write_gitolite_acls(
|
|
Pierre-Yves Chibon |
ccb160 |
self.session,
|
|
Pierre-Yves Chibon |
ccb160 |
self.outputconf,
|
|
Pierre-Yves Chibon |
ccb160 |
project=None,
|
|
Pierre-Yves Chibon |
ccb160 |
preconf=self.preconf,
|
|
Pierre-Yves Chibon |
ccb160 |
postconf=self.postconf,
|
|
Pierre-Yves Chibon |
ccb160 |
)
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
exp = (
|
|
Pierre-Yves Chibon |
73d120 |
r"""# this is a header that is manually added
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
@group1 = foo bar baz
|
|
Pierre-Yves Chibon |
ccb160 |
@group2 = threebean puiterwijk kevin pingou
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of header
|
|
Pierre-Yves Chibon |
ccb160 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
ccb160 |
# end of groups
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
%s
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
ccb160 |
# end of body
|
|
Pierre-Yves Chibon |
ccb160 |
# end of generated configuration
|
|
Pierre-Yves Chibon |
ccb160 |
# \ó/
|
|
Pierre-Yves Chibon |
ccb160 |
# end of footer
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
% CORE_CONFIG
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
ccb160 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
ccb160 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git_auth.get_git_auth_helper")
|
|
Pierre-Yves Chibon |
b31a79 |
def test_task_generate_gitolite_acls_one_group(self, get_helper):
|
|
Pierre-Yves Chibon |
b31a79 |
""" Test the generate_gitolite_acls task to ensure if group is None
|
|
Pierre-Yves Chibon |
b31a79 |
then None is passed to the helper. """
|
|
Pierre-Yves Chibon |
b31a79 |
helper = MagicMock()
|
|
Pierre-Yves Chibon |
b31a79 |
get_helper.return_value = helper
|
|
Pierre-Yves Chibon |
930073 |
pagure.lib.query.SESSIONMAKER = self.session.session_factory
|
|
Pierre-Yves Chibon |
b31a79 |
|
|
Pierre-Yves Chibon |
b31a79 |
pagure.lib.tasks.generate_gitolite_acls(
|
|
Pierre-Yves Chibon |
73d120 |
namespace=None, name="test", user=None, group=None
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
b31a79 |
|
|
Patrick Uiterwijk |
ad0b72 |
get_helper.assert_called_with()
|
|
Pierre-Yves Chibon |
b31a79 |
args = helper.generate_acls.call_args
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIsNone(args[1].get("group"))
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIsNotNone(args[1].get("project"))
|
|
Pierre-Yves Chibon |
b31a79 |
|
|
Stefan Bühler |
c92108 |
def test_write_gitolite_project_test_private(self):
|
|
Stefan Bühler |
c92108 |
""" Test the write_gitolite_acls function of pagure.lib.git with
|
|
Stefan Bühler |
c92108 |
a postconf set """
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
# Make the test project private
|
|
Pierre-Yves Chibon |
73d120 |
project = pagure.lib.query._get_project(self.session, "test")
|
|
Stefan Bühler |
c92108 |
project.private = True
|
|
Stefan Bühler |
c92108 |
self.session.add(project)
|
|
Stefan Bühler |
c92108 |
self.session.commit()
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
# Re-generate the gitolite config just for this project
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
73d120 |
helper.write_gitolite_acls(self.session, self.outputconf, project=None)
|
|
Stefan Bühler |
c92108 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Stefan Bühler |
c92108 |
|
|
Aurélien Bompard |
626417 |
exp = """@grp = pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Stefan Bühler |
c92108 |
# end of groups
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo test
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo docs/test
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo tickets/test
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo requests/test
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo test2
|
|
Stefan Bühler |
c92108 |
R = @all
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo docs/test2
|
|
Stefan Bühler |
c92108 |
R = @all
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo tickets/test2
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo requests/test2
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo somenamespace/test3
|
|
Stefan Bühler |
c92108 |
R = @all
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo docs/somenamespace/test3
|
|
Stefan Bühler |
c92108 |
R = @all
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo tickets/somenamespace/test3
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
repo requests/somenamespace/test3
|
|
Stefan Bühler |
c92108 |
RW+ = pingou
|
|
Stefan Bühler |
c92108 |
|
|
Stefan Bühler |
c92108 |
# end of body
|
|
Stefan Bühler |
c92108 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Stefan Bühler |
c92108 |
self.assertEqual(data, exp)
|
|
Stefan Bühler |
c92108 |
|
|
Pierre-Yves Chibon |
5b06f7 |
def test_remove_acls(self):
|
|
Pierre-Yves Chibon |
5b06f7 |
""" Test the remove_acls function of pagure.lib.git when deleting
|
|
Pierre-Yves Chibon |
5b06f7 |
a project """
|
|
Pierre-Yves Chibon |
73d120 |
pagure.config.config["GITOLITE_CONFIG"] = self.outputconf
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
5b06f7 |
pass
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
73d120 |
helper.write_gitolite_acls(self.session, self.outputconf, project=-1)
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
exp = (
|
|
Pierre-Yves Chibon |
73d120 |
"""@grp = pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
5b06f7 |
# end of groups
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
%s
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
# end of body
|
|
Pierre-Yves Chibon |
73d120 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
% CORE_CONFIG
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
# Test removing a project from the existing config
|
|
Pierre-Yves Chibon |
930073 |
project = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, project_name="test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
helper.remove_acls(self.session, project=project)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Aurélien Bompard |
626417 |
exp = """@grp = pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
5b06f7 |
# end of groups
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo test2
|
|
Pierre-Yves Chibon |
5b06f7 |
R = @all
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo docs/test2
|
|
Pierre-Yves Chibon |
5b06f7 |
R = @all
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo tickets/test2
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo requests/test2
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo somenamespace/test3
|
|
Pierre-Yves Chibon |
5b06f7 |
R = @all
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo docs/somenamespace/test3
|
|
Pierre-Yves Chibon |
5b06f7 |
R = @all
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo tickets/somenamespace/test3
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
repo requests/somenamespace/test3
|
|
Pierre-Yves Chibon |
5b06f7 |
RW+ = pingou
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
# end of body
|
|
Pierre-Yves Chibon |
5b06f7 |
"""
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
def test_remove_acls_no_project(self):
|
|
Pierre-Yves Chibon |
5b06f7 |
""" Test the remove_acls function of pagure.lib.git when no project
|
|
Pierre-Yves Chibon |
5b06f7 |
is specified """
|
|
Pierre-Yves Chibon |
73d120 |
pagure.config.config["GITOLITE_CONFIG"] = self.outputconf
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
with open(self.outputconf, "w") as stream:
|
|
Pierre-Yves Chibon |
5b06f7 |
pass
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3")
|
|
Pierre-Yves Chibon |
73d120 |
helper.write_gitolite_acls(self.session, self.outputconf, project=-1)
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertTrue(os.path.exists(self.outputconf))
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
exp = (
|
|
Pierre-Yves Chibon |
73d120 |
"""@grp = pingou
|
|
Aurélien Bompard |
f61bb3 |
@grp2 = foo
|
|
Pierre-Yves Chibon |
5b06f7 |
# end of groups
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
%s
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
# end of body
|
|
Pierre-Yves Chibon |
73d120 |
"""
|
|
Pierre-Yves Chibon |
73d120 |
% CORE_CONFIG
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
73d120 |
# print data
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
# Test nothing changes if no project is specified
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
73d120 |
RuntimeError, helper.remove_acls, self.session, project=None
|
|
Pierre-Yves Chibon |
5b06f7 |
)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
with open(self.outputconf) as stream:
|
|
Aurélien Bompard |
626417 |
data = stream.read()
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
5b06f7 |
self.assertEqual(data, exp)
|
|
Pierre-Yves Chibon |
5b06f7 |
|
|
Pierre-Yves Chibon |
274e60 |
|
|
Pierre-Yves Chibon |
73d120 |
if __name__ == "__main__":
|
|
Pierre-Yves Chibon |
274e60 |
unittest.main(verbosity=2)
|