• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1% STAMP regression tests for Scapy
2
3# More information at http://www.secdev.org/projects/UTscapy/
4
5# Type the following command to launch start the tests:
6# $ test/run_tests -t test/contrib/stamp.uts
7
8############
9# STAMP
10############
11
12+ STAMP tests
13
14= Load module
15
16load_contrib("stamp")
17
18= Test STAMP Session-Sender Test (Unauthenticated)
19~ stamp-session-sender-test
20
21created = STAMPSessionSenderTestUnauthenticated(
22    seq=0x1234,
23    ts=1234.5678,
24    err_estimate=ErrorEstimate(
25        S=1,
26        Z=0,
27        scale=0x12,
28        multiplier=0x34
29    ),
30    ssid=1357
31)
32assert raw(created) == b'\x00\x00\x12\x34\x00\x00\x04\xD2\x91\x5B\x57\x3E\x92\x34\x05\x4D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
33parsed = STAMPSessionSenderTestUnauthenticated(raw(created))
34assert parsed.seq == 0x1234
35assert parsed.ts == 1234.5678
36assert parsed.err_estimate.S == 1
37assert parsed.err_estimate.Z == 0
38assert parsed.err_estimate.scale == 0x12
39assert parsed.err_estimate.multiplier == 0x34
40assert parsed.ssid == 1357
41assert parsed.mbz == 0
42assert not parsed.tlv_objects
43
44= Test STAMP Session-Reflector Test (Unauthenticated)
45~ stamp-session-reflector-test
46
47created = STAMPSessionReflectorTestUnauthenticated(
48    seq=0x1234,
49    ts=1234.5678,
50    err_estimate=ErrorEstimate(
51        S=1,
52        Z=0,
53        scale=0x12,
54        multiplier=0x34
55    ),
56    ssid=1357,
57    ts_rx=4321.8765,
58    seq_sender=0x4321,
59    ts_sender=2143.6587,
60    err_estimate_sender=ErrorEstimate(
61        S=0,
62        Z=0,
63        scale=0x21,
64        multiplier=0x43
65    ),
66    ttl_sender=111
67)
68assert raw(created) == b'\x00\x00\x12\x34\x00\x00\x04\xD2\x91\x5B\x57\x3E\x92\x34\x05\x4D\x00\x00\x10\xE1\xE0\x62\x4D\xD2\x00\x00\x43\x21\x00\x00\x08\x5F\xA8\xA0\x90\x2D\x21\x43\x00\x00\x6F\x00\x00\x00'
69parsed = STAMPSessionReflectorTestUnauthenticated(raw(created))
70assert parsed.seq == 0x1234
71assert parsed.ts == 1234.5678
72assert parsed.err_estimate.S == 1
73assert parsed.err_estimate.Z == 0
74assert parsed.err_estimate.scale == 0x12
75assert parsed.err_estimate.multiplier == 0x34
76assert parsed.ssid == 1357
77assert parsed.ts_rx == 4321.8765
78assert parsed.seq_sender == 0x4321
79assert parsed.ts_sender == 2143.6587
80assert parsed.err_estimate_sender.S == 0
81assert parsed.err_estimate_sender.Z == 0
82assert parsed.err_estimate_sender.scale == 0x21
83assert parsed.err_estimate_sender.multiplier == 0x43
84assert parsed.mbz1 == 0
85assert parsed.ttl_sender == 111
86assert parsed.mbz2 == 0
87assert not parsed.tlv_objects
88
89