| |
@@ -55,6 +55,8 @@
|
| |
|
| |
repo requests/somenamespace/test3
|
| |
RWC = pingou
|
| |
+
|
| |
+ # end of body
|
| |
"""
|
| |
|
| |
|
| |
@@ -202,11 +204,112 @@
|
| |
|
| |
repo requests/test
|
| |
RWC = foo
|
| |
- RWC = pingou'''
|
| |
- self.assertMultiLineEqual(contents.strip(), expected)
|
| |
+ RWC = pingou
|
| |
+
|
| |
+ # end of body'''
|
| |
+ self.assertMultiLineEqual(expected, contents.strip())
|
| |
|
| |
def test_get_supported_branches(self):
|
| |
""" Test for real what is returned by PDC. """
|
| |
expected = ['master', 'f26', 'f25', 'f24', 'el6']
|
| |
actual = dist_git_auth.get_supported_branches('rpms', 'nethack')
|
| |
self.assertEquals(set(actual), set(expected))
|
| |
+
|
| |
+ @mock.patch('dist_git_auth.get_supported_branches')
|
| |
+ def test_write_gitolite_acls_test_project_w_group(
|
| |
+ self, get_supported_branches):
|
| |
+ """ Test updating the gitolite configuration file for just one
|
| |
+ project (project == a pagure.lib.model.Project).
|
| |
+
|
| |
+ """
|
| |
+
|
| |
+ get_supported_branches.return_value = ['master', 'f9000']
|
| |
+ self.test_write_gitolite_acls()
|
| |
+
|
| |
+ print("Modifying the test project so the output differs.")
|
| |
+ project = pagure.lib._get_project(self.session, 'test')
|
| |
+ project.user_id = 2
|
| |
+ self.session.add(project)
|
| |
+ self.session.commit()
|
| |
+
|
| |
+ # Add a group to a project and someone to this group
|
| |
+ project = pagure.lib._get_project(self.session, 'test')
|
| |
+ msg = pagure.lib.add_group_to_project(
|
| |
+ session=self.session,
|
| |
+ project=project,
|
| |
+ new_group='test_grp',
|
| |
+ user='pingou',
|
| |
+ access='admin',
|
| |
+ create=True,
|
| |
+ is_admin=True)
|
| |
+ self.assertEqual(msg, 'Group added')
|
| |
+ grp = pagure.lib.search_groups(self.session, group_name='test_grp')
|
| |
+ msg = pagure.lib.add_user_to_group(
|
| |
+ session=self.session,
|
| |
+ username='pingou',
|
| |
+ group=grp,
|
| |
+ user='pingou',
|
| |
+ is_admin=False)
|
| |
+ self.session.commit()
|
| |
+
|
| |
+ print("Rewriting %r" % self.configfile)
|
| |
+ project = pagure.lib._get_project(self.session, 'test')
|
| |
+ dist_git_auth.DistGitoliteAuth.write_gitolite_acls(
|
| |
+ self.session,
|
| |
+ configfile=self.configfile,
|
| |
+ project=project
|
| |
+ )
|
| |
+
|
| |
+ print("Checking the contents of %r" % self.configfile)
|
| |
+ with open(self.configfile, 'r') as f:
|
| |
+ contents = f.read()
|
| |
+
|
| |
+ expected = '''@test_grp = pingou
|
| |
+ # end of groups
|
| |
+
|
| |
+ repo test2
|
| |
+ R = @all
|
| |
+ RWC master = pingou
|
| |
+ RWC f9000 = pingou
|
| |
+ - f[0-9][0-9] = @all
|
| |
+ - epel[0-9] = @all
|
| |
+ - epel[0-9][0-9] = @all
|
| |
+ - el[0-9] = @all
|
| |
+ - olpc[0-9] = @all
|
| |
+ RWC = pingou
|
| |
+
|
| |
+ repo requests/test2
|
| |
+ RWC = pingou
|
| |
+
|
| |
+ repo somenamespace/test3
|
| |
+ R = @all
|
| |
+ RWC master = pingou
|
| |
+ RWC f9000 = pingou
|
| |
+ - f[0-9][0-9] = @all
|
| |
+ - epel[0-9] = @all
|
| |
+ - epel[0-9][0-9] = @all
|
| |
+ - el[0-9] = @all
|
| |
+ - olpc[0-9] = @all
|
| |
+ RWC = pingou
|
| |
+
|
| |
+ repo requests/somenamespace/test3
|
| |
+ RWC = pingou
|
| |
+
|
| |
+ repo test
|
| |
+ R = @all
|
| |
+ RWC master = foo
|
| |
+ RWC f9000 = foo
|
| |
+ - f[0-9][0-9] = @all
|
| |
+ - epel[0-9] = @all
|
| |
+ - epel[0-9][0-9] = @all
|
| |
+ - el[0-9] = @all
|
| |
+ - olpc[0-9] = @all
|
| |
+ RWC = @test_grp
|
| |
+ RWC = foo
|
| |
+
|
| |
+ repo requests/test
|
| |
+ RWC = @test_grp
|
| |
+ RWC = foo
|
| |
+
|
| |
+ # end of body'''
|
| |
+ self.assertMultiLineEqual(expected, contents.strip())
|
| |
And add the corresponding unit-tests
Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr