# PPPoE unit tests
#
# Type the following command to launch start the tests:
# $ sudo bash test/run_tests -t test/pppoe.uts -f html -o /tmp/kamene_pppoe_test_$(date +%Y%M%d-%H%H%S).html

+ Test PPPoE

= PPPoED
~ pppoed
p=PPPoED(b'\x11\x09\x00\x00\x00\x1f\x01\x01\x00\x0b\x4d\x61\x63\x42\x6f\x6f\x6b\x2d\x50\x72\x6f\x01\x02\x00\x00\x01\x03\x00\x08\x08\xf4\x18\x35\x80\xff\xff\xff')
assert(p[PPPoED].code == 9)
assert(p[PPPoED].tags[0].data == b'MacBook-Pro')
assert(p[PPPoED].tags[1].data == b'')
assert(p[PPPoED].tags[2].data == b'\x08\xf4\x18\x35\x80\xff\xff\xff')
p=PPPoED(code='PADO', tags=[PPPoE_Tag(type='Service-Name', data='MacBook-Pro'), PPPoE_Tag(type='AC-Name', data='HZ-HZ-DZKD-BAS-0X5E-0.XYW'), PPPoE_Tag(type='Host-Uniq', data=b'\x08\xf4\x18\x35\x80\xff\xff\xff')])
bytes(p)
assert(_ == b'\x11\x07\x00\x00\x00\x38\x01\x01\x00\x0b\x4d\x61\x63\x42\x6f\x6f\x6b\x2d\x50\x72\x6f\x01\x02\x00\x19\x48\x5a\x2d\x48\x5a\x2d\x44\x5a\x4b\x44\x2d\x42\x41\x53\x2d\x30\x58\x35\x45\x2d\x30\x2e\x58\x59\x57\x01\x03\x00\x08\x08\xf4\x18\x35\x80\xff\xff\xff')
q=PPPoED(_)
assert(bytes(p) == bytes(q))
assert(PPPoED(bytes(q)) == q)
assert(q[PPPoED].tags[0].type == 0x0101)
assert(q[PPPoED].tags[0].data == b'MacBook-Pro')
assert(q[PPPoED].tags[1].data == b'HZ-HZ-DZKD-BAS-0X5E-0.XYW')


= PPP LCP
~ ppp lcp
p=PPP(b'\xc0\x21\x01\x01\x00\x0e\x01\x04\x05\xd4\x05\x06\x0f\x3d\xad\x94')
assert(p[PPP_LCP].code == 1)
assert(p[PPP_LCP].id == 1)
assert(p[PPP_LCP_Option_MRU].data == 1492)
assert(p[PPP_LCP_Option_MAGIC].data == 0xf3dad94)
p=PPP()/PPP_LCP(id=0x58, options=[PPP_LCP_Option_MRU(data=1480), PPP_LCP_Option_AUTH(data='PAP'), PPP_LCP_Option_MAGIC(data=0x5e630ab8)])
bytes(p)
assert(_ == b'\xc0\x21\x01\x58\x00\x12\x01\x04\x05\xc8\x03\x04\xc0\x23\x05\x06\x5e\x63\x0a\xb8')
q=PPP(_)
assert(bytes(p) == bytes(q))
assert(PPP(bytes(q)) == q)
assert(p[PPP_LCP_Option_MRU].data == 1480)
assert(p[PPP_LCP_Option_AUTH].data == 0xc023)
assert(p[PPP_LCP_Option_MAGIC].data == 0x5e630ab8)

