mirror of https://github.com/MISP/PyMISP
new: [Community] Request access
parent
7402e1b3b6
commit
7bf6005576
|
@ -1740,10 +1740,24 @@ class ExpandedPyMISP(PyMISP):
|
|||
c.from_dict(**community)
|
||||
return c
|
||||
|
||||
def request_community_access(self, community: Union[MISPCommunity, int, str, UUID], sync: bool=False,
|
||||
requestor_org_description: str='', requestor_email_user: str='',
|
||||
message: str='', anonymise: bool=False):
|
||||
pass
|
||||
def request_community_access(self, community: Union[MISPCommunity, int, str, UUID],
|
||||
requestor_email_address: str=None,
|
||||
requestor_gpg_key: str=None,
|
||||
requestor_organisation_name: str=None,
|
||||
requestor_organisation_uuid: str=None,
|
||||
requestor_organisation_description: str=None,
|
||||
message: str=None, sync: bool=False,
|
||||
anonymise_requestor_server: bool=False,
|
||||
mock: bool=False):
|
||||
community_id = self.__get_uuid_or_id_from_abstract_misp(community)
|
||||
to_post = {'org_name': requestor_organisation_name,
|
||||
'org_uuid': requestor_organisation_uuid,
|
||||
'org_description': requestor_organisation_description,
|
||||
'email': requestor_email_address, 'gpgkey': requestor_gpg_key,
|
||||
'message': message, 'anonymise': anonymise_requestor_server, 'sync': sync,
|
||||
'mock': mock}
|
||||
r = self._prepare_request('POST', f'communities/requestAccess/{community_id}', data=to_post)
|
||||
return self._check_response(r, expect_json=True)
|
||||
|
||||
# ## END Communities ###
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ import urllib3
|
|||
import time
|
||||
from uuid import uuid4
|
||||
|
||||
import email
|
||||
|
||||
import logging
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
|
@ -1924,11 +1926,19 @@ class TestComprehensive(unittest.TestCase):
|
|||
# Delete event
|
||||
self.admin_misp_connector.delete_event(first)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 6), 'Not supported on python < 3.6')
|
||||
def test_communities(self):
|
||||
communities = self.admin_misp_connector.communities(pythonify=True)
|
||||
self.assertEqual(communities[0].name, 'CIRCL Private Sector Information Sharing Community - aka MISPPRIV')
|
||||
community = self.admin_misp_connector.get_community(communities[1], pythonify=True)
|
||||
self.assertEqual(community.name, 'CIRCL n/g CSIRT information sharing community - aka MISP')
|
||||
r = self.admin_misp_connector.request_community_access(community, mock=False)
|
||||
self.assertTrue(r['message'], 'Request sent.')
|
||||
r = self.admin_misp_connector.request_community_access(community, mock=True)
|
||||
mail = email.message_from_string(r['headers'] + '\n' + r['message'])
|
||||
for k, v in mail.items():
|
||||
if k == 'To':
|
||||
self.assertEqual(v, 'info@circl.lu')
|
||||
|
||||
def test_upload_stix(self):
|
||||
# FIXME https://github.com/MISP/MISP/issues/4892
|
||||
|
|
Loading…
Reference in New Issue