fix: Do now fail on requests returning plain text

Fix #639
pull/646/head
Raphaël Vinot 2020-10-21 15:16:15 +02:00
parent f248a8bfff
commit d428858f1e
2 changed files with 6 additions and 1 deletions

View File

@ -2973,7 +2973,7 @@ class PyMISP:
logger.debug(response.text) logger.debug(response.text)
if expect_json: if expect_json:
raise PyMISPUnexpectedResponse(f'Unexpected response from server: {response.text}') raise PyMISPUnexpectedResponse(f'Unexpected response from server: {response.text}')
if lenient_response_type and not response.headers['Accept'].startswith('application/json'): if lenient_response_type and not response.headers['Content-Type'].startswith('application/json'):
return response.text return response.text
if not response.content: if not response.content:
# Empty response # Empty response

View File

@ -1818,6 +1818,11 @@ class TestComprehensive(unittest.TestCase):
event_get = MISPEvent() event_get = MISPEvent()
event_get.from_dict(**r) event_get.from_dict(**r)
self.assertDictEqual(event.to_dict(), event_get.to_dict()) self.assertDictEqual(event.to_dict(), event_get.to_dict())
r = self.user_misp_connector.direct_call('events/restSearch', data={"returnFormat": "csv",
"type": {"AND": ["campaign-name", "threat-actor"]},
"category": "Attribution", "includeEventUuid": 1})
self.assertTrue(r.startswith('uuid,event_id,category,type,value'))
finally: finally:
self.admin_misp_connector.delete_event(event) self.admin_misp_connector.delete_event(event)