Esempio n. 1
0
    def test_058_single_proper_superset_edge3(self):
        """Portcon query with single port proper superset, high equal edge case"""
        q = PortconQuery(
            self.p, ports=(50800, 50801), ports_superset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50801, 50801)], ports)
Esempio n. 2
0
    def test_055_range_proper_subset_edge3(self):
        """Portcon query with range proper subset, high equal edge case"""
        q = PortconQuery(
            self.p, ports=(50501, 50510), ports_subset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50500, 50510)], ports)
Esempio n. 3
0
    def test_054_single_proper_subset(self):
        """Portcon query with single port proper subset"""
        q = PortconQuery(
            self.p, ports=(50400, 50400), ports_subset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([], ports)
Esempio n. 4
0
    def test_059_range_proper_superset_edge3(self):
        """Portcon query with range proper superset, equal low port edge case"""
        q = PortconQuery(
            self.p, ports=(50901, 50911), ports_superset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50901, 50910)], ports)
Esempio n. 5
0
    def test_055_range_proper_subset_edge3(self):
        """Portcon query with range proper subset, high equal edge case"""
        q = PortconQuery(
            self.p, ports=(50501, 50510), ports_subset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50500, 50510)], ports)
Esempio n. 6
0
    def test_058_single_proper_superset_edge3(self):
        """Portcon query with single port proper superset, high equal edge case"""
        q = PortconQuery(
            self.p, ports=(50800, 50801), ports_superset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50801, 50801)], ports)
Esempio n. 7
0
    def test_054_single_proper_subset(self):
        """Portcon query with single port proper subset"""
        q = PortconQuery(
            self.p, ports=(50400, 50400), ports_subset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([], ports)
Esempio n. 8
0
    def test_059_range_proper_superset_edge3(self):
        """Portcon query with range proper superset, equal low port edge case"""
        q = PortconQuery(
            self.p, ports=(50901, 50911), ports_superset=True, ports_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50901, 50910)], ports)
Esempio n. 9
0
    def test_043_range_superset2(self):
        """Portcon query with context range superset match (equal)"""
        q = PortconQuery(self.p,
                         range_="s3:c1 - s3:c1.c3",
                         range_superset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(43, 43)], ports)
Esempio n. 10
0
    def test_041_range_overlap5(self):
        """Portcon query with context range overlap match (overlap high level)"""
        q = PortconQuery(self.p,
                         range_="s1:c1,c2 - s1:c0.c4",
                         range_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(41, 41)], ports)
Esempio n. 11
0
    def test_042_range_subset1(self):
        """Portcon query with context range subset match"""
        q = PortconQuery(self.p,
                         range_="s2:c1,c2 - s2:c0.c3",
                         range_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(42, 42)], ports)
Esempio n. 12
0
    def test_045_range_proper_superset4(self):
        """Portcon query with context range proper superset match (equal high)"""
        q = PortconQuery(self.p,
                         range_="s5 - s5:c1.c3",
                         range_superset=True,
                         range_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(45, 45)], ports)
Esempio n. 13
0
    def test_000_unset(self):
        """Portcon query with no criteria"""
        # query with no parameters gets all ports.
        rules = sorted(self.p.portcons())

        q = PortconQuery(self.p)
        q_rules = sorted(q.results())

        self.assertListEqual(rules, q_rules)
Esempio n. 14
0
    def test_000_unset(self):
        """Portcon query with no criteria"""
        # query with no parameters gets all ports.
        rules = sorted(self.p.portcons())

        q = PortconQuery(self.p)
        q_rules = sorted(q.results())

        self.assertListEqual(rules, q_rules)
Esempio n. 15
0
    def test_044_range_proper_subset4(self):
        """Portcon query with context range proper subset match (equal high only)"""
        q = PortconQuery(self.p,
                         range_="s4:c1,c2 - s4:c1.c3",
                         range_subset=True,
                         range_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(44, 44)], ports)
Esempio n. 16
0
    def test_052_single_subset(self):
        """Portcon query with single port subset"""
        q = PortconQuery(self.p, ports=(50200, 50200), ports_subset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50200, 50200)], ports)
Esempio n. 17
0
    def test_041_range_overlap1(self):
        """Portcon query with context range overlap match (equal)"""
        q = PortconQuery(self.p, range_="s1:c1 - s1:c0.c4", range_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(41, 41)], ports)
Esempio n. 18
0
    def test_031_type_regex(self):
        """Portcon query with context type regex match"""
        q = PortconQuery(self.p, type_="type31(b|c)", type_regex=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(31000, 31000), (31001, 31001)], ports)
