/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-03-30 17:02:33 UTC
  • Revision ID: teddy@recompile.se-20190330170233-nxu3cgb98q2g3o5j
Fix typo in intro(8mandos).

* intro.xml (INTRODUCTION): Add missing period at end of last sentence
                            of penultimate paragraph.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2070
2070
    def runTest(self):
2071
2071
        if not hasattr(self, "command"):
2072
2072
            return              # Abstract TestCase class
2073
 
 
2074
 
        if hasattr(self, "values_to_set"):
2075
 
            cmd_args = [(value,) for value in self.values_to_set]
2076
 
            values_to_get = getattr(self, "values_to_get",
2077
 
                                    self.values_to_set)
2078
 
        else:
2079
 
            cmd_args = [() for x in range(len(self.values_to_get))]
2080
 
            values_to_get = self.values_to_get
2081
 
        for value_to_get, cmd_arg in zip(values_to_get, cmd_args):
2082
 
            for clientpath in self.bus.clients:
2083
 
                self.bus.clients[clientpath][self.propname] = (
2084
 
                    Unique())
2085
 
            self.command(*cmd_arg).run(self.bus.clients, self.bus)
2086
 
            for clientpath in self.bus.clients:
2087
 
                value = (self.bus.clients[clientpath]
2088
 
                         [self.propname])
 
2073
        values_to_get = getattr(self, "values_to_get",
 
2074
                                self.values_to_set)
 
2075
        for value_to_set, value_to_get in zip(self.values_to_set,
 
2076
                                              values_to_get):
 
2077
            for clientpath in self.bus.clients:
 
2078
                self.bus.clients[clientpath][self.propname] = Unique()
 
2079
            self.run_command(value_to_set, self.bus.clients)
 
2080
            for clientpath in self.bus.clients:
 
2081
                value = self.bus.clients[clientpath][self.propname]
2089
2082
                self.assertNotIsInstance(value, Unique)
2090
2083
                self.assertEqual(value_to_get, value)
2091
2084
 
 
2085
    def run_command(self, value, clients):
 
2086
        self.command().run(clients, self.bus)
 
2087
 
2092
2088
 
2093
2089
class TestEnableCmd(TestPropertySetterCmd):
2094
2090
    command = command.Enable
2095
2091
    propname = "Enabled"
2096
 
    values_to_get = [True]
 
2092
    values_to_set = [True]
2097
2093
 
2098
2094
 
2099
2095
class TestDisableCmd(TestPropertySetterCmd):
2100
2096
    command = command.Disable
2101
2097
    propname = "Enabled"
2102
 
    values_to_get = [False]
 
2098
    values_to_set = [False]
2103
2099
 
2104
2100
 
2105
2101
class TestBumpTimeoutCmd(TestPropertySetterCmd):
2106
2102
    command = command.BumpTimeout
2107
2103
    propname = "LastCheckedOK"
2108
 
    values_to_get = [""]
 
2104
    values_to_set = [""]
2109
2105
 
2110
2106
 
2111
2107
class TestStartCheckerCmd(TestPropertySetterCmd):
2112
2108
    command = command.StartChecker
2113
2109
    propname = "CheckerRunning"
2114
 
    values_to_get = [True]
 
2110
    values_to_set = [True]
2115
2111
 
2116
2112
 
2117
2113
class TestStopCheckerCmd(TestPropertySetterCmd):
2118
2114
    command = command.StopChecker
2119
2115
    propname = "CheckerRunning"
2120
 
    values_to_get = [False]
 
2116
    values_to_set = [False]
2121
2117
 
2122
2118
 
2123
2119
class TestApproveByDefaultCmd(TestPropertySetterCmd):
2124
2120
    command = command.ApproveByDefault
2125
2121
    propname = "ApprovedByDefault"
2126
 
    values_to_get = [True]
 
2122
    values_to_set = [True]
2127
2123
 
2128
2124
 
