2 from py.test import raises
4 from tiramisu.config import Config
5 from tiramisu.option import DomainnameOption, EmailOption, URLOption, OptionDescription
9 d = DomainnameOption('d', '')
10 f = DomainnameOption('f', '', allow_without_dot=True)
11 g = DomainnameOption('g', '', allow_ip=True)
12 od = OptionDescription('a', '', [d, f, g])
16 raises(ValueError, "c.d = 'toto'")
18 raises(ValueError, "c.d = 'toto3.3la'")
19 #raises(ValueError, "c.d = '3toto.com'")
20 raises(ValueError, "c.d = 'toto.co3'")
21 raises(ValueError, "c.d = 'toto_super.com'")
23 raises(ValueError, "c.d = 'toto..com'")
27 raises(ValueError, "c.f = 'domainnametoolongthathavemorethanmaximumsizeforatruedomainnameanditsnoteasytogeneratesolongdomainnamewithoutrepeatdomainnametoolongthathavemorethanmaximumsizeforatruedomainnameanditsnoteasytogeneratesolongdomainnamewithoutrepeatbutimnotabletodoitnowiendityeah'")
28 raises(ValueError, "c.f = 'd'")
34 def test_special_domain_name():
35 """domain name option that starts with a number or not
37 d = DomainnameOption('d', '')
38 e = DomainnameOption('e', '', type_='netbios')
39 od = OptionDescription('a', '', [d,e])
45 raises(ValueError, "c.e = '1toto'")
48 def test_domainname_netbios():
49 d = DomainnameOption('d', '', type_='netbios')
50 e = DomainnameOption('e', '', "toto", type_='netbios')
51 od = OptionDescription('a', '', [d, e])
54 raises(ValueError, "c.d = 'toto.com'")
56 raises(ValueError, "c.d = 'domainnametoolong'")
59 def test_domainname_hostname():
60 d = DomainnameOption('d', '', type_='hostname')
61 e = DomainnameOption('e', '', "toto", type_='hostname')
62 od = OptionDescription('a', '', [d, e])
65 raises(ValueError, "c.d = 'toto.com'")
67 c.d = 'domainnametoolong'
71 e = EmailOption('e', '')
72 od = OptionDescription('a', '', [e])
76 raises(ValueError, "c.e = 'root'")
77 raises(ValueError, "c.e = 'root@domain'")
78 raises(ValueError, "c.e = 'root[]@domain'")
82 u = URLOption('u', '')
83 od = OptionDescription('a', '', [u])
86 c.u = 'http://foo.com'
87 c.u = 'https://foo.com'
88 c.u = 'https://foo.com/'
89 raises(ValueError, "c.u = 'ftp://foo.com'")
90 raises(ValueError, "c.u = 'foo.com'")
91 raises(ValueError, "c.u = ':/foo.com'")
92 raises(ValueError, "c.u = 'foo.com/http://'")
93 c.u = 'https://foo.com/index.html'
94 c.u = 'https://foo.com/index.html?var=value&var2=val2'
95 raises(ValueError, "c.u = 'https://foo.com/index\\n.html'")
96 c.u = 'https://foo.com:8443'
97 c.u = 'https://foo.com:8443/'
98 c.u = 'https://foo.com:8443/index.html'
99 raises(ValueError, "c.u = 'https://foo.com:84438989'")