Esempio n. 19
0
    def test_053_range_subset(self):
        """Portcon query with range subset"""
        q = PortconQuery(self.p, ports=(50301, 50309), ports_subset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50300, 50310)], ports)
Esempio n. 20
0
    def test_044_range_proper_subset4(self):
        """Portcon query with context range proper subset match (equal high only)"""
        q = PortconQuery(self.p, range_="s4:c1,c2 - s4:c1.c3", range_subset=True, range_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(44, 44)], ports)
Esempio n. 21
0
    def test_045_range_proper_superset4(self):
        """Portcon query with context range proper superset match (equal high)"""
        q = PortconQuery(self.p, range_="s5 - s5:c1.c3", range_superset=True, range_proper=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(45, 45)], ports)
Esempio n. 22
0
    def test_057_range_superset_edge1(self):
        """Portcon query with range superset, equal edge case"""
        q = PortconQuery(self.p, ports=(50700, 50710), ports_superset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50700, 50710)], ports)
Esempio n. 23
0
    def test_056_single_superset_edge1(self):
        """Portcon query with single port superset, equal edge case"""
        q = PortconQuery(self.p, ports=(50601, 50601), ports_superset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50601, 50601)], ports)
Esempio n. 24
0
    def test_050_single_equal(self):
        """Portcon query with single port exact match"""
        q = PortconQuery(self.p, ports=(50, 50))

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50, 50)], ports)
Esempio n. 25
0
    def test_051_range_equal(self):
        """Portcon query with port range exact match"""
        q = PortconQuery(self.p, ports=(50100, 50110))

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50100, 50110)], ports)
Esempio n. 26
0
    def test_057_range_superset_edge1(self):
        """Portcon query with range superset, equal edge case"""
        q = PortconQuery(self.p, ports=(50700, 50710), ports_superset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50700, 50710)], ports)
Esempio n. 27
0
    def test_060_single_overlap(self):
        """Portcon query with single overlap"""
        q = PortconQuery(self.p, ports=(60001, 60001), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60001, 60001)], ports)
Esempio n. 28
0
    def test_001_protocol(self):
        """Portcon query with protocol match"""
        q = PortconQuery(self.p, protocol=IPPROTO_UDP)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(1, 1)], ports)
Esempio n. 29
0
    def test_031_type_regex(self):
        """Portcon query with context type regex match"""
        q = PortconQuery(self.p, type_="type31(b|c)", type_regex=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(31000, 31000), (31001, 31001)], ports)
Esempio n. 30
0
    def test_060_single_overlap_edge3(self):
        """Portcon query with single overlap, range match proper superset"""
        q = PortconQuery(self.p, ports=(60000, 60002), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60001, 60001)], ports)
Esempio n. 31
0
    def test_030_type_exact(self):
        """Portcon query with context type exact match"""
        q = PortconQuery(self.p, type_="type30", type_regex=False)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(30, 30)], ports)
Esempio n. 32
0
    def test_061_range_overlap_low_half(self):
        """Portcon query with range overlap, low half match"""
        q = PortconQuery(self.p, ports=(60100, 60105), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60101, 60110)], ports)
Esempio n. 33
0
    def test_040_range_exact(self):
        """Portcon query with context range exact match"""
        q = PortconQuery(self.p, range_="s0:c1 - s0:c0.c4")

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(40, 40)], ports)
Esempio n. 34
0
    def test_060_single_overlap(self):
        """Portcon query with single overlap"""
        q = PortconQuery(self.p, ports=(60001, 60001), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60001, 60001)], ports)
Esempio n. 35
0
    def test_051_range_equal(self):
        """Portcon query with port range exact match"""
        q = PortconQuery(self.p, ports=(50100, 50110))

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50100, 50110)], ports)
Esempio n. 36
0
    def test_010_user_exact(self):
        """Portcon query with context user exact match"""
        q = PortconQuery(self.p, user="******", user_regex=False)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(10, 10)], ports)
Esempio n. 37
0
    def test_053_range_subset(self):
        """Portcon query with range subset"""
        q = PortconQuery(self.p, ports=(50301, 50309), ports_subset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50300, 50310)], ports)
Esempio n. 38
0
    def test_062_range_overlap_high_half(self):
        """Portcon query with range overlap, high half match"""
        q = PortconQuery(self.p, ports=(60205, 60211), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60200, 60210)], ports)
Esempio n. 39
0
    def test_043_range_superset2(self):
        """Portcon query with context range superset match (equal)"""
        q = PortconQuery(self.p, range_="s3:c1 - s3:c1.c3", range_superset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(43, 43)], ports)
