summaryrefslogtreecommitdiff
path: root/scripts/tests/Ice/networkProxy.py
blob: 948b24b2e7c5891d1fc6ab1de0fd95bc1259f078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# **********************************************************************
#
# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

import NetworkProxy

class NetworkProxyTestCase(ClientServerTestCase):

    def __init__(self, proxyName, proxyType, proxyPortNum):
        ClientServerTestCase.__init__(self, proxyName + " client/server", client = Client(props = lambda p, c: {
            "Ice.{0}ProxyHost".format(proxyName): "localhost",
            "Ice.{0}ProxyPort".format(proxyName): "{0}".format(c.driver.getTestPort(proxyPortNum))
        }))
        self.proxyName = proxyName
        self.proxyType = proxyType
        self.proxyPortNum = proxyPortNum
        self.proxy = None

    def setupClientSide(self, current):
        current.write("starting {0} proxy... ".format(self.proxyName))
        self.proxy = self.proxyType(current.driver.getTestPort(self.proxyPortNum))
        current.writeln("ok")

    def teardownClientSide(self, current, success):
        current.write("terminating {0} proxy... ".format(self.proxyName))
        self.proxy.terminate()
        self.proxy = None
        current.writeln("ok")

TestSuite(__name__, [
    NetworkProxyTestCase("SOCKS", NetworkProxy.SocksProxy, 30),
    NetworkProxyTestCase("HTTP", NetworkProxy.HttpProxy, 31),
], options = { "ipv6" : [False] })