From 5f94ad31047f87716a17012812e9a7ec09bf4a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 20 Jul 2017 15:33:15 +0200 Subject: [PATCH] Add test of the authkey, update warnings. --- pymisp/api.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index 94f8a79..0a26efd 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -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.