/mandos/trunk

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-04-10 20:33:13 UTC
  • Revision ID: teddy@recompile.se-20190410203313-d3ufer20hfws7i3h
Improve language in intro(8mandos) manual page

* intro.xml (INTRODUCTION): Replace "it" with "the data" to fix bad
                            reference, and clarify that it is the
                            client which continues booting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
 
# -*- after-save-hook: (lambda () (let ((command (if (fboundp 'file-local-name) (file-local-name (buffer-file-name)) (or (file-remote-p (buffer-file-name) 'localname) (buffer-file-name))))) (if (= (progn (if (get-buffer "*Test*") (kill-buffer "*Test*")) (process-file-shell-command (format "%s --test" (shell-quote-argument command)) nil "*Test*")) 0) (let ((w (get-buffer-window "*Test*"))) (if w (delete-window w))) (progn (with-current-buffer "*Test*" (compilation-mode)) (display-buffer "*Test*" '(display-buffer-in-side-window)))))); coding: utf-8 -*-
 
2
# -*- mode: python; coding: utf-8; after-save-hook: (lambda () (let ((command (if (and (boundp 'tramp-file-name-structure) (string-match (car tramp-file-name-structure) (buffer-file-name))) (tramp-file-name-localname (tramp-dissect-file-name (buffer-file-name))) (buffer-file-name)))) (if (= (shell-command (format "%s --check" (shell-quote-argument command)) "*Test*") 0) (let ((w (get-buffer-window "*Test*"))) (if w (delete-window w)) (kill-buffer "*Test*")) (display-buffer "*Test*")))); -*-
3
3
#
4
4
# Mandos Monitor - Control and monitor the Mandos server
5
5
#
1780
1780
        self.assert_command_from_args(["--is-enabled", "client"],
1781
1781
                                      command.IsEnabled)
1782
1782
 
1783
 
    def assert_command_from_args(self, args, command_cls, length=1,
1784
 
                                 clients=None, **cmd_attrs):
 
1783
    def assert_command_from_args(self, args, command_cls,
 
1784
                                 **cmd_attrs):
1785
1785
        """Assert that parsing ARGS should result in an instance of
1786
1786
COMMAND_CLS with (optionally) all supplied attributes (CMD_ATTRS)."""
1787
1787
        options = self.parser.parse_args(args)
1788
1788
        check_option_syntax(self.parser, options)
1789
1789
        commands = commands_from_options(options)
1790
 
        self.assertEqual(length, len(commands))
1791
 
        for command in commands:
1792
 
            if isinstance(command, command_cls):
1793
 
                break
1794
 
        else:
1795
 
            self.assertIsInstance(command, command_cls)
1796
 
        if clients is not None:
1797
 
            self.assertEqual(clients, options.client)
 
1790
        self.assertEqual(1, len(commands))
 
1791
        command = commands[0]
 
1792
        self.assertIsInstance(command, command_cls)
1798
1793
        for key, value in cmd_attrs.items():
1799
1794
            self.assertEqual(value, getattr(command, key))
1800
1795
 
1801
 
    def assert_commands_from_args(self, args, commands, clients=None):
1802
 
        for cmd in commands:
1803
 
            self.assert_command_from_args(args, cmd,
1804
 
                                          length=len(commands),
1805
 
                                          clients=clients)
1806
 
 
1807
1796
    def test_is_enabled_short(self):
1808
1797
        self.assert_command_from_args(["-V", "client"],
1809
1798
                                      command.IsEnabled)
2000
1989
                                      verbose=True)
2001
1990
 
2002
1991
 
2003
 
    def test_manual_page_example_1(self):
2004
 
        self.assert_command_from_args("--verbose".split(),
2005
 
                                      command.PrintTable,
2006
 
                                      clients=[],
2007
 
                                      verbose=True)
2008
 
 
2009
 
    def test_manual_page_example_2(self):
2010
 
        self.assert_command_from_args(
2011
 
            "--verbose foo1.example.org foo2.example.org".split(),
2012
 
            command.PrintTable, clients=["foo1.example.org",
2013
 
                                         "foo2.example.org"],
2014
 
            verbose=True)
2015
 
 
2016
 
    def test_manual_page_example_3(self):
2017
 
        self.assert_command_from_args("--enable --all".split(),
2018
 
                                      command.Enable,
2019
 
                                      clients=[])
2020
 
 
2021
 
    def test_manual_page_example_4(self):
2022
 
        self.assert_commands_from_args(
2023
 
            ("--timeout=PT5M --interval=PT1M foo1.example.org"
2024
 
             " foo2.example.org").split(),
2025
 
            [command.SetTimeout, command.SetInterval],
2026
 
            clients=["foo1.example.org", "foo2.example.org"])
2027
 
 
2028
 
    def test_manual_page_example_5(self):
2029
 
        self.assert_command_from_args("--approve --all".split(),
2030
 
                                      command.Approve,
2031
 
                                      clients=[])
2032
 
 
2033
 
 
2034
1992
class TestCommand(unittest.TestCase):
2035
1993
    """Abstract class for tests of command classes"""
2036
1994