api: Check against the self-signed cert

(imported from commit f0444f1af206e5d7ee1c79f7486e9fe17daea0f7)
This commit is contained in:
Keegan McAllister 2012-10-15 12:55:10 -04:00
parent 3f6c6a5d1b
commit 9f05b9ac23

View file

@ -3,13 +3,13 @@ import simplejson
import requests import requests
import time import time
import traceback import traceback
from os import path
# TODO: Drop verify=False once we have real certificates
# Or switch to specifying a testing cert manually
# Check that we have a recent enough version # Check that we have a recent enough version
assert(requests.__version__ > '0.12') assert(requests.__version__ > '0.12')
cert = path.abspath(path.join(path.dirname(__file__), '../certs/humbug-self-signed.crt'))
class HumbugAPI(): class HumbugAPI():
def __init__(self, email, api_key, verbose=False, site="https://app.humbughq.com"): def __init__(self, email, api_key, verbose=False, site="https://app.humbughq.com"):
self.api_key = api_key self.api_key = api_key
@ -24,7 +24,7 @@ class HumbugAPI():
try: try:
res = requests.post(self.base_url + url, res = requests.post(self.base_url + url,
data=request, data=request,
verify=False, verify=cert,
auth=requests.auth.HTTPDigestAuth('tabbott', auth=requests.auth.HTTPDigestAuth('tabbott',
'xxxxxxxxxxxxxxxxx')) 'xxxxxxxxxxxxxxxxx'))
if res.status_code == requests.codes.service_unavailable: if res.status_code == requests.codes.service_unavailable: