102
102
clientnames = options.client
104
104
if options.debug:
105
logging.getLogger("").setLevel(logging.DEBUG)
105
log.setLevel(logging.DEBUG)
107
107
if dbussy is not None and ravel is not None:
108
108
bus = dbussy_adapter.CachingBus(dbussy, ravel)
395
395
"""Parse an interval string as documented by Mandos before 1.6.1,
396
396
and return a datetime.timedelta
398
>>> parse_pre_1_6_1_interval("7d") == datetime.timedelta(days=7)
400
>>> parse_pre_1_6_1_interval("60s") == datetime.timedelta(0, 60)
402
>>> parse_pre_1_6_1_interval("60m") == datetime.timedelta(hours=1)
404
>>> parse_pre_1_6_1_interval("24h") == datetime.timedelta(days=1)
406
>>> parse_pre_1_6_1_interval("1w") == datetime.timedelta(days=7)
408
>>> parse_pre_1_6_1_interval("5m 30s") == datetime.timedelta(0, 330)
410
>>> parse_pre_1_6_1_interval("") == datetime.timedelta(0)
398
>>> parse_pre_1_6_1_interval('7d') == datetime.timedelta(days=7)
400
>>> parse_pre_1_6_1_interval('60s') == datetime.timedelta(0, 60)
402
>>> parse_pre_1_6_1_interval('60m') == datetime.timedelta(hours=1)
404
>>> parse_pre_1_6_1_interval('24h') == datetime.timedelta(days=1)
406
>>> parse_pre_1_6_1_interval('1w') == datetime.timedelta(days=7)
408
>>> parse_pre_1_6_1_interval('5m 30s') == datetime.timedelta(0, 330)
410
>>> parse_pre_1_6_1_interval('') == datetime.timedelta(0)
412
412
>>> # Ignore unknown characters, allow any order and repetitions
413
>>> parse_pre_1_6_1_interval("2dxy7zz11y3m5m") == datetime.timedelta(2, 480, 18000)
413
>>> parse_pre_1_6_1_interval('2dxy7zz11y3m5m') == datetime.timedelta(2, 480, 18000)
876
876
{key: properties[key]
877
877
for key in self.all_keywords}
878
878
for properties in clients.values()}
879
print(json.dumps(data, indent=4, separators=(",", ": ")))
879
print(json.dumps(data, indent=4, separators=(',', ': ')))
882
882
class PrintTable(Output):
2439
2439
busname = "se.recompile.Mandos"
2440
2440
client_interface = "se.recompile.Mandos.Client"
2441
2441
command.Approve().run(self.bus.clients, self.bus)
2442
self.assertTrue(self.bus.clients)
2443
2442
for clientpath in self.bus.clients:
2444
2443
self.assertIn(("Approve", busname, clientpath,
2445
2444
client_interface, (True,)), self.bus.calls)
2448
2447
busname = "se.recompile.Mandos"
2449
2448
client_interface = "se.recompile.Mandos.Client"
2450
2449
command.Deny().run(self.bus.clients, self.bus)
2451
self.assertTrue(self.bus.clients)
2452
2450
for clientpath in self.bus.clients:
2453
2451
self.assertIn(("Approve", busname, clientpath,
2454
2452
client_interface, (False,)),
2455
2453
self.bus.calls)
2457
2455
def test_Remove(self):
2458
busname = "se.recompile.Mandos"
2460
server_interface = "se.recompile.Mandos"
2461
orig_clients = self.bus.clients.copy()
2462
2456
command.Remove().run(self.bus.clients, self.bus)
2463
self.assertFalse(self.bus.clients)
2464
for clientpath in orig_clients:
2465
self.assertIn(("RemoveClient", busname,
2466
server_path, server_interface,
2457
for clientpath in self.bus.clients:
2458
self.assertIn(("RemoveClient", dbus_busname,
2459
dbus_server_path, dbus_server_interface,
2467
2460
(clientpath,)), self.bus.calls)
2469
2462
expected_json = {
2672
2665
cmd_args = [() for x in range(len(self.values_to_get))]
2673
2666
values_to_get = self.values_to_get
2674
self.assertTrue(values_to_get)
2675
2667
for value_to_get, cmd_arg in zip(values_to_get, cmd_args):
2676
2668
for clientpath in self.bus.clients:
2677
2669
self.bus.clients[clientpath][self.propname] = (
2679
2671
self.command(*cmd_arg).run(self.bus.clients, self.bus)
2680
self.assertTrue(self.bus.clients)
2681
2672
for clientpath in self.bus.clients:
2682
2673
value = (self.bus.clients[clientpath]
2683
2674
[self.propname])