Source code for api.sampledb.v1.test_helpers.sample.get_evil_samples


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil, respond with HTTP 200""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil", status_code=200, json=fake_response({'offset': {'type': 'int', 'name': 'offset'}, 'limit': {'type': 'int', 'name': 'limit'}, 'responseCode': {'type': 'int', 'name': 'responseCode'}, 'count': {'type': 'int', 'name': 'count'}, 'data': {'type': 'list', 'items': {'mimeType': {'type': 'str', 'position': 0, 'description': 'Mimetype of the sample '}, 'entropy': {'type': 'int', 'position': 0, 'description': 'Entropy of the sample '}, 'createdTimestamp': {'type': 'int', 'position': 0, 'description': 'Timestamp of creation of the sample '}, 'ssDeep': {'type': 'str', 'position': 0, 'description': 'ssDeep of the sample '}, 'size': {'type': 'int', 'position': 0, 'description': 'Size of the sample '}, 'sha256': {'type': 'str'}, 'tlp': {'type': 'str', 'position': 0, 'description': 'TLP color of the sample ', 'readOnly': True, 'enum': ['WHITE', 'GREEN', 'AMBER', 'RED']}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['EVIL', 'SAFE']}}}, 'name': 'data'}, 'metaData': {'type': 'dict', 'additionalProperties': {'type': 'dict'}, 'name': 'metaData'}, 'messages': {'type': 'list', 'items': {'message': {'type': 'str'}, 'messageTemplate': {'type': 'str'}, 'type': 'str', 'field': {'type': 'str'}, 'parameter': {'type': 'dict'}, 'timestamp': {'type': 'int'}, 'options': ['FIELD_ERROR', 'ACTION_ERROR', 'WARNING', 'NOTIFICATION', 'INFO']}, 'name': 'messages'}, 'currentPage': {'type': 'int', 'name': 'currentPage'}, 'size': {'type': 'int', 'name': 'size'}}) ) return function(*args, **kwargs) return mock_response return decorator
[docs]def unauthorized(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil, respond with HTTP 401""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil", status_code=401, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def forbidden(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil, respond with HTTP 403""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil", status_code=403, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def not_found(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil, respond with HTTP 404""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/sampledb/v1/sample/search/evil", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator