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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
From 95364551209815ca2c2380ce270474989b924dda Mon Sep 17 00:00:00 2001
From: Igor Pashev <pashev.igor@gmail.com>
Date: Sat, 26 Jan 2019 11:48:48 +0200
Subject: [PATCH] Add --unix-socket option
---
pyresttest/resttest.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/pyresttest/resttest.py b/pyresttest/resttest.py
index 0344746..845c438 100644
--- a/pyresttest/resttest.py
+++ b/pyresttest/resttest.py
@@ -111,6 +111,7 @@ class TestConfig:
verbose = False
ssl_insecure = False
skip_term_colors = False # Turn off output term colors
+ unix_socket = None
# Binding and creation of generators
variable_binds = None
@@ -331,6 +332,8 @@ def run_test(mytest, test_config=TestConfig(), context=None, curl_handle=None, *
if test_config.ssl_insecure:
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
+ if test_config.unix_socket != None:
+ curl.setopt(pycurl.UNIX_SOCKET_PATH, test_config.unix_socket)
result.passed = None
@@ -798,6 +801,7 @@ def main(args):
Keys allowed for args:
url - REQUIRED - Base URL
test - REQUIRED - Test file (yaml)
+ unix_socket - OPTIONAL - connect to this UNIX socket
print_bodies - OPTIONAL - print response body
print_headers - OPTIONAL - print response headers
log - OPTIONAL - set logging level {debug,info,warning,error,critical} (default=warning)
@@ -854,6 +858,9 @@ def main(args):
if 'ssl_insecure' in args and args['ssl_insecure'] is not None:
t.config.ssl_insecure = safe_to_bool(args['ssl_insecure'])
+ if 'unix_socket' in args and args['unix_socket'] is not None:
+ t.config.unix_socket = args['unix_socket']
+
if 'skip_term_colors' in args and args['skip_term_colors'] is not None:
t.config.skip_term_colors = safe_to_bool(args['skip_term_colors'])
@@ -877,6 +884,8 @@ def parse_command_line_args(args_in):
action="store", type="string")
parser.add_option(
u"--url", help="Base URL to run tests against", action="store", type="string")
+ parser.add_option(u"--unix-socket", help="Connect to this UNIX socket",
+ action="store", type="string", dest="unix_socket")
parser.add_option(u"--test", help="Test file to use",
action="store", type="string")
parser.add_option(u'--import_extensions',
|