Esempio n. 40
0
    def test_064_range_overlap_equal(self):
        """Portcon query with range overlap, equal match"""
        q = PortconQuery(self.p, ports=(60400, 60410), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60400, 60410)], ports)
Esempio n. 41
0
    def test_056_single_superset_edge1(self):
        """Portcon query with single port superset, equal edge case"""
        q = PortconQuery(self.p, ports=(50601, 50601), ports_superset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50601, 50601)], ports)
Esempio n. 42
0
    def test_011_user_regex(self):
        """Portcon query with context user regex match"""
        q = PortconQuery(self.p, user="******", user_regex=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(11, 11), (11000, 11000)], ports)
Esempio n. 43
0
    def test_001_protocol(self):
        """Portcon query with protocol match"""
        q = PortconQuery(self.p, protocol=IPPROTO_UDP)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(1, 1)], ports)
Esempio n. 44
0
    def test_021_role_regex(self):
        """Portcon query with context role regex match"""
        q = PortconQuery(self.p, role="role21(a|c)_r", role_regex=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(21, 21), (21001, 21001)], ports)
Esempio n. 45
0
    def test_062_range_overlap_high_half(self):
        """Portcon query with range overlap, high half match"""
        q = PortconQuery(self.p, ports=(60205, 60211), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60200, 60210)], ports)
Esempio n. 46
0
    def test_052_single_subset(self):
        """Portcon query with single port subset"""
        q = PortconQuery(self.p, ports=(50200, 50200), ports_subset=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(50200, 50200)], ports)
Esempio n. 47
0
    def test_060_single_overlap_edge3(self):
        """Portcon query with single overlap, range match proper superset"""
        q = PortconQuery(self.p, ports=(60000, 60002), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60001, 60001)], ports)
Esempio n. 48
0
    def test_063_range_overlap_middle(self):
        """Portcon query with range overlap, middle match"""
        q = PortconQuery(self.p, ports=(60305, 60308), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60300, 60310)], ports)
Esempio n. 49
0
    def test_061_range_overlap_low_half(self):
        """Portcon query with range overlap, low half match"""
        q = PortconQuery(self.p, ports=(60100, 60105), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60101, 60110)], ports)
Esempio n. 50
0
    def test_064_range_overlap_equal(self):
        """Portcon query with range overlap, equal match"""
        q = PortconQuery(self.p, ports=(60400, 60410), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60400, 60410)], ports)
Esempio n. 51
0
    def test_063_range_overlap_middle(self):
        """Portcon query with range overlap, middle match"""
        q = PortconQuery(self.p, ports=(60305, 60308), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60300, 60310)], ports)
Esempio n. 52
0
    def test_065_range_overlap_superset(self):
        """Portcon query with range overlap, superset match"""
        q = PortconQuery(self.p, ports=(60500, 60510), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60501, 60509)], ports)
Esempio n. 53
0
    def test_065_range_overlap_superset(self):
        """Portcon query with range overlap, superset match"""
        q = PortconQuery(self.p, ports=(60500, 60510), ports_overlap=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(60501, 60509)], ports)
Esempio n. 54
0
    def test_010_user_exact(self):
        """Portcon query with context user exact match"""
        q = PortconQuery(self.p, user="******", user_regex=False)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(10, 10)], ports)
Esempio n. 55
0
    def test_020_role_exact(self):
        """Portcon query with context role exact match"""
        q = PortconQuery(self.p, role="role20_r", role_regex=False)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(20, 20)], ports)
Esempio n. 56
0
    def test_011_user_regex(self):
        """Portcon query with context user regex match"""
        q = PortconQuery(self.p, user="******", user_regex=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(11, 11), (11000, 11000)], ports)
Esempio n. 57
0
    def test_030_type_exact(self):
        """Portcon query with context type exact match"""
        q = PortconQuery(self.p, type_="type30", type_regex=False)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(30, 30)], ports)
Esempio n. 58
0
    def test_020_role_exact(self):
        """Portcon query with context role exact match"""
        q = PortconQuery(self.p, role="role20_r", role_regex=False)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(20, 20)], ports)
Esempio n. 59
0
    def test_040_range_exact(self):
        """Portcon query with context range exact match"""
        q = PortconQuery(self.p, range_="s0:c1 - s0:c0.c4")

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(40, 40)], ports)
Esempio n. 60
0
    def test_021_role_regex(self):
        """Portcon query with context role regex match"""
        q = PortconQuery(self.p, role="role21(a|c)_r", role_regex=True)

        ports = sorted(p.ports for p in q.results())
        self.assertListEqual([(21, 21), (21001, 21001)], ports)