2 from py.test import raises
3 from tiramisu.config import Config
4 from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \
5 PortOption, OptionDescription
10 b = IPOption('b', '', only_private=True)
11 od = OptionDescription('od', '', [a, b])
17 raises(ValueError, "c.a = '255.255.255.0'")
20 raises(ValueError, "c.b = '88.88.88.88'")
22 raises(ValueError, "c.b = '255.255.255.0'")
25 def test_ip_default():
26 a = IPOption('a', '', '88.88.88.88')
27 od = OptionDescription('od', '', [a])
33 a = NetworkOption('a', '')
34 od = OptionDescription('od', '', [a])
40 raises(ValueError, "c.a = '255.255.255.0'")
44 a = NetmaskOption('a', '')
45 od = OptionDescription('od', '', [a])
47 raises(ValueError, "c.a = '192.168.1.1'")
48 raises(ValueError, "c.a = '192.168.1.0'")
49 raises(ValueError, "c.a = '88.88.88.88'")
55 a = PortOption('a', '')
56 b = PortOption('b', '', allow_zero=True)
57 c = PortOption('c', '', allow_zero=True, allow_registred=False)
58 d = PortOption('d', '', allow_zero=True, allow_wellknown=False, allow_registred=False)
59 e = PortOption('e', '', allow_zero=True, allow_private=True)
60 f = PortOption('f', '', allow_private=True)
61 od = OptionDescription('od', '', [a, b, c, d, e, f])
63 raises(ValueError, "c.a = 0")
68 raises(ValueError, "c.a = 49152")
69 raises(ValueError, "c.a = 65535")
70 raises(ValueError, "c.a = 65536")
77 raises(ValueError, "c.b = 49152")
78 raises(ValueError, "c.b = 65535")
79 raises(ValueError, "c.b = 65536")
84 raises(ValueError, "c.c = 1024")
85 raises(ValueError, "c.c = 49151")
86 raises(ValueError, "c.c = 49152")
87 raises(ValueError, "c.c = 65535")
88 raises(ValueError, "c.c = 65536")
91 raises(ValueError, "c.d = 1")
92 raises(ValueError, "c.d = 1023")
93 raises(ValueError, "c.d = 1024")
94 raises(ValueError, "c.d = 49151")
95 raises(ValueError, "c.d = 49152")
96 raises(ValueError, "c.d = 65535")
97 raises(ValueError, "c.d = 65536")
107 raises(ValueError, "c.f = 0")
114 raises(ValueError, "c.f = 65536")
117 def test_port_range():
118 a = PortOption('a', '', allow_range=True)
119 b = PortOption('b', '', allow_range=True, allow_zero=True)
120 c = PortOption('c', '', allow_range=True, allow_zero=True, allow_registred=False)
121 d = PortOption('d', '', allow_range=True, allow_zero=True, allow_wellknown=False, allow_registred=False)
122 e = PortOption('e', '', allow_range=True, allow_zero=True, allow_private=True)
123 f = PortOption('f', '', allow_range=True, allow_private=True)
124 od = OptionDescription('od', '', [a, b, c, d, e, f])
126 raises(ValueError, "c.a = 0")
131 raises(ValueError, "c.a = 49152")
132 raises(ValueError, "c.a = 65535")
133 raises(ValueError, "c.a = 65536")
135 raises(ValueError, "c.a = '0:49151'")
136 raises(ValueError, "c.a = '1:49152'")
143 raises(ValueError, "c.b = 49152")
144 raises(ValueError, "c.b = 65535")
145 raises(ValueError, "c.b = 65536")
147 raises(ValueError, "c.b = '0:49152'")
152 raises(ValueError, "c.c = 1024")
153 raises(ValueError, "c.c = 49151")
154 raises(ValueError, "c.c = 49152")
155 raises(ValueError, "c.c = 65535")
156 raises(ValueError, "c.c = 65536")
158 raises(ValueError, "c.c = '0:1024'")
161 raises(ValueError, "c.d = 1")
162 raises(ValueError, "c.d = 1023")
163 raises(ValueError, "c.d = 1024")
164 raises(ValueError, "c.d = 49151")
165 raises(ValueError, "c.d = 49152")
166 raises(ValueError, "c.d = 65535")
167 raises(ValueError, "c.d = 65536")
168 raises(ValueError, "c.d = '0:0'")
169 raises(ValueError, "c.d = '0:1'")
179 raises(ValueError, "c.e = '0:65536'")
181 raises(ValueError, "c.f = 0")
188 raises(ValueError, "c.f = 65536")
191 raises(ValueError, "c.f = '0:65535'")
192 raises(ValueError, "c.f = '4:3'")