Add test of the authkey, update warnings.

pull/98/head
Raphaël Vinot 2017-07-20 15:33:15 +02:00
parent 49de3a8951
commit 5f94ad3104
1 changed files with 10 additions and 1 deletions

View File

@ -110,7 +110,9 @@ class PyMISP(object):
try:
# Make sure the MISP instance is working and the URL is valid
response = self.get_recommended_api_version()
if not response.get('version'):
if response.get('errors'):
logger.warning(response.get('errors')[0])
elif not response.get('version'):
logger.warning("Unable to check the recommended PyMISP version (MISP <2.4.60), please upgrade.")
else:
pymisp_version_tup = tuple(int(x) for x in __version__.split('.'))
@ -277,6 +279,13 @@ class PyMISP(object):
# ############### Simple REST API ################
# ################################################
def test_connexion(self):
"""Test the auth key"""
response = self.get_version()
if response.get('errors'):
raise PyMISPError(response.get('errors')[0])
return True
def get_index(self, filters=None):
"""Return the index.