From 9a21d1fa0e3e4cdfff4ff287beb2a2ac74d10bce Mon Sep 17 00:00:00 2001 From: Zara Date: Tue, 6 Sep 2016 12:45:27 +0000 Subject: [PATCH] Give user option to bypass verification This allows a user to use the python client with a storyboard instance that has a self-signed certificate, such as https://storyboard-dev.openstack.org Change-Id: Id1b1fb7b1b3921b70b2fa6946f13d188dd88f64e --- storyboardclient/base.py | 5 +++-- storyboardclient/v1/client.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/storyboardclient/base.py b/storyboardclient/base.py index 767a9f5..60dfcb7 100644 --- a/storyboardclient/base.py +++ b/storyboardclient/base.py @@ -26,12 +26,13 @@ DEFAULT_API_URL = "https://storyboard.openstack.org/api/v1" class BaseClient(client.BaseClient): - def __init__(self, api_url=None, access_token=None): + def __init__(self, api_url=None, access_token=None, verify=True): if not api_url: api_url = DEFAULT_API_URL self.auth_plugin = oauth.OAuthPlugin(api_url, access_token) - self.http_client = BaseHTTPClient(auth_plugin=self.auth_plugin) + self.http_client = BaseHTTPClient(auth_plugin=self.auth_plugin, + verify=verify) class BaseHTTPClient(client.HTTPClient): diff --git a/storyboardclient/v1/client.py b/storyboardclient/v1/client.py index 7ea451d..560bd5b 100644 --- a/storyboardclient/v1/client.py +++ b/storyboardclient/v1/client.py @@ -42,7 +42,7 @@ class Client(base.BaseClient): "mytoken") """ - def __init__(self, api_url=None, access_token=None): + def __init__(self, api_url=None, access_token=None, verify=True): """Sets up a client with endpoint managers. :param api_url: (Optional) Full API url. Defaults to @@ -50,11 +50,12 @@ class Client(base.BaseClient): :param access_token: (Optional) OAuth2 access token. If skipped only public read-only endpoint will be available. All other requests will fail with Unauthorized error. + :param verify: (Optional) Check certificate. Defaults to `True`; set + to `False` if accessing a trusted instance with a self-signed cert. :return: a client instance. """ super(Client, self).__init__(api_url=api_url, - access_token=access_token) - + access_token=access_token, verify=verify) self.branches = branches.BranchesManager(self) self.tasks = tasks.TasksManager(self) self.teams = teams.TeamsManager(self)