From 5296e4c1eec8d080ce844e4ac2e1918ceda28793 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Sep 05 2023 21:43:50 +0000 Subject: `fedpkg update`: add option `--severity` So far `--severity` was present only in a template and had to be uncommented in case of a security update. Now the update subcommand has this option with 'unspecified' as a default value. JIRA: RHELCMP-12518 Fixes: #526 Signed-off-by: Ondrej Nosek --- diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 1c70405..8bb6fff 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -57,7 +57,7 @@ bugs=%(bugs)s # Severity: low, medium, high, urgent # This is required for security updates. -# severity=unspecified +severity=%(severity)s display_name= @@ -261,6 +261,11 @@ class fedpkgClient(cliClient): dest='require_testcases', help='Disables the requirement that this update passes all test cases ' 'before reaching stable. Default is True.') + update_parser.add_argument( + '--severity', + choices=['unspecified', 'low', 'medium', 'high', 'urgent'], + default='unspecified', + help='Severity - required for security updates') group = update_parser.add_mutually_exclusive_group() group.add_argument( @@ -859,6 +864,7 @@ class fedpkgClient(cliClient): 'suggest': 'unspecified', 'require_bugs': str(self.args.require_bugs), 'require_testcases': str(self.args.require_testcases), + 'severity': self.args.severity, } if self.args.suggest_reboot: diff --git a/test/test_cli.py b/test/test_cli.py index e0a1918..aa1b350 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -179,7 +179,7 @@ class TestUpdate(CliTestCase): def assert_bodhi_update(self, cli, _load_cookies, send_request, csrf, update_type=None, request_type=None, notes=None, stable_karma=None, unstable_karma=None, - suggest=None): + suggest=None, severity=None): csrf.return_value = '123456' def run_command_side_effect(command, shell): @@ -214,7 +214,7 @@ class TestUpdate(CliTestCase): 'builds': ' {0} '.format(self.mock_nvr.return_value), 'close_bugs': True, 'request': 'testing', - 'severity': 'unspecified', + 'severity': severity or 'unspecified', 'suggest': 'unspecified', 'type': update_type, 'type_': update_type, @@ -302,6 +302,16 @@ class TestUpdate(CliTestCase): self.assert_bodhi_update(cli, update_type='enhancement', stable_karma='1', unstable_karma='-1') + def test_request_security_update_with_severity(self): + cli_cmd = [ + 'fedpkg', '--path', self.cloned_repo_path, 'update', + '--type', 'security', '--severity', 'medium' + ] + + cli = self.get_cli(cli_cmd) + self.assert_bodhi_update(cli, update_type='security', + severity='medium') + @patch('fedpkg.Commands.update', side_effect=OSError) def test_handle_any_errors_raised_when_execute_bodhi(self, update): cli_cmd = ['fedpkg', '--path', self.cloned_repo_path, 'update']