2129
2125
class TestDenyByDefaultCmd(TestPropertySetterCmd):
2130
2126
    command = command.DenyByDefault
2131
2127
    propname = "ApprovedByDefault"
2132
 
    values_to_get = [False]
2133
 
 
2134
 
 
2135
 
class TestSetCheckerCmd(TestPropertySetterCmd):
 
2128
    values_to_set = [False]
 
2129
 
 
2130
 
 
2131
class TestPropertySetterValueCmd(TestPropertySetterCmd):
 
2132
    """Abstract class for tests of PropertySetterValueCmd classes"""
 
2133
 
 
2134
    def run_command(self, value, clients):
 
2135
        self.command(value).run(clients, self.bus)
 
2136
 
 
2137
 
 
2138
class TestSetCheckerCmd(TestPropertySetterValueCmd):
2136
2139
    command = command.SetChecker
2137
2140
    propname = "Checker"
2138
2141
    values_to_set = ["", ":", "fping -q -- %s"]
2139
2142
 
2140
2143
 
2141
 
class TestSetHostCmd(TestPropertySetterCmd):
 
2144
class TestSetHostCmd(TestPropertySetterValueCmd):
2142
2145
    command = command.SetHost
2143
2146
    propname = "Host"
2144
2147
    values_to_set = ["192.0.2.3", "client.example.org"]
2145
2148
 
2146
2149
 
2147
 
class TestSetSecretCmd(TestPropertySetterCmd):
 
2150
class TestSetSecretCmd(TestPropertySetterValueCmd):
2148
2151
    command = command.SetSecret
2149
2152
    propname = "Secret"
2150
2153
    values_to_set = [io.BytesIO(b""),
2152
2155
    values_to_get = [f.getvalue() for f in values_to_set]
2153
2156
 
2154
2157
 
2155
 
class TestSetTimeoutCmd(TestPropertySetterCmd):
 
2158
class TestSetTimeoutCmd(TestPropertySetterValueCmd):
2156
2159
    command = command.SetTimeout
2157
2160
    propname = "Timeout"
2158
2161
    values_to_set = [datetime.timedelta(),
2163
2166
    values_to_get = [dt.total_seconds()*1000 for dt in values_to_set]
2164
2167
 
2165
2168
 
2166
 
class TestSetExtendedTimeoutCmd(TestPropertySetterCmd):
 
2169
class TestSetExtendedTimeoutCmd(TestPropertySetterValueCmd):
2167
2170
    command = command.SetExtendedTimeout
2168
2171
    propname = "ExtendedTimeout"
2169
2172
    values_to_set = [datetime.timedelta(),
2174
2177
    values_to_get = [dt.total_seconds()*1000 for dt in values_to_set]
2175
2178
 
2176
2179
 
2177
 
class TestSetIntervalCmd(TestPropertySetterCmd):
 
2180
class TestSetIntervalCmd(TestPropertySetterValueCmd):
2178
2181
    command = command.SetInterval
2179
2182
    propname = "Interval"
2180
2183
    values_to_set = [datetime.timedelta(),
2185
2188
    values_to_get = [dt.total_seconds()*1000 for dt in values_to_set]
2186
2189
 
2187
2190
 
2188
 
class TestSetApprovalDelayCmd(TestPropertySetterCmd):
 
2191
class TestSetApprovalDelayCmd(TestPropertySetterValueCmd):
2189
2192
    command = command.SetApprovalDelay
2190
2193
    propname = "ApprovalDelay"
2191
2194
    values_to_set = [datetime.timedelta(),
2196
2199
    values_to_get = [dt.total_seconds()*1000 for dt in values_to_set]
2197
2200
 
2198
2201
 
2199
 
class TestSetApprovalDurationCmd(TestPropertySetterCmd):
 
2202
class TestSetApprovalDurationCmd(TestPropertySetterValueCmd):
2200
2203
    command = command.SetApprovalDuration
2201
2204
    propname = "ApprovalDuration"
2202
2205
    values_to_set = [datetime.timedelta(),