def test_pycat_c1(self): "Paths for portCheck" assert pycat.portCheck(32768) assert not pycat.portCheck(-32768) assert not pycat.portCheck("abcde") "Paths for ipCheck" assert not pycat.ipCheck("128.128.128.-128/16") assert not pycat.ipCheck("128.128.128.128/255.255.254.255") assert not pycat.ipCheck("128.128.128.128/255.255.256.255") assert not pycat.ipCheck("128.128.128.128/-16") assert not pycat.ipCheck("128.128.128.-128") assert not pycat.ipCheck("128.128") assert not pycat.ipCheck("128.128.128.128/255.255.255.abc") assert pycat.ipCheck("140.113.1.1/255.255.0.0") "Paths for main" assert not json.loads(pycat.main("140.113.1.1/-1", "32768"))["success"] assert json.loads(pycat.main("140.113.1.1"))["success"] assert not json.loads(pycat.main("140.113.1.1", "1-"))["success"] assert not json.loads(pycat.main("140.113.1.1", "65536-0"))["success"] assert not json.loads(pycat.main("140.113.1.1", "0-65536"))["success"] assert not json.loads(pycat.main("140.113.1.1", "0,65536"))["success"] assert json.loads(pycat.main("140.113.1.1", "0-65535"))["success"] assert json.loads(pycat.main("140.113.1.1", "0,65535"))["success"] assert json.loads(pycat.main("140.113.1.1", "32768"))["success"] "Paths for scanner" scanner = Scanner() assert not scanner.scanip("256.256.256.256") assert scanner.scanip("127.0.0.1")
def test_pycat_mcdc(self): assert pycat.portCheck(12345) assert not pycat.portCheck(66666) assert not pycat.portCheck("abc") assert pycat.ipCheck("1.1.1.1") assert not pycat.ipCheck("1.1.1.256") assert not pycat.ipCheck("pycat!") assert not pycat.ipCheck("1.1.1.256/25") assert pycat.ipCheck("1.1.1.1/22") assert not pycat.ipCheck("1.1.1.1/66666") assert not pycat.ipCheck("1.1.1.1/255.255.255.256") assert not pycat.ipCheck("1.1.1.1/a.b.c.d") assert not pycat.ipCheck("1.1.1.1/1.2.3.4") assert not json.loads(pycat.main("1.1.1.256", "123"))["success"] assert json.loads(pycat.main("1.1.1.1"))["success"] assert json.loads(pycat.main("1.1.1.1", "25-30"))["success"] assert not json.loads(pycat.main("1.1.1.1", "25-30-35"))["success"] assert not json.loads(pycat.main("1.1.1.1", "25-a"))["success"] assert not json.loads(pycat.main("1.1.1.1", "a-25"))["success"] assert json.loads(pycat.main("1.1.1.1", "25,30"))["success"] assert not json.loads(pycat.main("1.1.1.1", "25,a"))["success"] scanner = Scanner() assert scanner.scanip("127.0.0.1") assert not scanner.scanip("1.1.1.256")
def test_pycat_c0(self): assert not pycat.ipCheck("128.400,.128/#$%") assert not pycat.ipCheck("140.113.1.256/24") assert pycat.ipCheck("128.128.128.128/255.255.0.0") assert not pycat.ipCheck("128.128.128.128/255.255.256.0") assert not pycat.ipCheck("140.113.1.1/40") assert pycat.ipCheck("140.113.1.1/24") assert json.loads(pycat.main("0.0.0.0", "17768"))["success"] assert not json.loads(pycat.main("140.113.1.1", "88888"))["success"] assert json.loads(pycat.main("0.0.0.0"))["success"] assert not json.loads(pycat.main("0.0.0.0", "1--2"))["success"] assert not json.loads(pycat.main("0.0.0.0", "80000,80001"))["success"] scanner = Scanner() assert scanner.scanip("127.0.0.1") assert not scanner.scanip("256.256.256.256")
def test_Robust(self): """ Weak & Strong Robust Equivalence Class """ """ IP part """ # min - 1 assert not json.loads(pycat.main("-1.255.255.255", "17768"))["success"] assert not json.loads(pycat.main("-1.255.255.255/16", "17768"))["success"] # max + 1 assert not json.loads(pycat.main("255.255.255.256", "17768"))["success"] assert not json.loads(pycat.main("255.255.255.256/16", "17768"))["success"] """ Submask part """ # min - 1 assert not json.loads(pycat.main("128.128.128.128/-1", "17768"))["success"] # max + 1 assert not json.loads(pycat.main("128.128.128.128/33", "17768"))["success"] """ Port """ # min - 1 assert not json.loads(pycat.main("128.128.128.128", "-1"))["success"] assert not json.loads(pycat.main("128.128.128.128/16", "-1"))["success"] # max + 1 assert not json.loads(pycat.main("128.128.128.128", "65536"))["success"] assert not json.loads(pycat.main("128.128.128.128/16", "65536"))["success"] """ Strong Robust Equivalence Class """ """ IP and subnet """ assert not json.loads(pycat.main("-1.255.255.255/-1", "17768"))["success"] assert not json.loads(pycat.main("255.255.255.256/33", "17768"))["success"] """ submask and port """ assert not json.loads(pycat.main("128.128.128.128/-1", "-1"))["success"] assert not json.loads(pycat.main("128.128.128.128/33", "65536"))["success"] """ ip and port """ # min - 1 assert not json.loads(pycat.main("-1.255.255.255", "-1"))["success"] assert not json.loads(pycat.main("-1.255.255.255/16", "-1"))["success"] # max + 1 assert not json.loads(pycat.main("255.255.255.256", "65536"))["success"] assert not json.loads(pycat.main("255.255.255.256/16", "65536"))["success"] """ All """ assert not json.loads(pycat.main("-1.255.255.255/-1", "-1"))["success"] assert not json.loads(pycat.main("255.255.255.256/32", "65536"))["success"]
def test_Normal(self): """ Weak Normal & Strong Normal Equivalence Class """ assert json.loads(pycat.main("128.128.128.128", "17768"))["success"] assert json.loads(pycat.main("128.128.128.128/16", "17768"))["success"]
def test_RuleC(self): assert not json.loads(pycat.main("Ops", "Ops"))["success"] assert not json.loads(pycat.main("none", "none"))["success"] assert not json.loads(pycat.main("Null", "Null"))["success"] assert not json.loads(pycat.main(";--", "#"))["success"]
def test_RuleB(self): assert not json.loads(pycat.main("128.128.128", "17768"))["success"] assert not json.loads(pycat.main("128,128,128,128", "22"))["success"] assert not json.loads(pycat.main("128,128.128,128", "22"))["success"] assert not json.loads(pycat.main("128,128,128,128", "22~25"))["success"] assert not json.loads(pycat.main("128-128-128-128", "22"))["success"] assert not json.loads(pycat.main("128/128/128/128", "22"))["success"] assert not json.loads(pycat.main("128.128.128.128", "22.80"))["success"] assert not json.loads(pycat.main("128.128.128.128", "22,80.443"))["success"] assert not json.loads(pycat.main("128.128.128.128", "22/80.443"))["success"] assert not json.loads(pycat.main("128.128.128.128", "128.128.128.128"))["success"] assert not json.loads(pycat.main("128", "128.128.128.128"))["success"]
def test_normal(self): """ IP part """ """one IP and one Port """ assert json.loads(pycat.main("0.0.0.0", "17768"))["success"] # min assert json.loads(pycat.main("0.0.0.1", "17768"))["success"] # min+1 # max-1 assert json.loads(pycat.main("255.255.255.254", "17768"))["success"] # max assert json.loads(pycat.main("255.255.255.255", "17768"))["success"] """ Subnet and one Port """ assert json.loads(pycat.main("0.0.0.0/16", "17768"))["success"] # min # min+1 assert json.loads(pycat.main("0.0.0.1/16", "17768"))["success"] # max-1 assert json.loads(pycat.main("255.255.255.254/16", "17768"))["success"] # max assert json.loads(pycat.main("255.255.255.255/16", "17768"))["success"] """ Subnet """ """ Subnet and one Port """ # min assert json.loads(pycat.main("128.128.128.128/0", "17768"))["success"] # min+1 assert json.loads(pycat.main("128.128.128.128/1", "17768"))["success"] # max-1 assert json.loads(pycat.main("128.128.128.128/31", "17768"))["success"] # max assert json.loads(pycat.main("128.128.128.128/32", "17768"))["success"] """ Port part """ """one IP and one Port """ assert json.loads(pycat.main("128.128.128.128", "0"))["success"] # min # min+1 assert json.loads(pycat.main("128.128.128.128", "1"))["success"] # max-1 assert json.loads(pycat.main("128.128.128.128", "65534"))["success"] # max assert json.loads(pycat.main("128.128.128.128", "65535"))["success"] """ Subnet and one Port """ # min assert json.loads(pycat.main("128.128.128.128/16", "0"))["success"] # min+1 assert json.loads(pycat.main("128.128.128.128/16", "1"))["success"] # max-1 assert json.loads(pycat.main("128.128.128.128/16", "65534"))["success"] # max assert json.loads(pycat.main("128.128.128.128/16", "65535"))["success"] """ All middle """ assert json.loads(pycat.main("128.128.128.128", "17768"))["success"] assert json.loads(pycat.main("128.128.128.128/16", "17768"))["success"]
def test_normal(self): assert json.loads(pycat.main("128.128.128.128", "17768"))["success"] assert json.loads(pycat.main("128.128.128.128/16", "17768"))["success"] assert json.loads(pycat.main("128.128.128.128", "22,80,443"))["success"] assert json.loads(pycat.main("128.128.128.128/16", "22-25"))["success"]