Skip to content

Add ssl_verify option to Gitlab object. #5

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

Merged
merged 1 commit into from
Aug 26, 2013
Merged
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
19 changes: 10 additions & 9 deletions gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GitlabAuthenticationError(Exception):

class Gitlab(object):
"""Represents a GitLab server connection"""
def __init__(self, url, private_token=None, email=None, password=None):
def __init__(self, url, private_token=None, email=None, password=None, ssl_verify=True):
"""Stores informations about the server

url: the URL of the Gitlab server
Expand All @@ -86,6 +86,7 @@ def __init__(self, url, private_token=None, email=None, password=None):
self.private_token = private_token
self.email = email
self.password = password
self.ssl_verify = ssl_verify

def auth(self):
"""Performs an authentication using either the private token, or the
Expand Down Expand Up @@ -139,7 +140,7 @@ def rawGet(self, path, with_token=False):
url += "?private_token=%s" % self.private_token

try:
r = requests.get(url)
r = requests.get(url, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All @@ -149,7 +150,7 @@ def rawGet(self, path, with_token=False):
def rawPost(self, path, data):
url = '%s%s' % (self._url, path)
try:
r = requests.post(url, data)
r = requests.post(url, data, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All @@ -162,7 +163,7 @@ def rawPut(self, path, with_token=False):
url += "?private_token=%s" % self.private_token

try:
r = requests.put(url)
r = requests.put(url, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All @@ -187,7 +188,7 @@ def list(self, obj_class, **kwargs):
["%s=%s" % (k, v) for k, v in kwargs.items()]))

try:
r = requests.get(url)
r = requests.get(url, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand Down Expand Up @@ -233,7 +234,7 @@ def get(self, obj_class, id=None, **kwargs):
(self._url, url, self.private_token)

try:
r = requests.get(url)
r = requests.get(url, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All @@ -253,7 +254,7 @@ def delete(self, obj):
(self._url, url, obj.id, self.private_token)

try:
r = requests.delete(url)
r = requests.delete(url, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand Down Expand Up @@ -281,7 +282,7 @@ def create(self, obj):
try:
# TODO: avoid too much work on the server side by filtering the
# __dict__ keys
r = requests.post(url, obj.__dict__)
r = requests.post(url, obj.__dict__, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All @@ -305,7 +306,7 @@ def update(self, obj):
d[k] = str(v)

try:
r = requests.put(url, d)
r = requests.put(url, d, verify=self.ssl_verify)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand Down