Skip to content

Commit b4323df

Browse files
authored
Merge pull request #63 from lorien/travis_3proxy
Running tests on travis CI
2 parents 84b36fe + 4304895 commit b4323df

17 files changed

+599
-367
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ var/
2424
.installed.cfg
2525
*.egg
2626
setup.cfg
27+
MANIFEST
28+
/.tox/
29+
/3proxy.conf

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: python
2+
3+
python: 2.7
4+
5+
os:
6+
- linux
7+
8+
env:
9+
- TOX_ENV=py27
10+
- TOX_ENV=py33
11+
- TOX_ENV=py34
12+
13+
# For python3.5 and python3.6 the base python versions
14+
# should be 3.5 and 3.6 accordingly to avoid InterpreterNotFound error
15+
matrix:
16+
include:
17+
- python: 3.5
18+
env: TOX_ENV=py35
19+
- python: 3.6
20+
env: TOX_ENV=py36
21+
22+
install:
23+
- pip install tox
24+
25+
script:
26+
- tox -e $TOX_ENV

requirements_dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
six
2+
test_server
3+
psutil

runtest.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python
2+
"""
3+
These tests use 3proxy software as http/socks4/socks5 proxy service.
4+
The 3proxy binary is located in test/bin/3proxy
5+
"""
6+
import unittest
7+
import sys
8+
import psutil
9+
import os
10+
import signal
11+
import logging
12+
from subprocess import Popen
13+
from threading import Thread
14+
import threading
15+
from test_server import TestServer
16+
import time
17+
import socket
18+
19+
from test.test_pysocks import PySocksTestCase
20+
from test import config
21+
from test.util import wait_for_socket
22+
23+
24+
def proxy_thread():
25+
with open('3proxy.conf', 'w') as out:
26+
out.write('\n'.join((
27+
'allow *',
28+
'auth none',
29+
'proxy -a -n -p%d -e%s' % (config.HTTP_PROXY_PORT,
30+
config.PROXY_HOST_IP),
31+
'socks -p%d -e%s' % (config.SOCKS4_PROXY_PORT,
32+
config.PROXY_HOST_IP),
33+
'socks -p%d -e%s' % (config.SOCKS5_PROXY_PORT,
34+
config.PROXY_HOST_IP),
35+
)))
36+
cmd = 'test/bin/3proxy 3proxy.conf'
37+
server = Popen(cmd, shell=True)
38+
server.wait()
39+
40+
41+
def start_servers():
42+
th = Thread(target=proxy_thread)
43+
th.daemon = True
44+
th.start()
45+
wait_for_socket('3proxy:http', config.PROXY_HOST_IP,
46+
config.HTTP_PROXY_PORT)
47+
wait_for_socket('3proxy:socks4', config.PROXY_HOST_IP,
48+
config.SOCKS4_PROXY_PORT)
49+
wait_for_socket('3proxy:socks5', config.PROXY_HOST_IP,
50+
config.SOCKS5_PROXY_PORT)
51+
52+
53+
def main():
54+
result = None
55+
try:
56+
start_servers()
57+
loader = unittest.TestLoader()
58+
suite = loader.loadTestsFromTestCase(PySocksTestCase)
59+
runner = unittest.TextTestRunner()
60+
result = runner.run(suite)
61+
except Exception as ex:
62+
logging.error('', exc_info=ex)
63+
finally:
64+
print('Active threads:')
65+
for th in threading.enumerate():
66+
print(' * %s' % th)
67+
68+
parent = psutil.Process(os.getpid())
69+
print('Active child processes:')
70+
for child in parent.children(recursive=True):
71+
print(' * %s' % child)
72+
child.send_signal(signal.SIGINT)
73+
74+
if result and result.wasSuccessful():
75+
sys.exit(0)
76+
else:
77+
sys.exit(1)
78+
79+
80+
if __name__ == '__main__':
81+
main()

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
keywords = ["socks", "proxy"],
1515
py_modules=["socks", "sockshandler"]
1616
)
17-

test/README

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/__init__.py

Whitespace-only changes.

test/bin/3proxy

665 KB
Binary file not shown.

test/bin/3proxy.license

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
3proxy 0.7 Public License Agreement
2+
3+
(c) 2000-2014 by 3APA3A ([email protected])
4+
(c) 2000-2014 by SecurityVulns.com (http://3proxy.ru/)
5+
(c) 2000-2014 by Vladimir Dubrovin ([email protected])
6+
7+
This software uses:
8+
RSA Data Security, Inc. MD4 Message-Digest Algorithm
9+
RSA Data Security, Inc. MD5 Message-Digest Algorithm
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
13+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
14+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
19+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22+
23+
This software is FREEWARE.
24+
25+
Redistribution and use in source and binary forms, with or without
26+
modification, are permitted provided that following conditions
27+
are met (BSD style license):
28+
29+
* Redistributions of source code must retain the above copyright notice,
30+
this list of conditions and the following disclaimer.
31+
* Redistributions in binary form must reproduce the above copyright notice,
32+
this list of conditions and the following disclaimer in the documentation
33+
and/or other materials provided with the distribution.
34+
* Neither the name of the SecurityVulns.COM nor the names of its
35+
contributors may be used to endorse or promote products derived from this
36+
software without specific prior written permission.
37+
38+
39+
Instead of this license, you can also use and redistribute this software under
40+
terms of compatible license, including:
41+
42+
1. Apache License, Version 2.0
43+
You may obtain a copy of the License at
44+
45+
http://www.apache.org/licenses/LICENSE-2.0
46+
47+
2. GNU General Public License as published by
48+
the Free Software Foundation; either version 2 of the License, or
49+
(at your option) any later version.
50+
You may obtain a copy of the License at
51+
52+
http://www.gnu.org/licenses/gpl.txt
53+
54+
3. GNU Lesser General Public License as published by the
55+
Free Software Foundation; either version 2.1 of the License, or
56+
(at your option) any later version.
57+
You may obtain a copy of the License at
58+
59+
http://www.gnu.org/licenses/lgpl.txt

test/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TEST_SERVER_HOST = 'localhost'
2+
TEST_SERVER_HOST_IP = '127.0.0.1'
3+
TEST_SERVER_PORT = 7777
4+
TEST_SERVER_EXTRA_PORT = 7776
5+
PROXY_HOST_IP = '127.0.0.2'
6+
HTTP_PROXY_PORT = 7775
7+
SOCKS4_PROXY_PORT = 7774
8+
SOCKS5_PROXY_PORT = 7773

test/httpproxy.py

Lines changed: 0 additions & 137 deletions
This file was deleted.

test/socks4server.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)