Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --unix-socket option #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pyresttest/resttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'])

Expand All @@ -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',
Expand Down