=== modified file 'mandos-ctl' --- mandos-ctl 2019-03-08 23:55:34 +0000 +++ mandos-ctl 2019-03-09 00:35:00 +0000 @@ -611,9 +611,6 @@ if options.is_enabled: commands.append(IsEnabledCmd()) - if options.remove: - commands.append(RemoveCmd()) - if options.checker is not None: commands.append(SetCheckerCmd(options.checker)) @@ -652,6 +649,9 @@ if options.deny: commands.append(DenyCmd()) + if options.remove: + commands.append(RemoveCmd()) + # If no command option has been given, show table of clients, # optionally verbosely if not commands: @@ -1355,6 +1355,22 @@ def test_is_enabled_short(self): self.assert_command_from_args(["-V", "foo"], IsEnabledCmd) + def test_deny_before_remove(self): + options = self.parser.parse_args(["--deny", "--remove", "foo"]) + check_option_syntax(self.parser, options) + commands = commands_from_options(options) + self.assertEqual(len(commands), 2) + self.assertIsInstance(commands[0], DenyCmd) + self.assertIsInstance(commands[1], RemoveCmd) + + def test_deny_before_remove_reversed(self): + options = self.parser.parse_args(["--remove", "--deny", "--all"]) + check_option_syntax(self.parser, options) + commands = commands_from_options(options) + self.assertEqual(len(commands), 2) + self.assertIsInstance(commands[0], DenyCmd) + self.assertIsInstance(commands[1], RemoveCmd) + class Test_check_option_syntax(unittest.TestCase): # This mostly corresponds to the definition from has_actions() in