Source code for api.alarms.v1.test_helpers.signature.delete_signatures


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/signature, 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( "DELETE", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/signature", 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': {'alarm': {'id': {'type': 'int'}, 'attackCategory': {'position': 0, 'description': 'Category of the alarm. ', '$ref': '#/definitions/AttackCategory'}, 'mappings': {'type': 'list', 'position': 0, 'description': 'Signatures mapped to the alarm. ', 'uniqueItems': True, 'items': {'alarm': {'position': 0, 'description': 'Alarm the signature is mapped to (null if not mapped). ', '$ref': '#/definitions/Alarm'}, 'lastUpdatedByUser': {'position': 0, 'description': 'Who updated the mapping last. ', '$ref': '#/definitions/UserInfo'}, 'lastUpdatedTimestamp': {'type': 'int', 'position': 0, 'description': 'When the mapping was last updated. '}, 'comments': {'type': 'list', 'position': 0, 'description': 'Comments added to the mapping. ', 'items': {'timestamp': {'type': 'int', 'position': 0, 'description': 'When the comment was added. '}, 'user': {'position': 0, 'description': 'Who added the comment. ', '$ref': '#/definitions/UserInfo'}, 'comment': {'type': 'str', 'position': 0, 'description': "The comment's text. "}}}, 'mappedTimestamp': {'type': 'int', 'position': 0, 'description': 'When the signature was mapped. '}, 'mappedByUser': {'position': 0, 'description': 'Who mapped the signature. ', '$ref': '#/definitions/UserInfo'}, 'firstTriggeredTimestamp': {'type': 'int', 'position': 0, 'description': 'When the signature was first triggered. '}, 'lastTriggeredTimestamp': {'type': 'int', 'position': 0, 'description': 'When the signature was last triggered. '}, 'triggerAmount': {'type': 'int', 'position': 0, 'description': 'How often the signature was triggered. '}, 'signature': {'type': 'str', 'position': 0, 'description': 'Signature mapped to alarm. '}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['DELETED', 'DEFAULT_BLOCK', 'SNORT', 'ISS_SIGNATURE']}}}}, 'comments': {'type': 'list', 'position': 0, 'description': 'Comments added to the alarm. ', 'items': {'timestamp': {'type': 'int', 'position': 0, 'description': 'When the comment was added. '}, 'user': {'position': 0, 'description': 'Who added the comment. ', '$ref': '#/definitions/UserInfo'}, 'comment': {'type': 'str', 'position': 0, 'description': "The comment's text. "}}}, 'references': {'type': 'list', 'position': 0, 'description': 'Further references to the alarm. ', 'uniqueItems': True, 'items': {'type': 'str'}}, 'labels': {'type': 'list', 'position': 0, 'description': 'Label assigned to the alarm. ', 'uniqueItems': True, 'items': {'type': 'str'}}, 'info': {'type': 'str', 'position': 0, 'description': 'Verbose information about the alarm. '}, 'description': {'type': 'str', 'position': 0, 'description': 'Short description about the alarm. '}, 'links': {'type': 'list', 'position': 0, 'description': 'Links added to the alarm. ', 'uniqueItems': True, 'items': {'type': 'str'}}, 'createdByUser': {'position': 0, 'description': 'Who created the alarm. ', '$ref': '#/definitions/UserInfo'}, 'createdTimestamp': {'type': 'int', 'position': 0, 'description': 'When the alarm was created. '}, 'lastUpdatedByUser': {'position': 0, 'description': 'Who updated the alarm last. ', '$ref': '#/definitions/UserInfo'}, 'lastUpdatedTimestamp': {'type': 'int', 'position': 0, 'description': 'When the alarm was last updated. '}, 'lastCheckedByUser': {'position': 0, 'description': 'Who checked the alarm last. ', '$ref': '#/definitions/UserInfo'}, 'lastCheckTimestamp': {'type': 'int', 'position': 0, 'description': 'When the alarm was last checked. '}, 'nextCheckTimestamp': {'type': 'int', 'position': 0, 'description': 'When the alarm should be checked next. '}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['DISABLED', 'DELETED']}}}, 'lastUpdatedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'lastUpdatedTimestamp': {'type': 'int', 'position': 0, 'description': 'When the mapping was last updated. '}, 'comments': {'type': 'list', 'position': 0, 'description': 'Comments added to the mapping. ', 'items': {'timestamp': {'type': 'int', 'position': 0, 'description': 'When the comment was added. '}, 'user': {'position': 0, 'description': 'Who added the comment. ', '$ref': '#/definitions/UserInfo'}, 'comment': {'type': 'str', 'position': 0, 'description': "The comment's text. "}}}, 'mappedTimestamp': {'type': 'int', 'position': 0, 'description': 'When the signature was mapped. '}, 'mappedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'firstTriggeredTimestamp': {'type': 'int', 'position': 0, 'description': 'When the signature was first triggered. '}, 'lastTriggeredTimestamp': {'type': 'int', 'position': 0, 'description': 'When the signature was last triggered. '}, 'triggerAmount': {'type': 'int', 'position': 0, 'description': 'How often the signature was triggered. '}, 'signature': {'type': 'str', 'position': 0, 'description': 'Signature mapped to alarm. '}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['DELETED', 'DEFAULT_BLOCK', 'SNORT', 'ISS_SIGNATURE']}}}, '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/alarms/v1/signature, 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( "DELETE", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/signature", 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/alarms/v1/signature, 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( "DELETE", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/signature", 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/alarms/v1/signature, 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( "DELETE", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/signature", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator