mirror of https://github.com/MISP/PyMISP
chg: Add live tests for recommended pymisp version and describeTypes up-to-date
parent
7ea7ca07d1
commit
f4439ae970
|
@ -122,9 +122,7 @@ class PyMISP(object):
|
|||
try:
|
||||
self.describe_types = self.get_live_describe_types()
|
||||
except Exception:
|
||||
with open(os.path.join(self.resources_path, 'describeTypes.json'), 'r') as f:
|
||||
describe_types = json.load(f)
|
||||
self.describe_types = describe_types['result']
|
||||
self.describe_types = self.get_local_describe_types()
|
||||
|
||||
self.categories = self.describe_types['categories']
|
||||
self.types = self.describe_types['types']
|
||||
|
@ -136,6 +134,11 @@ class PyMISP(object):
|
|||
response = self.__prepare_request('GET', urljoin(self.root_url, 'events/queryACL.json'))
|
||||
return self._check_response(response)
|
||||
|
||||
def get_local_describe_types(self):
|
||||
with open(os.path.join(self.resources_path, 'describeTypes.json'), 'r') as f:
|
||||
describe_types = json.load(f)
|
||||
return describe_types['result']
|
||||
|
||||
def get_live_describe_types(self):
|
||||
response = self.__prepare_request('GET', urljoin(self.root_url, 'attributes/describeTypes.json'))
|
||||
describe_types = self._check_response(response)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from pymisp import PyMISP
|
||||
from pymisp import PyMISP, __version__
|
||||
from keys import url, key
|
||||
import time
|
||||
|
||||
|
@ -282,10 +282,19 @@ class TestBasic(unittest.TestCase):
|
|||
self.assertTrue(sd['to_ids'] in [0, 1])
|
||||
self.assertTrue(sd['default_category'] in categories)
|
||||
|
||||
def test_describeTypes_uptodate(self):
|
||||
self.assertEqual(self.live_describe_types, self.misp.get_local_describe_types())
|
||||
|
||||
def test_live_acl(self):
|
||||
query_acl = self.misp.get_live_query_acl()
|
||||
self.assertEqual(query_acl['response'], [])
|
||||
|
||||
def test_recommended_pymisp_version(self):
|
||||
response = self.misp.get_recommended_api_version()
|
||||
recommended_version_tup = tuple(int(x) for x in response['version'].split('.'))
|
||||
pymisp_version_tup = tuple(int(x) for x in __version__.split('.'))[:3]
|
||||
self.assertEqual(recommended_version_tup, pymisp_version_tup)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue