From 98ab70dcff1a1546e149f7607959cd7189d15ce1 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Mon, 9 Dec 2019 13:34:03 +0100 Subject: [PATCH] fix permission check in CLI --- cli/koji_cli/commands.py | 4 ++-- tests/test_cli/test_remove_group.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index d94209d1..c1f46472 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -118,8 +118,8 @@ def handle_remove_group(goptions, session, args): group = args[1] activate_session(session, goptions) - if not session.hasPerm('admin'): - error(_("This action requires admin privileges")) + if not (session.hasPerm('admin') or session.hasPerm('tag')): + parser.error(_("This action requires tag or admin privileges")) dsttag = session.getTag(tag) if not dsttag: diff --git a/tests/test_cli/test_remove_group.py b/tests/test_cli/test_remove_group.py index d478479e..43147377 100644 --- a/tests/test_cli/test_remove_group.py +++ b/tests/test_cli/test_remove_group.py @@ -33,7 +33,7 @@ class TestRemoveGroup(utils.CliTestCase): session.getTag.return_value = None with self.assertRaises(SystemExit): - rv = handle_remove_group(options, session, arguments) + handle_remove_group(options, session, arguments) # assert that things were called as we expected. activate_session_mock.assert_called_once_with(session, options) @@ -58,7 +58,7 @@ class TestRemoveGroup(utils.CliTestCase): session.getTagGroups.return_value = [] with self.assertRaises(SystemExit): - rv = handle_remove_group(options, session, arguments) + handle_remove_group(options, session, arguments) # assert that things were called as we expected. activate_session_mock.assert_called_once_with(session, options) @@ -111,8 +111,8 @@ class TestRemoveGroup(utils.CliTestCase): stderr=expected, activate_session=None) - # if we don't have 'admin' permission + # if we don't have 'tag' permission session.hasPerm.return_value = False with self.assertRaises(SystemExit): - rv = handle_remove_group(options, session, ['tag', 'grp']) + handle_remove_group(options, session, ['tag', 'grp']) activate_session_mock.assert_called_with(session, options)