Some unit tests (#670)

This commit is contained in:
Guillaume Valadon 2017-06-06 13:39:33 +02:00 committed by GitHub
parent 6db9cf9fb9
commit 3a2d7bb846
2 changed files with 23 additions and 0 deletions

View File

@ -97,6 +97,20 @@ str(BGPCapability()) == b'\x00\x00'
c = BGPCapability(code = 70) c = BGPCapability(code = 70)
assert(str(c) == b'F\x00') assert(str(c) == b'F\x00')
= BGPCapability - Check exception
from scapy.contrib.bgp import _BGPInvalidDataException
try:
BGPCapability("\x00")
False
except _BGPInvalidDataException:
True
= BGPCapability - Test haslayer()
BGPCapFourBytesASN().haslayer(BGPCapability) == True
= BGPCapability - Test getlayer()
isinstance(BGPCapFourBytesASN().getlayer(BGPCapability), BGPCapFourBytesASN)
############################ BGPCapMultiprotocol ############################## ############################ BGPCapMultiprotocol ##############################
+ BGPCapMultiprotocol class tests + BGPCapMultiprotocol class tests
@ -185,6 +199,10 @@ c.code == 3 and c.length == 0
c = BGPCapORF(orf = [BGPCapORFBlock(afi = 1, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)]), BGPCapORFBlock(afi = 2, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)])]) c = BGPCapORF(orf = [BGPCapORFBlock(afi = 1, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)]), BGPCapORFBlock(afi = 2, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)])])
c.code == 3 and c.orf[0].afi == 1 and c.orf[0].safi == 1 and c.orf[0].entries[0].orf_type == 64 and c.orf[0].entries[0].send_receive == 3 and c.orf[1].afi == 2 and c.orf[1].safi == 1 and c.orf[1].entries[0].orf_type == 64 and c.orf[1].entries[0].send_receive == 3 c.code == 3 and c.orf[0].afi == 1 and c.orf[0].safi == 1 and c.orf[0].entries[0].orf_type == 64 and c.orf[0].entries[0].send_receive == 3 and c.orf[1].afi == 2 and c.orf[1].safi == 1 and c.orf[1].entries[0].orf_type == 64 and c.orf[1].entries[0].send_receive == 3
= BGPCapORF - Dissection
p = BGPCapORF(b'\x03\x07\x00\x01\x00\x01\x01@\x03')
assert(len(p.orf) == 1)
####################### BGPCapGracefulRestart.GRTuple ######################### ####################### BGPCapGracefulRestart.GRTuple #########################
+ BGPCapGracefulRestart.GRTuple class tests + BGPCapGracefulRestart.GRTuple class tests
@ -615,6 +633,10 @@ assert(m.path_attr[0].attribute.safi == 1)
assert(m.path_attr[0].attribute.afi_safi_specific.withdrawn_routes[0].prefix == "6000::/3") assert(m.path_attr[0].attribute.afi_safi_specific.withdrawn_routes[0].prefix == "6000::/3")
assert(m.nlri == []) assert(m.nlri == [])
= BGPUpdate - with BGPHeader
p = BGP(str(BGPHeader()/BGPUpdate()))
assert(BGPHeader in p and BGPUpdate in p)
########## BGPNotification Class ################################### ########## BGPNotification Class ###################################
+ BGPNotification class tests + BGPNotification class tests

View File

@ -331,6 +331,7 @@ if not WINDOWS:
~ manufdb ~ manufdb
assert(MANUFDB._resolve_MAC("00:00:0F:01:02:03") == "Next:01:02:03") assert(MANUFDB._resolve_MAC("00:00:0F:01:02:03") == "Next:01:02:03")
assert(MANUFDB._get_short_manuf("00:00:0F:01:02:03") == "Next") assert(MANUFDB._get_short_manuf("00:00:0F:01:02:03") == "Next")
assert(in6_addrtovendor("fe80::0200:0fff:fe01:0203").lower().startswith("next"))
= Test utility functions - network related = Test utility functions - network related
~ netaccess ~ netaccess