def test_from_string(self): layer = TransportLayerBuilder.build('tcp 1 2 3 4') assert_in(TcpAddress.from_string('1 2'), layer.source) assert_in(TcpAddress.from_string('3 4'), layer.destination) layer = TransportLayerBuilder.build('udp 1-2 3-4') assert_in(UdpAddress.from_string('1 2'), layer.source) assert_in(UdpAddress.from_string('3 4'), layer.destination) layer = TransportLayerBuilder.build('tcp 1-2 3 4') assert_in(TcpAddress.from_string('1 2'), layer.source) layer = TransportLayerBuilder.build('tcp 1 2') assert_in(TcpAddress.from_string('1'), layer.source) assert_in(TcpAddress.from_string('2'), layer.destination)
def test_ineqaulity(self): ace = Ace() ace.network = NetworkLayer.from_string('1.2.3.0/24 2.3.4.0/24') ace.transport = TransportLayerBuilder.build('tcp 1024 65535 22 22') ace.logging = LoggingFacility.from_string('warning') assert_not_equals(Ace(), ace) assert_not_equals(Ace(permit=False), Ace()) assert_not_equals(Ace(logging=1), Ace()) ace = Ace() ace.network = NetworkLayer.from_string('1.2.3.0/24 2.3.4.0/24') assert_not_equals(ace, Ace()) ace = Ace() ace.transport = TransportLayerBuilder.build('tcp 1024 65535 22 22') assert_not_equals(ace, Ace())
def test_not_contains(self): ace = Ace(network=NetworkLayer.from_string('1.2.3.0/24 2.3.4.0/24')) assert_not_in(Ace(), ace) ace = Ace(transport=TransportLayerBuilder.build('tcp 1024 65535 22 22')) assert_not_in(Ace(), ace) ace = Ace(logging='warning') assert_not_in(Ace(), ace)
def test_not_contains(self): ace = Ace(network=NetworkLayer.from_string('1.2.3.0/24 2.3.4.0/24')) assert_not_in(Ace(), ace) ace = Ace( transport=TransportLayerBuilder.build('tcp 1024 65535 22 22')) assert_not_in(Ace(), ace) ace = Ace(logging='warning') assert_not_in(Ace(), ace)
def test_eqaulity(self): aces = list() for index in range(2): ace = Ace() ace.network = NetworkLayer.from_string('1.2.3.0/24 2.3.4.0/24') ace.transport = TransportLayerBuilder.build('tcp 1024 65535 22 22') ace.logging = LoggingFacility.from_string('warning') aces.append(ace) assert_equals(aces[0], aces[1])
def transport(self, value): if value is not None: value = TransportLayerBuilder.build(value) self._transport = value
def test_transport_setter(self): self.ace.transport = None assert_equals(self.ace.transport, None) nl = TransportLayerBuilder.build('tcp 1 2 3 4') self.ace.transport = TransportLayerBuilder.build('tcp 1 2 3 4') assert_in(nl, self.ace.transport)