594
598
class Remove(Base):
595
def run(self, clients, bus, mandos):
596
for clientpath in clients.keys():
597
log.debug("D-Bus: %s:%s:%s.RemoveClient(%r)",
598
dbus_busname, server_dbus_path,
599
server_dbus_interface, clientpath)
600
mandos.RemoveClient(clientpath)
599
def run_on_one_client(self, client, properties):
600
log.debug("D-Bus: %s:%s:%s.RemoveClient(%r)",
601
dbus_busname, server_dbus_path,
602
server_dbus_interface,
603
str(client.__dbus_object_path__))
604
self.mandos.RemoveClient(client.__dbus_object_path__)
603
607
class Output(Base):
745
749
raise NotImplementedError()
748
class Enable(PropertySetter):
752
class Enable(Property):
749
753
propname = "Enabled"
750
754
value_to_set = dbus.Boolean(True)
753
class Disable(PropertySetter):
757
class Disable(Property):
754
758
propname = "Enabled"
755
759
value_to_set = dbus.Boolean(False)
758
class BumpTimeout(PropertySetter):
762
class BumpTimeout(Property):
759
763
propname = "LastCheckedOK"
760
764
value_to_set = ""
763
class StartChecker(PropertySetter):
764
propname = "CheckerRunning"
765
value_to_set = dbus.Boolean(True)
768
class StopChecker(PropertySetter):
769
propname = "CheckerRunning"
770
value_to_set = dbus.Boolean(False)
773
class ApproveByDefault(PropertySetter):
774
propname = "ApprovedByDefault"
775
value_to_set = dbus.Boolean(True)
778
class DenyByDefault(PropertySetter):
779
propname = "ApprovedByDefault"
780
value_to_set = dbus.Boolean(False)
783
class PropertySetterValue(PropertySetter):
784
"""Abstract class for PropertySetter recieving a value as
785
constructor argument instead of a class attribute."""
767
class StartChecker(Property):
768
propname = "CheckerRunning"
769
value_to_set = dbus.Boolean(True)
772
class StopChecker(Property):
773
propname = "CheckerRunning"
774
value_to_set = dbus.Boolean(False)
777
class ApproveByDefault(Property):
778
propname = "ApprovedByDefault"
779
value_to_set = dbus.Boolean(True)
782
class DenyByDefault(Property):
783
propname = "ApprovedByDefault"
784
value_to_set = dbus.Boolean(False)
787
class PropertyValue(Property):
788
"Abstract class for Property recieving a value as argument"
786
789
def __init__(self, value):
787
790
self.value_to_set = value
790
class SetChecker(PropertySetterValue):
793
class SetChecker(PropertyValue):
791
794
propname = "Checker"
794
class SetHost(PropertySetterValue):
797
class SetHost(PropertyValue):
795
798
propname = "Host"
798
class SetSecret(PropertySetterValue):
801
class SetSecret(PropertyValue):
799
802
propname = "Secret"
824
826
self._vts = int(round(value.total_seconds() * 1000))
827
class SetTimeout(PropertySetterValueMilliseconds):
829
class SetTimeout(MillisecondsPropertyValueArgument):
828
830
propname = "Timeout"
831
class SetExtendedTimeout(PropertySetterValueMilliseconds):
833
class SetExtendedTimeout(MillisecondsPropertyValueArgument):
832
834
propname = "ExtendedTimeout"
835
class SetInterval(PropertySetterValueMilliseconds):
837
class SetInterval(MillisecondsPropertyValueArgument):
836
838
propname = "Interval"
839
class SetApprovalDelay(PropertySetterValueMilliseconds):
841
class SetApprovalDelay(MillisecondsPropertyValueArgument):
840
842
propname = "ApprovalDelay"
843
class SetApprovalDuration(PropertySetterValueMilliseconds):
845
class SetApprovalDuration(MillisecondsPropertyValueArgument):
844
846
propname = "ApprovalDuration"
1725
1727
self.command().run(clients, self.bus)
1728
class TestEnableCmd(TestPropertySetterCmd):
1730
class TestEnableCmd(TestPropertyCmd):
1729
1731
command = command.Enable
1730
1732
propname = "Enabled"
1731
1733
values_to_set = [dbus.Boolean(True)]
1734
class TestDisableCmd(TestPropertySetterCmd):
1736
class TestDisableCmd(TestPropertyCmd):
1735
1737
command = command.Disable
1736
1738
propname = "Enabled"
1737
1739
values_to_set = [dbus.Boolean(False)]
1740
class TestBumpTimeoutCmd(TestPropertySetterCmd):
1742
class TestBumpTimeoutCmd(TestPropertyCmd):
1741
1743
command = command.BumpTimeout
1742
1744
propname = "LastCheckedOK"
1743
1745
values_to_set = [""]
1746
class TestStartCheckerCmd(TestPropertySetterCmd):
1748
class TestStartCheckerCmd(TestPropertyCmd):
1747
1749
command = command.StartChecker
1748
1750
propname = "CheckerRunning"
1749
1751
values_to_set = [dbus.Boolean(True)]
1752
class TestStopCheckerCmd(TestPropertySetterCmd):
1754
class TestStopCheckerCmd(TestPropertyCmd):
1753
1755
command = command.StopChecker
1754
1756
propname = "CheckerRunning"
1755
1757
values_to_set = [dbus.Boolean(False)]
1758
class TestApproveByDefaultCmd(TestPropertySetterCmd):
1760
class TestApproveByDefaultCmd(TestPropertyCmd):
1759
1761
command = command.ApproveByDefault
1760
1762
propname = "ApprovedByDefault"
1761
1763
values_to_set = [dbus.Boolean(True)]
1764
class TestDenyByDefaultCmd(TestPropertySetterCmd):
1766
class TestDenyByDefaultCmd(TestPropertyCmd):
1765
1767
command = command.DenyByDefault
1766
1768
propname = "ApprovedByDefault"
1767
1769
values_to_set = [dbus.Boolean(False)]
1770
class TestPropertySetterValueCmd(TestPropertySetterCmd):
1771
"""Abstract class for tests of PropertySetterValueCmd classes"""
1772
class TestPropertyValueCmd(TestPropertyCmd):
1773
"""Abstract class for tests of PropertyValueCmd classes"""
1773
1775
def runTest(self):
1774
if type(self) is TestPropertySetterValueCmd:
1776
if type(self) is TestPropertyValueCmd:
1776
return super(TestPropertySetterValueCmd, self).runTest()
1778
return super(TestPropertyValueCmd, self).runTest()
1778
1780
def run_command(self, value, clients):
1779
1781
self.command(value).run(clients, self.bus)
1782
class TestSetCheckerCmd(TestPropertySetterValueCmd):
1784
class TestSetCheckerCmd(TestPropertyValueCmd):
1783
1785
command = command.SetChecker
1784
1786
propname = "Checker"
1785
1787
values_to_set = ["", ":", "fping -q -- %s"]
1788
class TestSetHostCmd(TestPropertySetterValueCmd):
1790
class TestSetHostCmd(TestPropertyValueCmd):
1789
1791
command = command.SetHost
1790
1792
propname = "Host"
1791
1793
values_to_set = ["192.0.2.3", "client.example.org"]
1794
class TestSetSecretCmd(TestPropertySetterValueCmd):
1796
class TestSetSecretCmd(TestPropertyValueCmd):
1795
1797
command = command.SetSecret
1796
1798
propname = "Secret"
1797
1799
values_to_set = [io.BytesIO(b""),