Skip to content

Commit

Permalink
- added certificate flexibility within client configuration
Browse files Browse the repository at this point in the history
- version bump
  • Loading branch information
AtefBN authored and AtefBN committed Nov 3, 2020
1 parent e28443b commit 64389cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion esgissue/conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"CREDTEST": "/verify-authorization?login={}&token={}&institute={}&project={}",
"PID": "/1/resolve/pid"
},
"validate_issue_urls": true
"validate_issue_urls": true,
"verify_certificate": false
}
2 changes: 1 addition & 1 deletion esgissue/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NUMBER = '2.1'
VERSION_NUMBER = '2.3'

# REGEX STUFF

Expand Down
18 changes: 9 additions & 9 deletions esgissue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,30 +460,30 @@ def _get_ws_call(action, payload=None, uid=None, credentials=None, dry_run=False
_check_ws_heartbeat(dry_run)
if action in [CREATE, UPDATE]:
# First you need to retrieve the xsrf token from the options request
options_r = requests.options(url)
options_r = requests.options(url, verify=cf['verify_certificate'])
HEADERS['X-Xsrftoken'] = options_r.headers['X-Xsrftoken']
HEADERS['Cookie'] = options_r.headers['Set-Cookie']
try:
r = requests.post(url, json.dumps(payload), headers=HEADERS, auth=credentials)
r = requests.post(url, json.dumps(payload), headers=HEADERS, auth=credentials, verify=cf['verify_certificate'])
print(r.text)
except Exception as e:
print(e.message)
elif action == CLOSE:
options_r = requests.options(url)
options_r = requests.options(url, verify=cf['verify_certificate'])
HEADERS['X-Xsrftoken'] = options_r.headers['X-Xsrftoken']
HEADERS['Cookie'] = options_r.headers['Set-Cookie']
try:
r = requests.post(url + uid + '&status=' + payload, headers=HEADERS, auth=credentials)
r = requests.post(url + uid + '&status=' + payload, headers=HEADERS, auth=credentials, verify=cf['verify_certificate'])
except Exception as e:
print(e.message)
elif action == RETRIEVE:
r = requests.get(url + uid)
r = requests.get(url + uid , verify=cf['verify_certificate'])
elif action == RETRIEVE_ALL:
r = requests.get(url)
r = requests.get(url, verify=cf['verify_certificate'])
elif action == CREDTEST:
r = requests.get(url.format(credentials[0], credentials[1], payload['team'], payload['project']))
r = requests.get(url.format(credentials[0], credentials[1], payload['team'], payload['project']), verify=cf['verify_certificate'])
elif action == PID:
r = requests.get(url + '?pids=' + payload)
r = requests.get(url + '?pids=' + payload, verify=cf['verify_certificate'])
if r.status_code != requests.codes.ok:
error_json = json.loads(r.text)
if r.status_code == 400:
Expand Down Expand Up @@ -512,7 +512,7 @@ def _check_ws_heartbeat(dry_run = False):
else:
url = cf['url_base_dry_run']
try:
r = requests.get(url)
r = requests.get(url, verify=cf['verify_certificate'])
if r.status_code != 200:
logging.warning(ERROR_DIC['server_down'][0])
raise ServerDownException(code=404, msg='{} is unreachable'.format(url))
Expand Down

0 comments on commit 64389cc

Please sign in to comment.