/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-09 00:46:46 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190309004646-rplp42103zkabetc
mandos-ctl: Disallow --remove combined with any action except --deny

* mandos-ctl (check_option_syntax): Disallow --remove combined with
                                    any action except --deny.
  (Test_check_option_syntax.test_remove_can_only_be_combined_with_action_deny):
  New.

Show diffs side-by-side

added added

removed removed

Lines of Context:
695
695
        parser.error("--all requires an action.")
696
696
    if options.is_enabled and len(options.client) > 1:
697
697
        parser.error("--is-enabled requires exactly one client")
 
698
    if options.remove:
 
699
        options.remove = False
 
700
        if has_actions(options) and not options.deny:
 
701
            parser.error("--remove can only be combined with --deny")
 
702
        options.remove = True
698
703
 
699
704
 
700
705
def main():
1491
1496
        with self.assertParseError():
1492
1497
            self.check_option_syntax(options)
1493
1498
 
 
1499
    def test_remove_can_only_be_combined_with_action_deny(self):
 
1500
        for action, value in self.actions.items():
 
1501
            if action in {"remove", "deny"}:
 
1502
                continue
 
1503
            options = self.parser.parse_args()
 
1504
            setattr(options, action, value)
 
1505
            options.all = True
 
1506
            options.remove = True
 
1507
            with self.assertParseError():
 
1508
                self.check_option_syntax(options)
 
1509
 
1494
1510
 
1495
1511
 
1496
1512
def should_only_run_tests():