api.events.v1.test_helpers.nids.list_n_i_d_s_events — Argus-Toolbelt 1.0 documentation

# Source code for api.events.v1.test_helpers.nids.list_n_i_d_s_events

    def success(function):
        """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids, 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(
                    "GET",
                    r"https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids",
                    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': {'customerInfo': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}, 'domain': {'$ref': '#/definitions/DomainInfo'}}, 'properties': {'type': 'dict', 'additionalProperties': {'type': 'str'}}, 'comments': {'type': 'list', '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. "}}}, 'sensor': {'id': {'type': 'int'}, 'hostname': {'type': 'str'}, 'application': {'$ref': '#/definitions/Application'}, 'customer': {'$ref': '#/definitions/CustomerInfo'}, 'ipaddress': {'readOnly': True, '$ref': '#/definitions/IPAddress'}}, 'location': {'id': {'type': 'int'}, 'shortName': {'type': 'str'}, 'name': {'type': 'str'}, 'timeZone': {'type': 'str'}}, 'attackInfo': {'alarmID': {'type': 'int'}, 'alarmDescription': {'type': 'str'}, 'attackCategoryID': {'type': 'int'}, 'attackCategoryName': {'type': 'str'}, 'signature': {'type': 'str'}}, 'count': {'type': 'int'}, 'engineTimestamp': {'type': 'int'}, 'protocolID': {'type': 'int'}, 'domain': {'fqdn': {'type': 'str'}}, 'uri': {'type': 'str'}, 'source': {'port': {'type': 'int'}, 'geoLocation': {'$ref': '#/definitions/GeoInfo'}, 'networkAddress': {'$ref': '#/definitions/IPNetworkAddress'}}, 'destination': {'port': {'type': 'int'}, 'geoLocation': {'$ref': '#/definitions/GeoInfo'}, 'networkAddress': {'$ref': '#/definitions/IPNetworkAddress'}}, 'timestamp': {'type': 'int'}, 'severity': {'type': 'str', 'readOnly': True, 'enum': ['low', 'medium', 'high', 'critical']}, 'flags': {'type': 'list', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['ESTABLISHED', 'BLOCKED', 'SNAPSHOT', 'FINALIZED', 'SOURCE_IS_CUSTOMERNET', 'DESTINATION_IS_CUSTOMERNET', 'SOURCE_IS_PARTIAL_CUSTOMERNET', 'DESTINATION_IS_PARTIAL_CUSTOMERNET', 'INTRUDER_IS_CUSTOMERNET', 'VICTIM_IS_CUSTOMERNET', 'INTRUDER_IS_PARTIAL_CUSTOMERNET', 'VICTIM_IS_PARTIAL_CUSTOMERNET', 'PARTIALLY_BLOCKED', 'FALSE_POSITIVE', 'NOT_A_THREAT', 'TUNING_CANDIDATE', 'NOTIFIED', 'PARTIALLY_NOTIFIED', 'FOLLOWUP', 'IDENTIFIED_THREAT', 'THREAT_CANDIDATE', 'ACKNOWLEDGED', 'PARTIALLY_ACKNOWLEDGED', 'SEVERITY_ADJUSTED', 'COMMENTED', 'FILTERED', 'CHECKED', 'INCOMPLETE_DETAILS', 'AGGREGATED_BASE_EVENT', 'REMOTE_STORAGE', 'CUSTOM_SOURCE_AGGREGATION', 'CUSTOM_DESTINATION_AGGREGATION', 'CUSTOM_INTRUDER_AGGREGATION', 'CUSTOM_VICTIM_AGGREGATION', 'HAS_PAYLOAD', 'HAS_PCAP', 'ASSOCIATED_TO_CASE_BY_FILTER', 'SEVERITY_INCREASED_BY_FILTER', 'SEVERITY_REDUCED_BY_FILTER', 'CREATED_BY_ANALYSIS_FILTER', 'EXTEND_EVENT_TTL', 'INITIAL_TUNING']}}, 'id': {'type': 'str', 'xml': {'attribute': True}, 'readOnly': True}}, '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

    def unauthorized(function):
        """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids, 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(
                    "GET",
                    r"https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids",
                    status_code=401,
                    json=None
                )
                return function(*args, **kwargs)
            return mock_response
        return decorator

    def forbidden(function):
        """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids, 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(
                    "GET",
                    r"https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids",
                    status_code=403,
                    json=None
                )
                return function(*args, **kwargs)
            return mock_response
        return decorator

    def not_found(function):
        """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids, 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(
                    "GET",
                    r"https://osl-argus-trunk-web1.mnemonic.no/web/api/events/v1/nids",
                    status_code=404,
                    json=None
                )
                return function(*args, **kwargs)
            return mock_response
        return decorator