From c35959e946f496a2db67ecc33eea895a6bc96731 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 19 2019 09:19:51 +0000 Subject: [PATCH 1/2] Ensure there are admin groups before adding them to the list of groups If in the config ADMIN_GROUP is defined as None, it was added to the list of groups to query the openid server for. Which resulted in a set containing a None element, which broke loging in. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/flask_app.py b/pagure/flask_app.py index b52f366..dafe585 100644 --- a/pagure/flask_app.py +++ b/pagure/flask_app.py @@ -398,10 +398,13 @@ def auth_login(): # pragma: no cover return flask.redirect(return_point) admins = pagure_config["ADMIN_GROUP"] - if isinstance(admins, list): - admins = set(admins) - else: # pragma: no cover - admins = set([admins]) + if admins: + if isinstance(admins, list): + admins = set(admins) + else: # pragma: no cover + admins = set([admins]) + else: + admins = set() if auth in ["fas", "openid"]: from pagure.ui.fas_login import FAS From 0fb8671248abfe9b84901091c3a78180751407c0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 19 2019 09:19:51 +0000 Subject: [PATCH 2/2] Do not notify about invalid identifier if none is specified If no identifier is specified, there is no point saying it was not found in the list of branches or in the git repo. Fixes https://pagure.io/pagure/issue/4203 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index bc95201..3f659dc 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -962,11 +962,12 @@ def view_tree(repo, identifier=None, username=None, namespace=None): if not repo_obj.head_is_unborn: branchname = repo_obj.head.shorthand commit = repo_obj[repo_obj.head.target] - flask.flash( - "'%s' not found in the git repository, going back to: " - "%s" % (identifier, branchname), - "error", - ) + if identifier: + flask.flash( + "'%s' not found in the git repository, going back " + "to: %s" % (identifier, branchname), + "error", + ) # If we're arriving here from the release page, we may have a Tag # where we expected a commit, in this case, get the actual commit if isinstance(commit, pygit2.Tag): diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 1e89014..ab86f71 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -3175,6 +3175,30 @@ index 0000000..fb7093d self.assertFalse( 'No content found in this repository' in output_text) + # View tree, no identifier: + output = self.app.get('/test/tree/') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn('Tree - test - Pagure', output_text) + self.assertIn('README.rst', output_text) + self.assertNotIn( + 'No content found in this repository', output_text) + self.assertNotIn( + "'None' not found in the git repository, going back to: " + "master", output_text) + + # View tree, invalid identifier: + output = self.app.get('/test/tree/invalid') + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn('Tree - test - Pagure', output_text) + self.assertIn('README.rst', output_text) + self.assertNotIn( + 'No content found in this repository', output_text) + self.assertIn( + "'invalid' not found in the git repository, going back " + "to: master", output_text) + # View tree by branch output = self.app.get('/test/tree/master') self.assertEqual(output.status_code, 200)