Skip to content

Commit

Permalink
Updated api to include an ssl verify toggle closes #492
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Nov 4, 2015
1 parent dbed1c8 commit 50b3fab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions features/steps/rest-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ def require_valid_model(model, name=None, mtype=None, creator=None):

@given(u'a running Slycat server.')
def step_impl(context):
context.server_admin = slycat.web.client.Connection(host=context.server_host, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.server_admin_user, context.server_admin_password))
context.project_admin = slycat.web.client.Connection(host=context.server_host, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_admin_user, context.project_admin_password))
context.project_writer = slycat.web.client.Connection(host=context.server_host, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_writer_user, context.project_writer_password))
context.project_reader = slycat.web.client.Connection(host=context.server_host, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_reader_user, context.project_reader_password))
context.project_outsider = slycat.web.client.Connection(host=context.server_host, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_outsider_user, context.project_outsider_password))
context.unauthenticated_user = slycat.web.client.Connection(host=context.server_host, proxies={"http":context.server_proxy, "https":context.server_proxy})
context.server_admin = slycat.web.client.Connection(host=context.server_host, ssl_verify=False, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.server_admin_user, context.server_admin_password))
context.project_admin = slycat.web.client.Connection(host=context.server_host, ssl_verify=False, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_admin_user, context.project_admin_password))
context.project_writer = slycat.web.client.Connection(host=context.server_host, ssl_verify=False, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_writer_user, context.project_writer_password))
context.project_reader = slycat.web.client.Connection(host=context.server_host, ssl_verify=False, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_reader_user, context.project_reader_password))
context.project_outsider = slycat.web.client.Connection(host=context.server_host, ssl_verify=False, proxies={"http":context.server_proxy, "https":context.server_proxy}, auth=(context.project_outsider_user, context.project_outsider_password))
context.unauthenticated_user = slycat.web.client.Connection(host=context.server_host, ssl_verify=False, proxies={"http":context.server_proxy, "https":context.server_proxy})
context.server_admin.get_configuration_version()

@given(u'a default project.')
Expand Down
5 changes: 3 additions & 2 deletions packages/slycat/web/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ class Connection(object):
"""Encapsulates a set of requests to the given host. Additional keyword
arguments must be compatible with the Python Requests library,
http://docs.python-requests.org/en/latest"""
def __init__(self, host="http://localhost:8092", **keywords):
def __init__(self, host="http://localhost:8092", ssl_verify=True, **keywords):
self.host = host
self.keywords = keywords
self.session = requests.Session()
self.ssl_verify = ssl_verify

def request(self, method, path, **keywords):
"""Makes a request with the given HTTP method and path, returning the body of
Expand All @@ -113,7 +114,7 @@ def request(self, method, path, **keywords):
log_message = "{} {} {}".format(keywords.get("auth", ("", ""))[0], method, uri)

try:
response = self.session.request(method, uri, **keywords)
response = self.session.request(method, uri, verify=self.ssl_verify, **keywords)

log_message += " => {} {}".format(response.status_code, response.raw.reason)

Expand Down

0 comments on commit 50b3fab

Please sign in to comment.