pactest.py

Test cases - Davide Principi, 12/01/2015 09:44 AM

Download (1.75 KB)

 
1
#!/usr/bin/python2.5
2

    
3
import pacparser
4

    
5

    
6
tests = [
7
    ("green1.1", "192.168.122.12", "http://192.168.122.100"),
8
    ("green1.2", "192.168.122.11", "http://www.centos.org"), 
9
    ("green1.3 (bypass)", "192.168.122.1", "http://www.centos.org"), 
10
    ("green2.1", "192.168.123.13", "http://www.nethserver.org"), 
11
    ("blue1", "192.168.150.7",  "http://www.centos.org"),
12

    
13
    ('dst bypass group from green', '192.168.122.12', 'http://mirror2.nethserver.org'),
14
    ('dst bypass group from blue', '192.168.150.8', 'http://mirror2.nethserver.org'),
15
    ('dst bypass cidr from green', '192.168.122.12', 'http://10.0.0.1'),
16
    ('dst bypass cidr from blue', '192.168.150.8', 'http://10.0.0.1'),
17
    ('dst bypass host from green', '192.168.122.12', 'http://packages.nethserver.org'),
18
    ('dst bypass host from blue', '192.168.150.8', 'http://packages.nethserver.org'),
19

    
20
    ('src bypass iprange from green', '192.168.122.91',  'http://www.nethserver.org'),
21
    ('src bypass iprange from blue', '192.168.150.91',  'http://www.nethserver.org'),
22
    ('src bypass host from green', '192.168.122.10',  'http://www.nethserver.org'),
23
    ('src bypass host from blue', '192.168.150.20',  'http://www.nethserver.org'),
24
    ('src bypass host-group from green', '192.168.122.3',  'http://www.nethserver.org'),
25
    ('src bypass host-group from blue', '192.168.150.33',  'http://www.nethserver.org'),
26
    ('src bypass cidr from green', '192.168.122.249',  'http://www.nethserver.org'),
27
    ('src bypass cidr from blue', '192.168.150.249',  'http://www.nethserver.org')
28
]
29

    
30
for t in tests:
31
    pacparser.init()
32
    pacparser.parse_pac("wpad.dat")
33
    pacparser.setmyip(t[1])
34
    proxy = pacparser.find_proxy(t[2])
35
    print "| %-34s | %-18s | %-34s | %s |" % (t[0], t[1], t[2], proxy)
36
    pacparser.cleanup()
37

    
38