예제 #1
0
 def test_tcp_filter_tcp_packet_wrong_src_right_dst(self):
     rule = port_filter.PortRule(protocol='TCP', src_port=0, dst_port=0)
     packet = FakePacket(protocol=socket.IPPROTO_TCP,
                         src_port=1,
                         dst_port=1)
     self.assertFalse(rule.filter_condition(packet))
예제 #2
0
 def test_tcp_filter_tcp_packet_matching_src_and_dst(self):
     rule = port_filter.PortRule(protocol='TCP', src_port=0, dst_port=0)
     packet = FakePacket(protocol=socket.IPPROTO_TCP,
                         src_port=0,
                         dst_port=0)
     self.assertTrue(rule.filter_condition(packet))
예제 #3
0
 def test_udp_filter_udp_packet_wrong_dst_port(self):
     rule = port_filter.PortRule(protocol='UDP', dst_port=0)
     packet = FakePacket(protocol=socket.IPPROTO_UDP, dst_port=1)
     self.assertFalse(rule.filter_condition(packet))
예제 #4
0
 def test_udp_filter_with_tcp_packet(self):
     rule = port_filter.PortRule(protocol='UDP', src_port=0)
     packet = FakePacket(protocol=socket.IPPROTO_TCP)
     self.assertFalse(rule.filter_condition(packet))
예제 #5
0
 def test_udp_filter_with_udp_matching_src_port(self):
     rule = port_filter.PortRule(protocol='UDP', src_port=0)
     packet = FakePacket(protocol=socket.IPPROTO_UDP, src_port=0)
     self.assertTrue(rule.filter_condition(packet))