From 4a2ab02c044aecb936f950d3d3199c6dc04498d8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 28 2018 08:17:27 +0000 Subject: Tests that the signed-off-by line is added when editing a file online and the project enforces the signed-off-by line to be present on all commits Relates to https://pagure.io/pagure/pull-request/3092 Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index ac89707..2a5bfc1 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -3850,6 +3850,77 @@ index 0000000..fb7093d self.assertIn('', output.data) self.assertTrue(output.data.count('tagid'), 1) + def test_edit_file_no_signed_off(self): + """ Test the edit_file endpoint when signed-off isn't enforced. """ + tests.create_projects(self.session) + tests.create_projects_git( + os.path.join(self.path, 'repos'), bare=True) + + user = tests.FakeUser() + user.username = 'pingou' + with tests.user_set(self.app.application, user): + + # Add some content to the git repo + tests.add_content_git_repo( + os.path.join(self.path, 'repos', 'test.git')) + + output = self.app.get('/test/edit/master/f/sources') + self.assertEqual(output.status_code, 200) + self.assertIn( + '
  • ' + '  master' + '
  • ' + '  sources
  • ', + output.data) + self.assertIn( + '', + output.data) + self.assertIn( + '', output.data + ) + + def test_edit_file_signed_off(self): + """ Test the edit_file endpoint when signed-off is enforced. """ + tests.create_projects(self.session) + tests.create_projects_git( + os.path.join(self.path, 'repos'), bare=True) + + repo = pagure.lib.get_authorized_project(self.session, 'test') + settings = repo.settings + settings['Enforce_signed-off_commits_in_pull-request'] = True + repo.settings = settings + self.session.add(repo) + self.session.commit() + + user = tests.FakeUser() + user.username = 'pingou' + with tests.user_set(self.app.application, user): + + # Add some content to the git repo + tests.add_content_git_repo( + os.path.join(self.path, 'repos', 'test.git')) + + output = self.app.get('/test/edit/master/f/sources') + self.assertEqual(output.status_code, 200) + self.assertIn( + '
  • ' + '  master' + '
  • ' + '  sources
  • ', + output.data) + self.assertIn( + '', + output.data) + self.assertIn( + '', output.data + ) + def test_edit_file(self): """ Test the edit_file endpoint. """