Skip to content

Commit d8773d2

Browse files
committed
Add verify_ssl option
1 parent 79579d2 commit d8773d2

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

reportportal_client/service.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ReportPortalService(object):
8888
"""Service class with report portal event callbacks."""
8989

9090
def __init__(self, endpoint, project, token, api_base="api/v1",
91-
is_skipped_an_issue=True):
91+
is_skipped_an_issue=True, verify_ssl=True):
9292
"""Init the service class.
9393
9494
Args:
@@ -98,6 +98,7 @@ def __init__(self, endpoint, project, token, api_base="api/v1",
9898
api_base: defaults to api/v1, can be changed to other version.
9999
is_skipped_an_issue: option to mark skipped tests as not
100100
'To Investigate' items on Server side.
101+
verify_ssl: option to not verify ssl certificates
101102
"""
102103
super(ReportPortalService, self).__init__()
103104
self.endpoint = endpoint
@@ -113,6 +114,8 @@ def __init__(self, endpoint, project, token, api_base="api/v1",
113114
self.session.headers["Authorization"] = "bearer {0}".format(self.token)
114115
self.stack = [None]
115116
self.launch_id = None
117+
self.verify_ssl = verify_ssl
118+
116119

117120
def terminate(self):
118121
pass
@@ -127,7 +130,7 @@ def start_launch(self, name, start_time, description=None, tags=None,
127130
"mode": mode
128131
}
129132
url = uri_join(self.base_url, "launch")
130-
r = self.session.post(url=url, json=data)
133+
r = self.session.post(url=url, json=data, verify=self.verify_ssl)
131134
self.launch_id = _get_id(r)
132135
self.stack.append(None)
133136
logger.debug("start_launch - Stack: %s", self.stack)
@@ -139,7 +142,7 @@ def _finalize_launch(self, end_time, action, status):
139142
"status": status
140143
}
141144
url = uri_join(self.base_url, "launch", self.launch_id, action)
142-
r = self.session.put(url=url, json=data)
145+
r = self.session.put(url=url, json=data, verify=self.verify_ssl)
143146
self.stack.pop()
144147
logger.debug("%s_launch - Stack: %s", action, self.stack)
145148
return _get_msg(r)
@@ -184,7 +187,7 @@ def start_test_item(self, name, start_time, item_type, description=None,
184187
url = uri_join(self.base_url, "item", parent_item_id)
185188
else:
186189
url = uri_join(self.base_url, "item")
187-
r = self.session.post(url=url, json=data)
190+
r = self.session.post(url=url, json=data, verify=self.verify_ssl)
188191

189192
item_id = _get_id(r)
190193
self.stack.append(item_id)
@@ -204,7 +207,7 @@ def finish_test_item(self, end_time, status, issue=None):
204207
}
205208
item_id = self.stack.pop()
206209
url = uri_join(self.base_url, "item", item_id)
207-
r = self.session.put(url=url, json=data)
210+
r = self.session.put(url=url, json=data, verify=self.verify_ssl)
208211
logger.debug("finish_test_item - Stack: %s", self.stack)
209212
return _get_msg(r)
210213

@@ -220,7 +223,7 @@ def log(self, time, message, level=None, attachment=None):
220223
return self.log_batch([data])
221224
else:
222225
url = uri_join(self.base_url, "log")
223-
r = self.session.post(url=url, json=data)
226+
r = self.session.post(url=url, json=data, verify=self.verify_ssl)
224227
logger.debug("log - Stack: %s", self.stack)
225228
return _get_id(r)
226229

@@ -268,7 +271,7 @@ def log_batch(self, log_data):
268271
)
269272
)]
270273
files.extend(attachments)
271-
r = self.session.post(url=url, files=files)
274+
r = self.session.post(url=url, files=files, verify=self.verify_ssl)
272275
logger.debug("log_batch - Stack: %s", self.stack)
273276
logger.debug("log_batch response: %s", r.text)
274277

reportportal_client/service_async.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ class ReportPortalServiceAsync(object):
118118

119119
def __init__(self, endpoint, project, token, api_base="api/v1",
120120
error_handler=None, log_batch_size=20,
121-
is_skipped_an_issue=True):
121+
is_skipped_an_issue=True,
122+
verify_ssl=True):
122123
"""Init the service class.
123124
124125
Args:
@@ -130,12 +131,13 @@ def __init__(self, endpoint, project, token, api_base="api/v1",
130131
during items processing (in thread)
131132
is_skipped_an_issue: option to mark skipped tests as not
132133
'To Investigate' items on Server side.
134+
verify_ssl: option to not verify ssl certificates
133135
"""
134136
super(ReportPortalServiceAsync, self).__init__()
135137
self.error_handler = error_handler
136138
self.log_batch_size = log_batch_size
137139
self.rp_client = ReportPortalService(
138-
endpoint, project, token, api_base, is_skipped_an_issue)
140+
endpoint, project, token, api_base, is_skipped_an_issue, verify_ssl)
139141
self.log_batch = []
140142
self.supported_methods = ["start_launch", "finish_launch",
141143
"start_test_item", "finish_test_item", "log"]

0 commit comments

Comments
 (0)