/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

  • Committer: teddy at recompile
  • Date: 2020-01-12 01:53:04 UTC
  • Revision ID: teddy@recompile.se-20200112015304-gqif9w4pbyix8w6b
mandos-ctl: Fix minor bug in tests

Fix two tests, the last assert of which would always erroneously
succeed.  (No change in non-test code needed.)

* mandos-ctl (Test_dbus_python_adapter_SystemBus): In the
  test_call_method_handles_exception() method, fix check for
  dbus.ConnectFailed exception.
  (Test_pydbus_adapter_SystemBus): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
import collections
79
79
import codecs
80
80
import unittest
81
 
import random
82
 
import shlex
83
81
 
84
82
import dbus
85
83
import dbus.service
95
93
    __metaclass__ = type
96
94
    str = unicode
97
95
 
98
 
# Add collections.abc.Callable if it does not exist
99
 
try:
100
 
    collections.abc.Callable
101
 
except AttributeError:
102
 
    class abc:
103
 
        Callable = collections.Callable
104
 
    collections.abc = abc
105
 
    del abc
106
 
 
107
 
# Add shlex.quote if it does not exist
108
 
try:
109
 
    shlex.quote
110
 
except AttributeError:
111
 
    shlex.quote = re.escape
112
 
 
113
96
# Show warnings by default
114
97
if not sys.warnoptions:
115
98
    import warnings
1052
1035
        if self.checker_initiator_tag is not None:
1053
1036
            GLib.source_remove(self.checker_initiator_tag)
1054
1037
        self.checker_initiator_tag = GLib.timeout_add(
1055
 
            random.randrange(int(self.interval.total_seconds() * 1000
1056
 
                                 + 1)),
 
1038
            int(self.interval.total_seconds() * 1000),
1057
1039
            self.start_checker)
1058
1040
        # Schedule a disable() when 'timeout' has passed
1059
1041
        if self.disable_initiator_tag is not None:
1134
1116
        if self.checker is None:
1135
1117
            # Escape attributes for the shell
1136
1118
            escaped_attrs = {
1137
 
                attr: shlex.quote(str(getattr(self, attr)))
 
1119
                attr: re.escape(str(getattr(self, attr)))
1138
1120
                for attr in self.runtime_expansions}
1139
1121
            try:
1140
1122
                command = self.checker_command % escaped_attrs
2764
2746
        if command == 'getattr':
2765
2747
            attrname = request[1]
2766
2748
            if isinstance(client_object.__getattribute__(attrname),
2767
 
                          collections.abc.Callable):
 
2749
                          collections.Callable):
2768
2750
                parent_pipe.send(('function', ))
2769
2751
            else:
2770
2752
                parent_pipe.send((