#14 Drop the + access for the groups, it generates an invalid config
Merged 8 years ago by pingou. Opened 8 years ago by pingou.

file modified
+3 -3
@@ -101,7 +101,7 @@ 

  

              access = 'RWC'

              if project.is_fork:

-                 access = 'RW+'

+                 access = 'RW+C'

  

              if repos == '':

                  # First, whitelist the supported branches from PDC
@@ -115,7 +115,7 @@ 

                  config.append(_blacklist)

  

              if project.committer_groups:

-                 config.append('  %s+ = @%s' % (access, ' @'.join(

+                 config.append('  %s = @%s' % (access, ' @'.join(

                      [

                          group.group_name

                          for group in project.committer_groups
@@ -132,7 +132,7 @@ 

                  if deploykey.pushaccess:

                      access = 'RW'

                      if project.is_fork:

-                         access = 'RW+'

+                         access = 'RW+C'

                  # Note: the replace of / with _ is because gitolite

                  # users can't contain a /. At first, this might look

                  # like deploy keys in a project called

file modified
+105 -2
@@ -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

Already hotfixed in prod

1 new commit added

  • Give RW+C to the forks
8 years ago

Other than the fact that this does a lot more than the title says, I am +1 to the last two commits of this branch (cf7dc0bf03c68aa391baa34d3a99c4927bd5bdf4 and c56420ff712b678293e56db4cfe3c4bbbdbed85d)

rebased

8 years ago

rebased

8 years ago

Pull-Request has been merged by pingou

8 years ago