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_WeakRobust(self): assert not pycat.ipCheck("-1.-1.-1.-1") assert not pycat.ipCheck("256.256.256.256") assert not pycat.ipCheck("a.a.a.a") assert not pycat.ipCheck("0,0,0,0") assert not pycat.ipCheck("0...") assert not pycat.ipCheck("0.0.0.0/-1") assert not pycat.ipCheck("0.0.0.0/33") assert not pycat.ipCheck("0.0.0.0/-1.-1.-1.-1") assert not pycat.ipCheck("0.0.0.0/@")
def test_WeakRobust(self): assert not pycat.ipCheck("128.-128.128.128") assert not pycat.ipCheck("128.400.128.128") assert not pycat.ipCheck("128.abc.128.128") assert not pycat.ipCheck("128.128,128.128") assert not pycat.ipCheck("128..128.128") assert not pycat.ipCheck("128.128.128.128/-16") assert not pycat.ipCheck("128.128.128.128/40") assert not pycat.ipCheck("128.128.128.128/200.200.0.0") assert not pycat.ipCheck("128.128.128.128/#$%")
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_WeakNormal(self): assert pycat.ipCheck("0.128.128.128") assert pycat.ipCheck("255.128.128.128") assert pycat.ipCheck("128.0.128.128") assert pycat.ipCheck("128.255.128.128") assert pycat.ipCheck("128.128.0.128") assert pycat.ipCheck("128.128.255.128") assert pycat.ipCheck("128.128.128.0") assert pycat.ipCheck("128.128.128.255")
def test_WeakRobust(self): assert not pycat.ipCheck("-1.128.128.128") assert not pycat.ipCheck("256.128.128.128") assert not pycat.ipCheck("128.-1.128.128") assert not pycat.ipCheck("128.256.128.128") assert not pycat.ipCheck("128.128.-1.128") assert not pycat.ipCheck("128.128.256.128") assert not pycat.ipCheck("128.128.128.-1") assert not pycat.ipCheck("128.128.128.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_RuleB(self): "Otherwise" assert not pycat.ipCheck("abc.-128,400")
def test_RuleA(self): "3 points, 4 words, 0 <= numbers <= 255" assert pycat.ipCheck("128.128.128.128")
def test_StrongRobust(self): assert not pycat.ipCheck("-1,-1,-1,-1") assert not pycat.ipCheck("-1...") assert not pycat.ipCheck("-1.-1.-1.-1/-1") assert not pycat.ipCheck("-1.-1.-1.-1/33") assert not pycat.ipCheck("-1.-1.-1.-1/-1.-1.-1.-1") assert not pycat.ipCheck("-1.-1.-1.-1/@") assert not pycat.ipCheck("256,256,256,256") assert not pycat.ipCheck("256...") assert not pycat.ipCheck("256.256.256.256/-1") assert not pycat.ipCheck("256.256.256.256/33") assert not pycat.ipCheck("256.256.256.256/-1.-1.-1.-1") assert not pycat.ipCheck("256.256.256.256/@") assert not pycat.ipCheck("a,a,a,a") assert not pycat.ipCheck("a...") assert not pycat.ipCheck("a.a.a.a/-1") assert not pycat.ipCheck("a.a.a.a/33") assert not pycat.ipCheck("a.a.a.a/-1.-1.-1.-1") assert not pycat.ipCheck("a.a.a.a/@") assert not pycat.ipCheck("0,,,") assert not pycat.ipCheck("0,0,0,0/-1") assert not pycat.ipCheck("0,0,0,0/33") assert not pycat.ipCheck("0,0,0,0/-1.-1.-1.-1") assert not pycat.ipCheck("0,0,0,0/@") assert not pycat.ipCheck("0.../-1") assert not pycat.ipCheck("0.../33") assert not pycat.ipCheck("0.../-1.-1.-1.-1") assert not pycat.ipCheck("0.../@") assert not pycat.ipCheck("-1,,,") assert not pycat.ipCheck("256,,,") assert not pycat.ipCheck("a,,,") assert not pycat.ipCheck("-1,-1,-1,-1/-1") assert not pycat.ipCheck("-1,-1,-1,-1/33") assert not pycat.ipCheck("-1,-1,-1,-1/-1.-1.-1.-1") assert not pycat.ipCheck("-1,-1,-1,-1/@") assert not pycat.ipCheck("256,256,256,256/-1") assert not pycat.ipCheck("256,256,256,256/33") assert not pycat.ipCheck("256,256,256,256/-1.-1.-1.-1") assert not pycat.ipCheck("256,256,256,256/@") assert not pycat.ipCheck("a,a,a,a/-1") assert not pycat.ipCheck("a,a,a,a/33") assert not pycat.ipCheck("a,a,a,a/-1.-1.-1.-1") assert not pycat.ipCheck("a,a,a,a/@") assert not pycat.ipCheck("-1.../-1") assert not pycat.ipCheck("-1.../33") assert not pycat.ipCheck("-1.../-1.-1.-1.-1") assert not pycat.ipCheck("-1.../@") assert not pycat.ipCheck("256.../-1") assert not pycat.ipCheck("256.../33") assert not pycat.ipCheck("256.../-1.-1.-1.-1") assert not pycat.ipCheck("256.../@") assert not pycat.ipCheck("a.../-1") assert not pycat.ipCheck("a.../33") assert not pycat.ipCheck("a.../-1.-1.-1.-1") assert not pycat.ipCheck("a.../@") assert not pycat.ipCheck("0,,,/-1") assert not pycat.ipCheck("0,,,/33") assert not pycat.ipCheck("0,,,/-1.-1.-1.-1") assert not pycat.ipCheck("0,,,/@") assert not pycat.ipCheck("-1,,,/-1") assert not pycat.ipCheck("-1,,,/33") assert not pycat.ipCheck("-1,,,/-1.-1.-1.-1") assert not pycat.ipCheck("-1,,,/@") assert not pycat.ipCheck("256,,,/-1") assert not pycat.ipCheck("256,,,/33") assert not pycat.ipCheck("256,,,/-1.-1.-1.-1") assert not pycat.ipCheck("256,,,/@") assert not pycat.ipCheck("a,,,/-1") assert not pycat.ipCheck("a,,,/33") assert not pycat.ipCheck("a,,,/-1.-1.-1.-1") assert not pycat.ipCheck("a,,,/@")
def test_WeakNormal(self): assert pycat.ipCheck("0.0.0.0") assert pycat.ipCheck("0.0.0.0/0") assert pycat.ipCheck("0.0.0.0/0.0.0.0") assert pycat.ipCheck("0.0.0.0/255.255.255.255")
def test_StrongNormal(self): assert pycat.ipCheck("0.0.128.128") assert pycat.ipCheck("0.255.128.128") assert pycat.ipCheck("255.0.128.128") assert pycat.ipCheck("255.255.128.128") assert pycat.ipCheck("0.128.0.128") assert pycat.ipCheck("0.128.255.128") assert pycat.ipCheck("255.128.0.128") assert pycat.ipCheck("255.128.255.128") assert pycat.ipCheck("0.128.128.0") assert pycat.ipCheck("0.128.128.255") assert pycat.ipCheck("255.128.128.0") assert pycat.ipCheck("255.128.128.255") assert pycat.ipCheck("128.0.0.128") assert pycat.ipCheck("128.0.255.128") assert pycat.ipCheck("128.255.0.128") assert pycat.ipCheck("128.255.255.128") assert pycat.ipCheck("128.0.128.0") assert pycat.ipCheck("128.0.128.255") assert pycat.ipCheck("128.255.128.0") assert pycat.ipCheck("128.255.128.255") assert pycat.ipCheck("128.128.0.0") assert pycat.ipCheck("128.128.0.255") assert pycat.ipCheck("128.128.255.0") assert pycat.ipCheck("128.128.255.255") assert pycat.ipCheck("0.0.0.128") assert pycat.ipCheck("255.0.0.128") assert pycat.ipCheck("0.255.0.128") assert pycat.ipCheck("0.0.255.128") assert pycat.ipCheck("255.255.0.128") assert pycat.ipCheck("255.0.255.128") assert pycat.ipCheck("0.255.255.128") assert pycat.ipCheck("255.255.255.128") assert pycat.ipCheck("0.0.128.0") assert pycat.ipCheck("255.0.128.0") assert pycat.ipCheck("0.255.128.0") assert pycat.ipCheck("0.0.128.255") assert pycat.ipCheck("255.255.128.0") assert pycat.ipCheck("255.0.128.255") assert pycat.ipCheck("0.255.128.255") assert pycat.ipCheck("255.255.128.255") assert pycat.ipCheck("0.128.0.0") assert pycat.ipCheck("255.128.0.0") assert pycat.ipCheck("0.128.255.0") assert pycat.ipCheck("0.128.0.255") assert pycat.ipCheck("255.128.255.0") assert pycat.ipCheck("255.128.0.255") assert pycat.ipCheck("0.128.255.255") assert pycat.ipCheck("255.128.255.255") assert pycat.ipCheck("128.0.0.0") assert pycat.ipCheck("128.255.0.0") assert pycat.ipCheck("128.0.255.0") assert pycat.ipCheck("128.0.0.255") assert pycat.ipCheck("128.255.255.0") assert pycat.ipCheck("128.255.0.255") assert pycat.ipCheck("128.0.255.255") assert pycat.ipCheck("128.255.255.255") assert pycat.ipCheck("0.0.0.0") assert pycat.ipCheck("255.0.0.0") assert pycat.ipCheck("0.255.0.0") assert pycat.ipCheck("0.0.255.0") assert pycat.ipCheck("0.0.0.255") assert pycat.ipCheck("255.255.0.0") assert pycat.ipCheck("255.0.255.0") assert pycat.ipCheck("255.0.0.255") assert pycat.ipCheck("0.255.255.0") assert pycat.ipCheck("0.255.0.255") assert pycat.ipCheck("0.0.255.255") assert pycat.ipCheck("255.255.255.0") assert pycat.ipCheck("255.255.0.255") assert pycat.ipCheck("255.0.255.255") assert pycat.ipCheck("0.255.255.255") assert pycat.ipCheck("255.255.255.255")
def test_StrongRobust(self): assert not pycat.ipCheck("128.-128,128.128") assert not pycat.ipCheck("128.-128..128") assert not pycat.ipCheck("128.-128.128.128/-16") assert not pycat.ipCheck("128.-128.128.128/40") assert not pycat.ipCheck("128.-128.128.128/200.200.0.0") assert not pycat.ipCheck("128.-128.128.128/#$%") assert not pycat.ipCheck("128.400,128.128") assert not pycat.ipCheck("128.400..128") assert not pycat.ipCheck("128.400.128.128/-16") assert not pycat.ipCheck("128.400.128.128/40") assert not pycat.ipCheck("128.400.128.128/200.200.0.0") assert not pycat.ipCheck("128.400.128.128/#$%") assert not pycat.ipCheck("128.abc,128.128") assert not pycat.ipCheck("128.abc..128") assert not pycat.ipCheck("128.abc.128.128/-16") assert not pycat.ipCheck("128.abc.128.128/40") assert not pycat.ipCheck("128.abc.128.128/200.200.0.0") assert not pycat.ipCheck("128.abc.128.128/#$%") assert not pycat.ipCheck("128.,128.128") assert not pycat.ipCheck("128.128,128.128/-16") assert not pycat.ipCheck("128.128,128.128/40") assert not pycat.ipCheck("128.128,128.128/200.200.0.0") assert not pycat.ipCheck("128.128,128.128/#$%") assert not pycat.ipCheck("128..128.128/-16") assert not pycat.ipCheck("128..128.128/40") assert not pycat.ipCheck("128..128.128/200.200.0.0") assert not pycat.ipCheck("128..128.128/#$%") assert not pycat.ipCheck("128.-128,.128") assert not pycat.ipCheck("128.400,.128") assert not pycat.ipCheck("128.abc,.128") assert not pycat.ipCheck("128.-128,128.128/-16") assert not pycat.ipCheck("128.-128,128.128/40") assert not pycat.ipCheck("128.-128,128.128/200.200.0.0") assert not pycat.ipCheck("128.-128,128.128/#$%") assert not pycat.ipCheck("128.400,128.128/-16") assert not pycat.ipCheck("128.400,128.128/40") assert not pycat.ipCheck("128.400,128.128/200.200.0.0") assert not pycat.ipCheck("128.400,128.128/#$%") assert not pycat.ipCheck("128.abc,128.128/-16") assert not pycat.ipCheck("128.abc,128.128/40") assert not pycat.ipCheck("128.abc,128.128/200.200.0.0") assert not pycat.ipCheck("128.abc,128.128/#$%") assert not pycat.ipCheck("128.-128..128/-16") assert not pycat.ipCheck("128.-128..128/40") assert not pycat.ipCheck("128.-128..128/200.200.0.0") assert not pycat.ipCheck("128.-128..128/#$%") assert not pycat.ipCheck("128.400..128/-16") assert not pycat.ipCheck("128.400..128/40") assert not pycat.ipCheck("128.400..128/200.200.0.0") assert not pycat.ipCheck("128.400..128/#$%") assert not pycat.ipCheck("128.abc..128/-16") assert not pycat.ipCheck("128.abc..128/40") assert not pycat.ipCheck("128.abc..128/200.200.0.0") assert not pycat.ipCheck("128.abc..128/#$%") assert not pycat.ipCheck("128.,128.128/-16") assert not pycat.ipCheck("128.,128.128/40") assert not pycat.ipCheck("128.,128.128/200.200.0.0") assert not pycat.ipCheck("128.,128.128/#$%") assert not pycat.ipCheck("128.-128,.128/-16") assert not pycat.ipCheck("128.-128,.128/40") assert not pycat.ipCheck("128.-128,.128/200.200.0.0") assert not pycat.ipCheck("128.-128,.128/#$%") assert not pycat.ipCheck("128.400,.128/-16") assert not pycat.ipCheck("128.400,.128/40") assert not pycat.ipCheck("128.400,.128/200.200.0.0") assert not pycat.ipCheck("128.400,.128/#$%") assert not pycat.ipCheck("128.abc,.128/-16") assert not pycat.ipCheck("128.abc,.128/40") assert not pycat.ipCheck("128.abc,.128/200.200.0.0") assert not pycat.ipCheck("128.abc,.128/#$%")
def test_WeakNormal(self): assert pycat.ipCheck("128.128.128.128") assert pycat.ipCheck("128.128.128.128/16") assert pycat.ipCheck("128.128.128.128/255.255.0.0") assert pycat.ipCheck("128.128.128.128/0.0.255.255")
def test_StrongRobust(self): assert not pycat.ipCheck("-1.-1.128.128") assert not pycat.ipCheck("-1.256.128.128") assert not pycat.ipCheck("256.-1.128.128") assert not pycat.ipCheck("256.256.128.128") assert not pycat.ipCheck("-1.128.-1.128") assert not pycat.ipCheck("-1.128.256.128") assert not pycat.ipCheck("256.128.-1.128") assert not pycat.ipCheck("256.128.256.128") assert not pycat.ipCheck("-1.128.128.-1") assert not pycat.ipCheck("-1.128.128.256") assert not pycat.ipCheck("256.128.128.-1") assert not pycat.ipCheck("256.128.128.256") assert not pycat.ipCheck("128.-1.-1.128") assert not pycat.ipCheck("128.-1.256.128") assert not pycat.ipCheck("128.256.-1.128") assert not pycat.ipCheck("128.256.256.128") assert not pycat.ipCheck("128.-1.128.-1") assert not pycat.ipCheck("128.-1.128.256") assert not pycat.ipCheck("128.256.128.-1") assert not pycat.ipCheck("128.256.128.256") assert not pycat.ipCheck("128.128.-1.-1") assert not pycat.ipCheck("128.128.-1.256") assert not pycat.ipCheck("128.128.256.-1") assert not pycat.ipCheck("128.128.256.256") assert not pycat.ipCheck("-1.-1.-1.128") assert not pycat.ipCheck("256.-1.-1.128") assert not pycat.ipCheck("-1.256.-1.128") assert not pycat.ipCheck("-1.-1.256.128") assert not pycat.ipCheck("256.256.-1.128") assert not pycat.ipCheck("256.-1.256.128") assert not pycat.ipCheck("-1.256.256.128") assert not pycat.ipCheck("256.256.256.128") assert not pycat.ipCheck("-1.-1.128.-1") assert not pycat.ipCheck("256.-1.128.-1") assert not pycat.ipCheck("-1.256.128.-1") assert not pycat.ipCheck("-1.-1.128.256") assert not pycat.ipCheck("256.256.128.-1") assert not pycat.ipCheck("256.-1.128.256") assert not pycat.ipCheck("-1.256.128.256") assert not pycat.ipCheck("256.256.128.256") assert not pycat.ipCheck("-1.128.-1.-1") assert not pycat.ipCheck("256.128.-1.-1") assert not pycat.ipCheck("-1.128.256.-1") assert not pycat.ipCheck("-1.128.-1.256") assert not pycat.ipCheck("256.128.256.-1") assert not pycat.ipCheck("256.128.-1.256") assert not pycat.ipCheck("-1.128.256.256") assert not pycat.ipCheck("256.128.256.256") assert not pycat.ipCheck("128.-1.-1.-1") assert not pycat.ipCheck("128.256.-1.-1") assert not pycat.ipCheck("128.-1.256.-1") assert not pycat.ipCheck("128.-1.-1.256") assert not pycat.ipCheck("128.256.256.-1") assert not pycat.ipCheck("128.256.-1.256") assert not pycat.ipCheck("128.-1.256.256") assert not pycat.ipCheck("128.256.256.256") assert not pycat.ipCheck("-1.-1.-1.-1") assert not pycat.ipCheck("256.-1.-1.-1") assert not pycat.ipCheck("-1.256.-1.-1") assert not pycat.ipCheck("-1.-1.256.-1") assert not pycat.ipCheck("-1.-1.-1.256") assert not pycat.ipCheck("256.256.-1.-1") assert not pycat.ipCheck("256.-1.256.-1") assert not pycat.ipCheck("256.-1.-1.256") assert not pycat.ipCheck("-1.256.256.-1") assert not pycat.ipCheck("-1.256.-1.256") assert not pycat.ipCheck("-1.-1.256.256") assert not pycat.ipCheck("256.256.256.-1") assert not pycat.ipCheck("256.256.-1.256") assert not pycat.ipCheck("256.-1.256.256") assert not pycat.ipCheck("-1.256.256.256") assert not pycat.ipCheck("256.256.256.256")