From af12b2a87bece1c3e70c90b837499976f76fade9 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Fri, 21 Mar 2025 08:41:16 +0100 Subject: [PATCH 1/6] Add: New openvasd scanner type and relay fields The latest GMP protocol version now supports the openvasd scanner type and the new scanner fields relay_host and relay_port. --- gvm/protocols/gmp/_gmp226.py | 155 +++++++++ gvm/protocols/gmp/requests/v226/__init__.py | 3 +- gvm/protocols/gmp/requests/v226/_scanners.py | 326 ++++++++++++++++++ .../gmpv226/entities/test_scanners.py | 96 +++++- .../gmpv226/enums/test_scanner_type.py | 7 + 5 files changed, 582 insertions(+), 5 deletions(-) create mode 100644 gvm/protocols/gmp/requests/v226/_scanners.py diff --git a/gvm/protocols/gmp/_gmp226.py b/gvm/protocols/gmp/_gmp226.py index cad24f90..2fcec60b 100644 --- a/gvm/protocols/gmp/_gmp226.py +++ b/gvm/protocols/gmp/_gmp226.py @@ -21,6 +21,8 @@ Reports, ResourceNames, ResourceType, + Scanners, + ScannerType, ) @@ -446,3 +448,156 @@ def modify_report_config( report_config_id, name=name, comment=comment, params=params ) ) + + def create_scanner( + self, + name: str, + host: str, + port: Union[str, int], + scanner_type: ScannerType, + credential_id: str, + *, + ca_pub: Optional[str] = None, + comment: Optional[str] = None, + relay_host: Optional[str] = None, + relay_port: Optional[Union[str, int]] = None, + ) -> T: + """Create a new scanner + + Args: + name: Name of the new scanner + host: Hostname or IP address of the scanner + port: Port of the scanner + scanner_type: Type of the scanner + credential_id: UUID of client certificate credential for the + scanner + ca_pub: Certificate of CA to verify scanner certificate + comment: Comment for the scanner + relay_host: Hostname or IP address of the scanner relay + relay_port: Port of the scanner relay + """ + return self._send_request_and_transform_response( + Scanners.create_scanner( + name, + host, + port, + scanner_type, + credential_id, + ca_pub=ca_pub, + comment=comment, + relay_host=relay_host, + relay_port=relay_port, + ) + ) + + def modify_scanner( + self, + scanner_id: EntityID, + *, + name: Optional[str] = None, + host: Optional[str] = None, + port: Optional[int] = None, + scanner_type: Optional[ScannerType] = None, + credential_id: Optional[EntityID] = None, + ca_pub: Optional[str] = None, + comment: Optional[str] = None, + relay_host: Optional[str] = None, + relay_port: Optional[Union[str, int]] = None, + ) -> T: + """Modify an existing scanner + + Args: + scanner_id: UUID of the scanner to modify + name: New name of the scanner + host: New hostname or IP address of the scanner + port: New port of the scanner + scanner_type: New type of the scanner + credential_id: New UUID of client certificate credential for the + scanner + ca_pub: New certificate of CA to verify scanner certificate + comment: New comment for the scanner + relay_host: Hostname or IP address of the scanner relay + relay_port: Port of the scanner relay + """ + return self._send_request_and_transform_response( + Scanners.modify_scanner( + scanner_id, + name=name, + host=host, + port=port, + scanner_type=scanner_type, + credential_id=credential_id, + ca_pub=ca_pub, + comment=comment, + relay_host=relay_host, + relay_port=relay_port, + ) + ) + + def get_scanners( + self, + *, + filter_string: Optional[str] = None, + filter_id: Optional[EntityID] = None, + trash: Optional[bool] = None, + details: Optional[bool] = None, + ) -> T: + """Request a list of scanners + + Args: + filter_string: Filter term to use for the query + filter_id: UUID of an existing filter to use for the query + trash: Whether to get the trashcan scanners instead + details: Whether to include extra details like tasks using this + scanner + """ + return self._send_request_and_transform_response( + Scanners.get_scanners( + filter_string=filter_string, + filter_id=filter_id, + trash=trash, + details=details, + ) + ) + + def get_scanner(self, scanner_id: EntityID) -> T: + """Request a single scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.get_scanner(scanner_id) + ) + + def verify_scanner(self, scanner_id: EntityID) -> T: + """Verify an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.verify_scanner(scanner_id) + ) + + def clone_scanner(self, scanner_id: EntityID) -> T: + """Clone an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.clone_scanner(scanner_id) + ) + + def delete_scanner( + self, scanner_id: EntityID, ultimate: Optional[bool] = False + ) -> T: + """Delete an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.delete_scanner(scanner_id, ultimate=ultimate) + ) diff --git a/gvm/protocols/gmp/requests/v226/__init__.py b/gvm/protocols/gmp/requests/v226/__init__.py index 268e2a07..e9379949 100644 --- a/gvm/protocols/gmp/requests/v226/__init__.py +++ b/gvm/protocols/gmp/requests/v226/__init__.py @@ -48,8 +48,6 @@ Results, Roles, ScanConfigs, - Scanners, - ScannerType, Schedules, SecInfo, Severity, @@ -71,6 +69,7 @@ ) from ._audit_reports import AuditReports from ._filters import Filters, FilterType +from ._scanners import Scanners, ScannerType from ._report_configs import ReportConfigParameter, ReportConfigs from ._reports import Reports from ._resource_names import ResourceNames, ResourceType diff --git a/gvm/protocols/gmp/requests/v226/_scanners.py b/gvm/protocols/gmp/requests/v226/_scanners.py new file mode 100644 index 00000000..b6de6e9e --- /dev/null +++ b/gvm/protocols/gmp/requests/v226/_scanners.py @@ -0,0 +1,326 @@ +# SPDX-FileCopyrightText: 2021-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from typing import Optional, Union + +from gvm._enum import Enum +from gvm.errors import InvalidArgument, RequiredArgument +from gvm.protocols.core import Request +from gvm.utils import to_bool +from gvm.xml import XmlCommand + +from .._entity_id import EntityID + + +class ScannerType(Enum): + """Enum for scanner type""" + + # 1 was removed (OSP_SCANNER_TYPE). + OPENVAS_SCANNER_TYPE = "2" + CVE_SCANNER_TYPE = "3" + GREENBONE_SENSOR_SCANNER_TYPE = "5" + OPENVASD_SCANNER_TYPE = "6" + + @classmethod + def from_string( + cls, + scanner_type: Optional[str], + ) -> Optional["ScannerType"]: + """Convert a scanner type string to an actual ScannerType instance + + Arguments: + scanner_type: Scanner type string to convert to a ScannerType + """ + if not scanner_type: + return None + + scanner_type = scanner_type.lower() + + if ( + scanner_type == cls.OPENVAS_SCANNER_TYPE.value + or scanner_type == "openvas" + or scanner_type == "openvas_scanner_type" + ): + return cls.OPENVAS_SCANNER_TYPE + + if ( + scanner_type == cls.CVE_SCANNER_TYPE.value + or scanner_type == "cve" + or scanner_type == "cve_scanner_type" + ): + return cls.CVE_SCANNER_TYPE + + if ( + scanner_type == cls.GREENBONE_SENSOR_SCANNER_TYPE.value + or scanner_type == "greenbone" + or scanner_type == "greenbone_sensor_scanner_type" + ): + return cls.GREENBONE_SENSOR_SCANNER_TYPE + + if ( + scanner_type == cls.OPENVASD_SCANNER_TYPE.value + or scanner_type == "openvasd" + or scanner_type == "openvasd_scanner_type" + ): + return cls.OPENVASD_SCANNER_TYPE + + raise InvalidArgument( + argument="scanner_type", function=cls.from_string.__name__ + ) + + +class Scanners: + @classmethod + def create_scanner( + cls, + name: str, + host: str, + port: Union[str, int], + scanner_type: ScannerType, + credential_id: str, + *, + ca_pub: Optional[str] = None, + comment: Optional[str] = None, + relay_host: Optional[str] = None, + relay_port: Optional[Union[str, int]] = None, + ) -> Request: + """Create a new scanner + + Args: + name: Name of the new scanner + host: Hostname or IP address of the scanner + port: Port of the scanner + scanner_type: Type of the scanner + credential_id: UUID of client certificate credential for the + scanner + ca_pub: Certificate of CA to verify scanner certificate + comment: Comment for the scanner + relay_host: Hostname or IP address of the scanner relay + relay_port: Port of the scanner relay + """ + if not name: + raise RequiredArgument( + function=cls.create_scanner.__name__, argument="name" + ) + + if not host: + raise RequiredArgument( + function=cls.create_scanner.__name__, argument="host" + ) + + if not port: + raise RequiredArgument( + function=cls.create_scanner.__name__, argument="port" + ) + + if not scanner_type: + raise RequiredArgument( + function=cls.create_scanner.__name__, argument="scanner_type" + ) + + if not credential_id: + raise RequiredArgument( + function=cls.create_scanner.__name__, argument="credential_id" + ) + + cmd = XmlCommand("create_scanner") + cmd.add_element("name", name) + cmd.add_element("host", host) + cmd.add_element("port", str(port)) + + if not isinstance(scanner_type, ScannerType): + scanner_type = ScannerType(scanner_type) + + cmd.add_element("type", scanner_type.value) + + cmd.add_element("credential", attrs={"id": str(credential_id)}) + + if ca_pub: + cmd.add_element("ca_pub", ca_pub) + + if comment: + cmd.add_element("comment", comment) + + if relay_host: + cmd.add_element("relay_host", relay_host) + + if relay_port: + cmd.add_element("relay_port", str(relay_port)) + + return cmd + + @classmethod + def modify_scanner( + cls, + scanner_id: EntityID, + *, + name: Optional[str] = None, + host: Optional[str] = None, + port: Optional[int] = None, + scanner_type: Optional[ScannerType] = None, + credential_id: Optional[EntityID] = None, + ca_pub: Optional[str] = None, + comment: Optional[str] = None, + relay_host: Optional[str] = None, + relay_port: Optional[Union[str, int]] = None, + ) -> Request: + """Modify an existing scanner + + Args: + scanner_id: UUID of the scanner to modify + name: New name of the scanner + host: New hostname or IP address of the scanner + port: New port of the scanner + scanner_type: New type of the scanner + credential_id: New UUID of client certificate credential for the + scanner + ca_pub: New certificate of CA to verify scanner certificate + comment: New comment for the scanner + relay_host: Hostname or IP address of the scanner relay + relay_port: Port of the scanner relay + """ + if not scanner_id: + raise RequiredArgument( + function=cls.modify_scanner.__name__, argument="scanner_id" + ) + + cmd = XmlCommand("modify_scanner") + cmd.set_attribute("scanner_id", str(scanner_id)) + + if scanner_type is not None: + if not isinstance(scanner_type, ScannerType): + scanner_type = ScannerType(scanner_type) + if not scanner_type: + raise InvalidArgument( + argument="scanner_type", + function=cls.modify_scanner.__name__, + ) + cmd.add_element("type", scanner_type.value) + + if host: + cmd.add_element("host", host) + + if port: + cmd.add_element("port", str(port)) + + if comment: + cmd.add_element("comment", comment) + + if name: + cmd.add_element("name", name) + + if ca_pub: + cmd.add_element("ca_pub", ca_pub) + + if credential_id: + cmd.add_element("credential", attrs={"id": str(credential_id)}) + + if relay_host: + cmd.add_element("relay_host", relay_host) + + if relay_port: + cmd.add_element("relay_port", str(relay_port)) + + return cmd + + @staticmethod + def get_scanners( + *, + filter_string: Optional[str] = None, + filter_id: Optional[EntityID] = None, + trash: Optional[bool] = None, + details: Optional[bool] = None, + ) -> Request: + """Request a list of scanners + + Args: + filter_string: Filter term to use for the query + filter_id: UUID of an existing filter to use for the query + trash: Whether to get the trashcan scanners instead + details: Whether to include extra details like tasks using this + scanner + """ + cmd = XmlCommand("get_scanners") + cmd.add_filter(filter_string, filter_id) + + if trash is not None: + cmd.set_attribute("trash", to_bool(trash)) + + if details is not None: + cmd.set_attribute("details", to_bool(details)) + + return cmd + + @classmethod + def get_scanner(cls, scanner_id: EntityID) -> Request: + """Request a single scanner + + Args: + scanner_id: UUID of an existing scanner + """ + if not scanner_id: + raise RequiredArgument( + function=cls.get_scanner.__name__, argument="scanner_id" + ) + + cmd = XmlCommand("get_scanners") + cmd.set_attribute("scanner_id", str(scanner_id)) + + # for single entity always request all details + cmd.set_attribute("details", "1") + + return cmd + + @classmethod + def verify_scanner(cls, scanner_id: EntityID) -> Request: + """Verify an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + if not scanner_id: + raise RequiredArgument( + function=cls.verify_scanner.__name__, argument="scanner_id" + ) + + cmd = XmlCommand("verify_scanner") + cmd.set_attribute("scanner_id", str(scanner_id)) + + return cmd + + @classmethod + def clone_scanner(cls, scanner_id: EntityID) -> Request: + """Clone an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + if not scanner_id: + raise RequiredArgument( + function=cls.clone_scanner.__name__, argument="scanner_id" + ) + + cmd = XmlCommand("create_scanner") + cmd.add_element("copy", str(scanner_id)) + return cmd + + @classmethod + def delete_scanner( + cls, scanner_id: EntityID, ultimate: Optional[bool] = False + ) -> Request: + """Delete an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + if not scanner_id: + raise RequiredArgument( + function=cls.delete_scanner.__name__, argument="scanner_id" + ) + + cmd = XmlCommand("delete_scanner") + cmd.set_attribute("scanner_id", str(scanner_id)) + cmd.set_attribute("ultimate", to_bool(ultimate)) + + return cmd diff --git a/tests/protocols/gmpv226/entities/test_scanners.py b/tests/protocols/gmpv226/entities/test_scanners.py index d48a2fbd..fa732936 100644 --- a/tests/protocols/gmpv226/entities/test_scanners.py +++ b/tests/protocols/gmpv226/entities/test_scanners.py @@ -12,7 +12,7 @@ GmpModifyScannerTestMixin, ) from ...gmpv226 import GMPTestCase - +from gvm.protocols.gmp.requests.v226 import ScannerType class GMPDeleteScannerTestCase(GmpDeleteScannerTestMixin, GMPTestCase): pass @@ -31,8 +31,98 @@ class GMPCloneScannerTestCase(GmpCloneScannerTestMixin, GMPTestCase): class GMPCreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): - pass + def test_create_scanner_with_openvasd_type(self): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + credential_id="c1", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"localhost" + b"1234" + b"6" + b'' + b"" + ) + + def test_create_scanner_with_relay_host(self): + self.gmp.create_scanner( + name="foo", + host="remotehost", + port=1234, + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + credential_id="c1", + relay_host="localhost", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"remotehost" + b"1234" + b"6" + b'' + b'localhost' + b"" + ) + def test_create_scanner_with_relay_port(self): + self.gmp.create_scanner( + name="foo", + host="remotehost", + port=1234, + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + credential_id="c1", + relay_port=2345, + ) + self.connection.send.has_been_called_with( + b"" + b"foo" + b"remotehost" + b"1234" + b"6" + b'' + b'2345' + b"" + ) class GMPModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): - pass + def test_modify_scanner_with_openvasd_type(self): + self.gmp.modify_scanner( + scanner_id="s1", + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + ) + + self.connection.send.has_been_called_with( + b'' + b'6' + b'' + ) + + def test_modify_scanner_with_relay_host(self): + self.gmp.modify_scanner( + scanner_id="s1", + relay_host="localhost", + ) + + self.connection.send.has_been_called_with( + b'' + b'localhost' + b'' + ) + def test_modify_scanner_with_relay_port(self): + self.gmp.modify_scanner( + scanner_id="s1", + relay_port=2345, + ) + + self.connection.send.has_been_called_with( + b'' + b'2345' + b'' + ) diff --git a/tests/protocols/gmpv226/enums/test_scanner_type.py b/tests/protocols/gmpv226/enums/test_scanner_type.py index aee135b1..f09a9b04 100644 --- a/tests/protocols/gmpv226/enums/test_scanner_type.py +++ b/tests/protocols/gmpv226/enums/test_scanner_type.py @@ -47,3 +47,10 @@ def test_greenbone_sensor_scanner(self): ct = ScannerType.from_string("greenbone") self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) + + def test_openvasd_scanner(self): + ct = ScannerType.from_string("6") + self.assertEqual(ct, ScannerType.OPENVASD_SCANNER_TYPE) + + ct = ScannerType.from_string("openvasd") + self.assertEqual(ct, ScannerType.OPENVASD_SCANNER_TYPE) From 66ce63421fcc05e941f00ad524ecba7fd879841e Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Thu, 10 Apr 2025 14:44:14 +0200 Subject: [PATCH 2/6] Create GMP 22.7 protocol and move scanner changes there --- gvm/protocols/gmp/__init__.py | 8 +- gvm/protocols/gmp/_gmp.py | 10 +- gvm/protocols/gmp/_gmp226.py | 155 ----------- gvm/protocols/gmp/_gmp227.py | 190 +++++++++++++ gvm/protocols/gmp/requests/v226/__init__.py | 3 +- gvm/protocols/gmp/requests/v227/__init__.py | 151 +++++++++++ .../gmp/requests/{v226 => v227}/_scanners.py | 0 gvm/protocols/latest.py | 4 +- gvm/protocols/next.py | 4 +- .../gmpv226/entities/test_scanners.py | 102 +------ .../gmpv226/enums/test_scanner_type.py | 14 - tests/protocols/gmpv227/__init__.py | 12 + tests/protocols/gmpv227/entities/__init__.py | 3 + .../gmpv227/entities/scanners/__init__.py | 23 ++ .../entities/scanners/test_create_scanner.py | 254 ++++++++++++++++++ .../entities/scanners/test_modify_scanner.py | 163 +++++++++++ .../protocols/gmpv227/entities/test_alerts.py | 48 ++++ .../gmpv227/entities/test_audit_reports.py | 23 ++ .../protocols/gmpv227/entities/test_audits.py | 53 ++++ .../gmpv227/entities/test_credentials.py | 38 +++ .../gmpv227/entities/test_filters.py | 38 +++ .../protocols/gmpv227/entities/test_groups.py | 38 +++ .../protocols/gmpv227/entities/test_hosts.py | 33 +++ .../protocols/gmpv227/entities/test_notes.py | 38 +++ .../entities/test_operating_systems.py | 36 +++ .../gmpv227/entities/test_overrides.py | 38 +++ .../gmpv227/entities/test_permissions.py | 38 +++ .../gmpv227/entities/test_policies.py | 80 ++++++ .../gmpv227/entities/test_port_lists.py | 48 ++++ .../gmpv227/entities/test_report_configs.py | 44 +++ .../gmpv227/entities/test_report_formats.py | 51 ++++ .../gmpv227/entities/test_reports.py | 28 ++ .../gmpv227/entities/test_resource_names.py | 20 ++ .../gmpv227/entities/test_results.py | 18 ++ .../protocols/gmpv227/entities/test_roles.py | 38 +++ .../gmpv227/entities/test_scan_configs.py | 80 ++++++ .../gmpv227/entities/test_scanners.py | 42 +++ .../gmpv227/entities/test_schedules.py | 38 +++ .../gmpv227/entities/test_secinfo.py | 83 ++++++ tests/protocols/gmpv227/entities/test_tags.py | 38 +++ .../gmpv227/entities/test_targets.py | 38 +++ .../protocols/gmpv227/entities/test_tasks.py | 65 +++++ .../gmpv227/entities/test_tickets.py | 38 +++ .../gmpv227/entities/test_tls_certificates.py | 48 ++++ .../protocols/gmpv227/entities/test_users.py | 38 +++ .../gmpv227/entities/test_vulnerabilities.py | 20 ++ tests/protocols/gmpv227/enums/__init__.py | 4 + .../gmpv227/enums/test_aggregate_statistic.py | 57 ++++ .../gmpv227/enums/test_alert_condition.py | 45 ++++ .../gmpv227/enums/test_alert_event.py | 45 ++++ .../gmpv227/enums/test_alert_method.py | 69 +++++ .../gmpv227/enums/test_alive_test.py | 61 +++++ .../gmpv227/enums/test_credential_format.py | 41 +++ .../gmpv227/enums/test_credential_type.py | 49 ++++ .../gmpv227/enums/test_entity_type.py | 166 ++++++++++++ .../protocols/gmpv227/enums/test_feed_type.py | 37 +++ .../gmpv227/enums/test_filter_type.py | 146 ++++++++++ .../gmpv227/enums/test_help_format.py | 37 +++ .../gmpv227/enums/test_hosts_ordering.py | 33 +++ .../protocols/gmpv227/enums/test_info_type.py | 49 ++++ .../enums/test_permission_subject_type.py | 33 +++ .../gmpv227/enums/test_port_range_type.py | 29 ++ .../gmpv227/enums/test_report_format_type.py | 97 +++++++ .../gmpv227/enums/test_resource_type.py | 133 +++++++++ .../gmpv227/enums/test_scanner_type.py | 56 ++++ .../gmpv227/enums/test_snmp_algorithms.py | 52 ++++ .../gmpv227/enums/test_sort_order.py | 33 +++ .../gmpv227/enums/test_ticket_status.py | 33 +++ .../gmpv227/enums/test_user_auth_type.py | 37 +++ tests/protocols/test_latest.py | 2 +- tests/protocols/test_next.py | 2 +- 71 files changed, 3440 insertions(+), 278 deletions(-) create mode 100644 gvm/protocols/gmp/_gmp227.py create mode 100644 gvm/protocols/gmp/requests/v227/__init__.py rename gvm/protocols/gmp/requests/{v226 => v227}/_scanners.py (100%) create mode 100644 tests/protocols/gmpv227/__init__.py create mode 100644 tests/protocols/gmpv227/entities/__init__.py create mode 100644 tests/protocols/gmpv227/entities/scanners/__init__.py create mode 100644 tests/protocols/gmpv227/entities/scanners/test_create_scanner.py create mode 100644 tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py create mode 100644 tests/protocols/gmpv227/entities/test_alerts.py create mode 100644 tests/protocols/gmpv227/entities/test_audit_reports.py create mode 100644 tests/protocols/gmpv227/entities/test_audits.py create mode 100644 tests/protocols/gmpv227/entities/test_credentials.py create mode 100644 tests/protocols/gmpv227/entities/test_filters.py create mode 100644 tests/protocols/gmpv227/entities/test_groups.py create mode 100644 tests/protocols/gmpv227/entities/test_hosts.py create mode 100644 tests/protocols/gmpv227/entities/test_notes.py create mode 100644 tests/protocols/gmpv227/entities/test_operating_systems.py create mode 100644 tests/protocols/gmpv227/entities/test_overrides.py create mode 100644 tests/protocols/gmpv227/entities/test_permissions.py create mode 100644 tests/protocols/gmpv227/entities/test_policies.py create mode 100644 tests/protocols/gmpv227/entities/test_port_lists.py create mode 100644 tests/protocols/gmpv227/entities/test_report_configs.py create mode 100644 tests/protocols/gmpv227/entities/test_report_formats.py create mode 100644 tests/protocols/gmpv227/entities/test_reports.py create mode 100644 tests/protocols/gmpv227/entities/test_resource_names.py create mode 100644 tests/protocols/gmpv227/entities/test_results.py create mode 100644 tests/protocols/gmpv227/entities/test_roles.py create mode 100644 tests/protocols/gmpv227/entities/test_scan_configs.py create mode 100644 tests/protocols/gmpv227/entities/test_scanners.py create mode 100644 tests/protocols/gmpv227/entities/test_schedules.py create mode 100644 tests/protocols/gmpv227/entities/test_secinfo.py create mode 100644 tests/protocols/gmpv227/entities/test_tags.py create mode 100644 tests/protocols/gmpv227/entities/test_targets.py create mode 100644 tests/protocols/gmpv227/entities/test_tasks.py create mode 100644 tests/protocols/gmpv227/entities/test_tickets.py create mode 100644 tests/protocols/gmpv227/entities/test_tls_certificates.py create mode 100644 tests/protocols/gmpv227/entities/test_users.py create mode 100644 tests/protocols/gmpv227/entities/test_vulnerabilities.py create mode 100644 tests/protocols/gmpv227/enums/__init__.py create mode 100644 tests/protocols/gmpv227/enums/test_aggregate_statistic.py create mode 100644 tests/protocols/gmpv227/enums/test_alert_condition.py create mode 100644 tests/protocols/gmpv227/enums/test_alert_event.py create mode 100644 tests/protocols/gmpv227/enums/test_alert_method.py create mode 100644 tests/protocols/gmpv227/enums/test_alive_test.py create mode 100644 tests/protocols/gmpv227/enums/test_credential_format.py create mode 100644 tests/protocols/gmpv227/enums/test_credential_type.py create mode 100644 tests/protocols/gmpv227/enums/test_entity_type.py create mode 100644 tests/protocols/gmpv227/enums/test_feed_type.py create mode 100644 tests/protocols/gmpv227/enums/test_filter_type.py create mode 100644 tests/protocols/gmpv227/enums/test_help_format.py create mode 100644 tests/protocols/gmpv227/enums/test_hosts_ordering.py create mode 100644 tests/protocols/gmpv227/enums/test_info_type.py create mode 100644 tests/protocols/gmpv227/enums/test_permission_subject_type.py create mode 100644 tests/protocols/gmpv227/enums/test_port_range_type.py create mode 100644 tests/protocols/gmpv227/enums/test_report_format_type.py create mode 100644 tests/protocols/gmpv227/enums/test_resource_type.py create mode 100644 tests/protocols/gmpv227/enums/test_scanner_type.py create mode 100644 tests/protocols/gmpv227/enums/test_snmp_algorithms.py create mode 100644 tests/protocols/gmpv227/enums/test_sort_order.py create mode 100644 tests/protocols/gmpv227/enums/test_ticket_status.py create mode 100644 tests/protocols/gmpv227/enums/test_user_auth_type.py diff --git a/gvm/protocols/gmp/__init__.py b/gvm/protocols/gmp/__init__.py index f9857007..d95d4289 100644 --- a/gvm/protocols/gmp/__init__.py +++ b/gvm/protocols/gmp/__init__.py @@ -8,18 +8,21 @@ In most circumstances you will want to use the :class:`GMP` class which dynamically selects the supported GMP protocol of the remote manager daemon. -If you need to use a specific GMP version, you can use the :class:`GMPv224` or -:class:`GMPv225` classes. +If you need to use a specific GMP version, you can use the :class:`GMPv224`, +:class:`GMPv225`, :class:`GMPv226` or :class:`GMPv227` classes. * :class:`GMP` - Dynamically select supported GMP protocol of the remote manager daemon. * :class:`GMPv224` - GMP version 22.4 * :class:`GMPv225` - GMP version 22.5 +* :class:`GMPv226` - GMP version 22.6 +* :class:`GMPv227` - GMP version 22.7 """ from ._gmp import GMP from ._gmp224 import GMPv224 from ._gmp225 import GMPv225 from ._gmp226 import GMPv226 +from ._gmp227 import GMPv227 Gmp = GMP # for backwards compatibility @@ -29,4 +32,5 @@ "GMPv224", "GMPv225", "GMPv226", + "GMPv227", ) diff --git a/gvm/protocols/gmp/_gmp.py b/gvm/protocols/gmp/_gmp.py index 6ad5fff4..7ec73818 100644 --- a/gvm/protocols/gmp/_gmp.py +++ b/gvm/protocols/gmp/_gmp.py @@ -15,10 +15,11 @@ from ._gmp224 import GMPv224 from ._gmp225 import GMPv225 from ._gmp226 import GMPv226 +from ._gmp227 import GMPv227 from .requests import Version -SUPPORTED_GMP_VERSIONS = Union[GMPv224[T], GMPv225[T], GMPv226[T]] -_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6"] +SUPPORTED_GMP_VERSIONS = Union[GMPv224[T], GMPv225[T], GMPv226[T], GMPv227[T]] +_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6", "22.7"] class GMP(GvmProtocol[T]): @@ -36,8 +37,9 @@ class GMP(GvmProtocol[T]): with GMP(connection) as gmp: # gmp can be an instance of # gvm.protocols.gmp.GMPv224, - # gvm.protocols.gmp.GMPv225 - # or gvm.protocols.gmp.GMPv226 + # gvm.protocols.gmp.GMPv225, + # gvm.protocols.gmp.GMPv226, + # or gvm.protocols.gmp.GMPv227 # depending on the supported GMP version of the remote manager daemon resp = gmp.get_tasks() diff --git a/gvm/protocols/gmp/_gmp226.py b/gvm/protocols/gmp/_gmp226.py index 2fcec60b..cad24f90 100644 --- a/gvm/protocols/gmp/_gmp226.py +++ b/gvm/protocols/gmp/_gmp226.py @@ -21,8 +21,6 @@ Reports, ResourceNames, ResourceType, - Scanners, - ScannerType, ) @@ -448,156 +446,3 @@ def modify_report_config( report_config_id, name=name, comment=comment, params=params ) ) - - def create_scanner( - self, - name: str, - host: str, - port: Union[str, int], - scanner_type: ScannerType, - credential_id: str, - *, - ca_pub: Optional[str] = None, - comment: Optional[str] = None, - relay_host: Optional[str] = None, - relay_port: Optional[Union[str, int]] = None, - ) -> T: - """Create a new scanner - - Args: - name: Name of the new scanner - host: Hostname or IP address of the scanner - port: Port of the scanner - scanner_type: Type of the scanner - credential_id: UUID of client certificate credential for the - scanner - ca_pub: Certificate of CA to verify scanner certificate - comment: Comment for the scanner - relay_host: Hostname or IP address of the scanner relay - relay_port: Port of the scanner relay - """ - return self._send_request_and_transform_response( - Scanners.create_scanner( - name, - host, - port, - scanner_type, - credential_id, - ca_pub=ca_pub, - comment=comment, - relay_host=relay_host, - relay_port=relay_port, - ) - ) - - def modify_scanner( - self, - scanner_id: EntityID, - *, - name: Optional[str] = None, - host: Optional[str] = None, - port: Optional[int] = None, - scanner_type: Optional[ScannerType] = None, - credential_id: Optional[EntityID] = None, - ca_pub: Optional[str] = None, - comment: Optional[str] = None, - relay_host: Optional[str] = None, - relay_port: Optional[Union[str, int]] = None, - ) -> T: - """Modify an existing scanner - - Args: - scanner_id: UUID of the scanner to modify - name: New name of the scanner - host: New hostname or IP address of the scanner - port: New port of the scanner - scanner_type: New type of the scanner - credential_id: New UUID of client certificate credential for the - scanner - ca_pub: New certificate of CA to verify scanner certificate - comment: New comment for the scanner - relay_host: Hostname or IP address of the scanner relay - relay_port: Port of the scanner relay - """ - return self._send_request_and_transform_response( - Scanners.modify_scanner( - scanner_id, - name=name, - host=host, - port=port, - scanner_type=scanner_type, - credential_id=credential_id, - ca_pub=ca_pub, - comment=comment, - relay_host=relay_host, - relay_port=relay_port, - ) - ) - - def get_scanners( - self, - *, - filter_string: Optional[str] = None, - filter_id: Optional[EntityID] = None, - trash: Optional[bool] = None, - details: Optional[bool] = None, - ) -> T: - """Request a list of scanners - - Args: - filter_string: Filter term to use for the query - filter_id: UUID of an existing filter to use for the query - trash: Whether to get the trashcan scanners instead - details: Whether to include extra details like tasks using this - scanner - """ - return self._send_request_and_transform_response( - Scanners.get_scanners( - filter_string=filter_string, - filter_id=filter_id, - trash=trash, - details=details, - ) - ) - - def get_scanner(self, scanner_id: EntityID) -> T: - """Request a single scanner - - Args: - scanner_id: UUID of an existing scanner - """ - return self._send_request_and_transform_response( - Scanners.get_scanner(scanner_id) - ) - - def verify_scanner(self, scanner_id: EntityID) -> T: - """Verify an existing scanner - - Args: - scanner_id: UUID of an existing scanner - """ - return self._send_request_and_transform_response( - Scanners.verify_scanner(scanner_id) - ) - - def clone_scanner(self, scanner_id: EntityID) -> T: - """Clone an existing scanner - - Args: - scanner_id: UUID of an existing scanner - """ - return self._send_request_and_transform_response( - Scanners.clone_scanner(scanner_id) - ) - - def delete_scanner( - self, scanner_id: EntityID, ultimate: Optional[bool] = False - ) -> T: - """Delete an existing scanner - - Args: - scanner_id: UUID of an existing scanner - """ - return self._send_request_and_transform_response( - Scanners.delete_scanner(scanner_id, ultimate=ultimate) - ) diff --git a/gvm/protocols/gmp/_gmp227.py b/gvm/protocols/gmp/_gmp227.py new file mode 100644 index 00000000..fff1d04f --- /dev/null +++ b/gvm/protocols/gmp/_gmp227.py @@ -0,0 +1,190 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +""" +Greenbone Management Protocol (GMP) version 22.7 +""" + +from typing import Optional, Sequence, Union + +from .._protocol import T +from ._gmp226 import GMPv226 +from .requests.v227 import ( + EntityID, + Scanners, + ScannerType, +) + + +class GMPv227(GMPv226[T]): + """ + A class implementing the Greenbone Management Protocol (GMP) version 22.7 + + Example: + + .. code-block:: python + + from gvm.protocols.gmp import GMPv227 as GMP + + with GMP(connection) as gmp: + resp = gmp.get_tasks() + """ + + @staticmethod + def get_protocol_version() -> tuple[int, int]: + return (22, 7) + + def create_scanner( + self, + name: str, + host: str, + port: Union[str, int], + scanner_type: ScannerType, + credential_id: str, + *, + ca_pub: Optional[str] = None, + comment: Optional[str] = None, + relay_host: Optional[str] = None, + relay_port: Optional[Union[str, int]] = None, + ) -> T: + """Create a new scanner + + Args: + name: Name of the new scanner + host: Hostname or IP address of the scanner + port: Port of the scanner + scanner_type: Type of the scanner + credential_id: UUID of client certificate credential for the + scanner + ca_pub: Certificate of CA to verify scanner certificate + comment: Comment for the scanner + relay_host: Hostname or IP address of the scanner relay + relay_port: Port of the scanner relay + """ + return self._send_request_and_transform_response( + Scanners.create_scanner( + name, + host, + port, + scanner_type, + credential_id, + ca_pub=ca_pub, + comment=comment, + relay_host=relay_host, + relay_port=relay_port, + ) + ) + + def modify_scanner( + self, + scanner_id: EntityID, + *, + name: Optional[str] = None, + host: Optional[str] = None, + port: Optional[int] = None, + scanner_type: Optional[ScannerType] = None, + credential_id: Optional[EntityID] = None, + ca_pub: Optional[str] = None, + comment: Optional[str] = None, + relay_host: Optional[str] = None, + relay_port: Optional[Union[str, int]] = None, + ) -> T: + """Modify an existing scanner + + Args: + scanner_id: UUID of the scanner to modify + name: New name of the scanner + host: New hostname or IP address of the scanner + port: New port of the scanner + scanner_type: New type of the scanner + credential_id: New UUID of client certificate credential for the + scanner + ca_pub: New certificate of CA to verify scanner certificate + comment: New comment for the scanner + relay_host: Hostname or IP address of the scanner relay + relay_port: Port of the scanner relay + """ + return self._send_request_and_transform_response( + Scanners.modify_scanner( + scanner_id, + name=name, + host=host, + port=port, + scanner_type=scanner_type, + credential_id=credential_id, + ca_pub=ca_pub, + comment=comment, + relay_host=relay_host, + relay_port=relay_port, + ) + ) + + def get_scanners( + self, + *, + filter_string: Optional[str] = None, + filter_id: Optional[EntityID] = None, + trash: Optional[bool] = None, + details: Optional[bool] = None, + ) -> T: + """Request a list of scanners + + Args: + filter_string: Filter term to use for the query + filter_id: UUID of an existing filter to use for the query + trash: Whether to get the trashcan scanners instead + details: Whether to include extra details like tasks using this + scanner + """ + return self._send_request_and_transform_response( + Scanners.get_scanners( + filter_string=filter_string, + filter_id=filter_id, + trash=trash, + details=details, + ) + ) + + def get_scanner(self, scanner_id: EntityID) -> T: + """Request a single scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.get_scanner(scanner_id) + ) + + def verify_scanner(self, scanner_id: EntityID) -> T: + """Verify an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.verify_scanner(scanner_id) + ) + + def clone_scanner(self, scanner_id: EntityID) -> T: + """Clone an existing scanner + + Args: + scanner_id: UUID of an existing scanner + """ + return self._send_request_and_transform_response( + Scanners.clone_scanner(scanner_id) + ) + + def delete_scanner( + self, scanner_id: EntityID, ultimate: Optional[bool] = False + ) -> T: + """Delete an existing scanner + + Args: + scanner_id: UUID of an existing scanner + ultimate: Whether to remove entirely, or to the trashcan. + """ + return self._send_request_and_transform_response( + Scanners.delete_scanner(scanner_id, ultimate=ultimate) + ) diff --git a/gvm/protocols/gmp/requests/v226/__init__.py b/gvm/protocols/gmp/requests/v226/__init__.py index e9379949..ae1c68c0 100644 --- a/gvm/protocols/gmp/requests/v226/__init__.py +++ b/gvm/protocols/gmp/requests/v226/__init__.py @@ -47,6 +47,8 @@ ReportFormatType, Results, Roles, + ScannerType, + Scanners, ScanConfigs, Schedules, SecInfo, @@ -69,7 +71,6 @@ ) from ._audit_reports import AuditReports from ._filters import Filters, FilterType -from ._scanners import Scanners, ScannerType from ._report_configs import ReportConfigParameter, ReportConfigs from ._reports import Reports from ._resource_names import ResourceNames, ResourceType diff --git a/gvm/protocols/gmp/requests/v227/__init__.py b/gvm/protocols/gmp/requests/v227/__init__.py new file mode 100644 index 00000000..ab7db8b0 --- /dev/null +++ b/gvm/protocols/gmp/requests/v227/__init__.py @@ -0,0 +1,151 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +""" +GMP Request implementations for GMP version 22.7. +""" + +from .._entity_id import EntityID +from .._version import Version +from ..v226 import ( + Aggregates, + AggregateStatistic, + AlertCondition, + AlertEvent, + AlertMethod, + Alerts, + AliveTest, + AuditReports, + Audits, + Authentication, + CertBundAdvisories, + Cpes, + CredentialFormat, + Credentials, + CredentialType, + Cves, + DfnCertAdvisories, + EntityType, + Feed, + FeedType, + Filters, + FilterType, + Groups, + Help, + HelpFormat, + Hosts, + HostsOrdering, + InfoType, + Notes, + Nvts, + OperatingSystems, + Overrides, + Permissions, + PermissionSubjectType, + Policies, + PortLists, + PortRangeType, + ReportConfigs, + ReportConfigParameter, + ReportFormats, + ReportFormatType, + Reports, + ResourceNames, + ResourceType, + Results, + Roles, + ScanConfigs, + Schedules, + SecInfo, + Severity, + SnmpAuthAlgorithm, + SnmpPrivacyAlgorithm, + SortOrder, + SystemReports, + Tags, + Targets, + Tasks, + Tickets, + TicketStatus, + TLSCertificates, + TrashCan, + UserAuthType, + Users, + UserSettings, + Vulnerabilities, +) + +from gvm.protocols.gmp.requests.v227._scanners import Scanners, ScannerType + +__all__ = ( + "Aggregates", + "AggregateStatistic", + "Alerts", + "AlertCondition", + "AlertEvent", + "AlertMethod", + "AliveTest", + "AuditReports", + "Audits", + "Authentication", + "CertBundAdvisories", + "Cpes", + "Credentials", + "CredentialFormat", + "CredentialType", + "Cves", + "DfnCertAdvisories", + "EntityID", + "EntityType", + "Feed", + "FeedType", + "Filters", + "FilterType", + "Groups", + "Help", + "HelpFormat", + "Hosts", + "HostsOrdering", + "InfoType", + "Notes", + "Nvts", + "OperatingSystems", + "Overrides", + "Permissions", + "PermissionSubjectType", + "Policies", + "PortLists", + "PortRangeType", + "ReportConfigs", + "ReportConfigParameter", + "ReportFormatType", + "ReportFormats", + "Reports", + "ResourceNames", + "ResourceType", + "Results", + "Roles", + "ScanConfigs", + "Scanners", + "ScannerType", + "Schedules", + "SecInfo", + "Severity", + "SortOrder", + "SnmpAuthAlgorithm", + "SnmpPrivacyAlgorithm", + "SystemReports", + "Tags", + "Targets", + "Tasks", + "Tickets", + "TicketStatus", + "TLSCertificates", + "TrashCan", + "UserAuthType", + "UserSettings", + "Users", + "Version", + "Vulnerabilities", +) diff --git a/gvm/protocols/gmp/requests/v226/_scanners.py b/gvm/protocols/gmp/requests/v227/_scanners.py similarity index 100% rename from gvm/protocols/gmp/requests/v226/_scanners.py rename to gvm/protocols/gmp/requests/v227/_scanners.py diff --git a/gvm/protocols/latest.py b/gvm/protocols/latest.py index c067a3a3..711aaf47 100644 --- a/gvm/protocols/latest.py +++ b/gvm/protocols/latest.py @@ -14,7 +14,7 @@ :py:mod:`gvm.protocols`. Exports: - - :py:class:`gvm.protocols.gmp.GMPv226` + - :py:class:`gvm.protocols.gmp.GMPv227` - :py:class:`gvm.protocols.ospv1.Osp` .. _Greenbone Management Protocol: @@ -22,7 +22,7 @@ """ from .gmp import ( - GMPv226 as Gmp, + GMPv227 as Gmp, ) from .ospv1 import Osp diff --git a/gvm/protocols/next.py b/gvm/protocols/next.py index c067a3a3..711aaf47 100644 --- a/gvm/protocols/next.py +++ b/gvm/protocols/next.py @@ -14,7 +14,7 @@ :py:mod:`gvm.protocols`. Exports: - - :py:class:`gvm.protocols.gmp.GMPv226` + - :py:class:`gvm.protocols.gmp.GMPv227` - :py:class:`gvm.protocols.ospv1.Osp` .. _Greenbone Management Protocol: @@ -22,7 +22,7 @@ """ from .gmp import ( - GMPv226 as Gmp, + GMPv227 as Gmp, ) from .ospv1 import Osp diff --git a/tests/protocols/gmpv226/entities/test_scanners.py b/tests/protocols/gmpv226/entities/test_scanners.py index fa732936..2de40c13 100644 --- a/tests/protocols/gmpv226/entities/test_scanners.py +++ b/tests/protocols/gmpv226/entities/test_scanners.py @@ -1,9 +1,9 @@ -# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# SPDX-FileCopyrightText: 2025 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # -from ...gmpv224.entities.scanners import ( +from tests.protocols.gmpv224.entities.scanners import ( GmpCloneScannerTestMixin, GmpCreateScannerTestMixin, GmpDeleteScannerTestMixin, @@ -11,8 +11,8 @@ GmpGetScannerTestMixin, GmpModifyScannerTestMixin, ) -from ...gmpv226 import GMPTestCase -from gvm.protocols.gmp.requests.v226 import ScannerType +from tests.protocols.gmpv226 import GMPTestCase + class GMPDeleteScannerTestCase(GmpDeleteScannerTestMixin, GMPTestCase): pass @@ -31,98 +31,8 @@ class GMPCloneScannerTestCase(GmpCloneScannerTestMixin, GMPTestCase): class GMPCreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): - def test_create_scanner_with_openvasd_type(self): - self.gmp.create_scanner( - name="foo", - host="localhost", - port=1234, - scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, - credential_id="c1", - ) - - self.connection.send.has_been_called_with( - b"" - b"foo" - b"localhost" - b"1234" - b"6" - b'' - b"" - ) - - def test_create_scanner_with_relay_host(self): - self.gmp.create_scanner( - name="foo", - host="remotehost", - port=1234, - scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, - credential_id="c1", - relay_host="localhost", - ) - - self.connection.send.has_been_called_with( - b"" - b"foo" - b"remotehost" - b"1234" - b"6" - b'' - b'localhost' - b"" - ) + pass - def test_create_scanner_with_relay_port(self): - self.gmp.create_scanner( - name="foo", - host="remotehost", - port=1234, - scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, - credential_id="c1", - relay_port=2345, - ) - self.connection.send.has_been_called_with( - b"" - b"foo" - b"remotehost" - b"1234" - b"6" - b'' - b'2345' - b"" - ) class GMPModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): - def test_modify_scanner_with_openvasd_type(self): - self.gmp.modify_scanner( - scanner_id="s1", - scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, - ) - - self.connection.send.has_been_called_with( - b'' - b'6' - b'' - ) - - def test_modify_scanner_with_relay_host(self): - self.gmp.modify_scanner( - scanner_id="s1", - relay_host="localhost", - ) - - self.connection.send.has_been_called_with( - b'' - b'localhost' - b'' - ) - def test_modify_scanner_with_relay_port(self): - self.gmp.modify_scanner( - scanner_id="s1", - relay_port=2345, - ) - - self.connection.send.has_been_called_with( - b'' - b'2345' - b'' - ) + pass diff --git a/tests/protocols/gmpv226/enums/test_scanner_type.py b/tests/protocols/gmpv226/enums/test_scanner_type.py index f09a9b04..e190b226 100644 --- a/tests/protocols/gmpv226/enums/test_scanner_type.py +++ b/tests/protocols/gmpv226/enums/test_scanner_type.py @@ -40,17 +40,3 @@ def test_gmp_scanner(self): with self.assertRaises(InvalidArgument): ScannerType.from_string("gmp") - - def test_greenbone_sensor_scanner(self): - ct = ScannerType.from_string("5") - self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) - - ct = ScannerType.from_string("greenbone") - self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) - - def test_openvasd_scanner(self): - ct = ScannerType.from_string("6") - self.assertEqual(ct, ScannerType.OPENVASD_SCANNER_TYPE) - - ct = ScannerType.from_string("openvasd") - self.assertEqual(ct, ScannerType.OPENVASD_SCANNER_TYPE) diff --git a/tests/protocols/gmpv227/__init__.py b/tests/protocols/gmpv227/__init__.py new file mode 100644 index 00000000..87d02934 --- /dev/null +++ b/tests/protocols/gmpv227/__init__.py @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gvm.protocols.gmp import GMPv227 + +from .. import GmpTestCase as BaseGMPTestCase + + +class GMPTestCase(BaseGMPTestCase): + gmp_class = GMPv227 \ No newline at end of file diff --git a/tests/protocols/gmpv227/entities/__init__.py b/tests/protocols/gmpv227/entities/__init__.py new file mode 100644 index 00000000..9c0a68e7 --- /dev/null +++ b/tests/protocols/gmpv227/entities/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later diff --git a/tests/protocols/gmpv227/entities/scanners/__init__.py b/tests/protocols/gmpv227/entities/scanners/__init__.py new file mode 100644 index 00000000..e2e2fd4e --- /dev/null +++ b/tests/protocols/gmpv227/entities/scanners/__init__.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2021-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from .test_create_scanner import GmpCreateScannerTestMixin +from .test_modify_scanner import GmpModifyScannerTestMixin + +from ....gmpv224.entities.scanners import GmpCloneScannerTestMixin +from ....gmpv224.entities.scanners import GmpDeleteScannerTestMixin +from ....gmpv224.entities.scanners import GmpGetScannerTestMixin +from ....gmpv224.entities.scanners import GmpGetScannersTestMixin +from ....gmpv224.entities.scanners import GmpVerifyScannerTestMixin + +__all__ = ( + "GmpCloneScannerTestMixin", + "GmpCreateScannerTestMixin", + "GmpDeleteScannerTestMixin", + "GmpGetScannerTestMixin", + "GmpGetScannersTestMixin", + "GmpModifyScannerTestMixin", + "GmpVerifyScannerTestMixin", +) diff --git a/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py b/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py new file mode 100644 index 00000000..83e1b08b --- /dev/null +++ b/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py @@ -0,0 +1,254 @@ +# SPDX-FileCopyrightText: 2021-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gvm.errors import InvalidArgument, RequiredArgument +from gvm.protocols.gmp.requests.v227 import ScannerType + + +class GmpCreateScannerTestMixin: + def test_create_scanner(self): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"localhost" + b"1234" + b"2" + b'' + b"" + ) + + def test_create_scanner_missing_name(self): + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name=None, + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="", + host="localhost", + port=1234, + scanner_type="2", + credential_id="c1", + ) + + def test_create_scanner_missing_host(self): + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host=None, + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="", + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + def test_create_scanner_missing_port(self): + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=None, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port="", + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + def test_create_scanner_missing_scanner_type(self): + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=None, + credential_id="c1", + ) + + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type="", + credential_id="c1", + ) + + def test_create_scanner_missing_credential_id(self): + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id=None, + ) + + with self.assertRaises(RequiredArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="", + ) + + def test_create_scanner_invalid_scanner_type(self): + with self.assertRaises(InvalidArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type="bar", + credential_id="c1", + ) + + with self.assertRaises(AttributeError): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.FOO, # pylint: disable=no-member + credential_id="c1", + ) + + with self.assertRaises(InvalidArgument): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type="55", + credential_id="c1", + ) + + def test_create_scanner_with_ca_pub(self): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + ca_pub="foo", + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"localhost" + b"1234" + b"2" + b'' + b"foo" + b"" + ) + + def test_create_scanner_with_comment(self): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, + credential_id="c1", + comment="bar", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"localhost" + b"1234" + b"2" + b'' + b"bar" + b"" + ) + + def test_create_scanner_with_openvasd_type(self): + self.gmp.create_scanner( + name="foo", + host="localhost", + port=1234, + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + credential_id="c1", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"localhost" + b"1234" + b"6" + b'' + b"" + ) + + def test_create_scanner_with_relay_host(self): + self.gmp.create_scanner( + name="foo", + host="remotehost", + port=1234, + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + credential_id="c1", + relay_host="localhost", + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"remotehost" + b"1234" + b"6" + b'' + b'localhost' + b"" + ) + + def test_create_scanner_with_relay_port(self): + self.gmp.create_scanner( + name="foo", + host="remotehost", + port=1234, + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + credential_id="c1", + relay_port=2345, + ) + + self.connection.send.has_been_called_with( + b"" + b"foo" + b"remotehost" + b"1234" + b"6" + b'' + b'2345' + b"" + ) \ No newline at end of file diff --git a/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py b/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py new file mode 100644 index 00000000..eb1b6b41 --- /dev/null +++ b/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py @@ -0,0 +1,163 @@ +# SPDX-FileCopyrightText: 2021-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gvm.errors import InvalidArgument, RequiredArgument +from gvm.protocols.gmp.requests.v227 import ScannerType + + +class GmpModifyScannerTestMixin: + def test_modify_scanner(self): + self.gmp.modify_scanner(scanner_id="s1") + + self.connection.send.has_been_called_with( + b'' + ) + + def test_modify_scanner_missing_scanner_id(self): + with self.assertRaises(RequiredArgument): + self.gmp.modify_scanner(scanner_id=None) + + with self.assertRaises(RequiredArgument): + self.gmp.modify_scanner(scanner_id="") + + def test_modify_scanner_with_comment(self): + self.gmp.modify_scanner(scanner_id="s1", comment="foo") + + self.connection.send.has_been_called_with( + b'' + b"foo" + b"" + ) + + def test_modify_scanner_with_host(self): + self.gmp.modify_scanner(scanner_id="s1", host="foo") + + self.connection.send.has_been_called_with( + b'' + b"foo" + b"" + ) + + def test_modify_scanner_with_port(self): + self.gmp.modify_scanner(scanner_id="s1", port=1234) + + self.connection.send.has_been_called_with( + b'' + b"1234" + b"" + ) + + self.gmp.modify_scanner(scanner_id="s1", port="1234") + + self.connection.send.has_been_called_with( + b'' + b"1234" + b"" + ) + + def test_modify_scanner_with_name(self): + self.gmp.modify_scanner(scanner_id="s1", name="foo") + + self.connection.send.has_been_called_with( + b'' + b"foo" + b"" + ) + + def test_modify_scanner_with_ca_pub(self): + self.gmp.modify_scanner(scanner_id="s1", ca_pub="foo") + + self.connection.send.has_been_called_with( + b'' + b"foo" + b"" + ) + + def test_modify_scanner_with_credential_id(self): + self.gmp.modify_scanner(scanner_id="s1", credential_id="c1") + + self.connection.send.has_been_called_with( + b'' + b'' + b"" + ) + + def test_modify_scanner_with_scanner_type(self): + self.gmp.modify_scanner( + scanner_id="s1", scanner_type=ScannerType.OPENVAS_SCANNER_TYPE + ) + + self.connection.send.has_been_called_with( + b'' + b"2" + b"" + ) + + self.gmp.modify_scanner( + scanner_id="s1", scanner_type=ScannerType.CVE_SCANNER_TYPE + ) + + self.connection.send.has_been_called_with( + b'' + b"3" + b"" + ) + + self.gmp.modify_scanner( + scanner_id="s1", + scanner_type=ScannerType.GREENBONE_SENSOR_SCANNER_TYPE, + ) + + self.connection.send.has_been_called_with( + b'' + b"5" + b"" + ) + + def test_modify_scanner_invalid_scanner_type(self): + with self.assertRaises(ValueError): + self.gmp.modify_scanner(scanner_id="s1", scanner_type="") + + with self.assertRaises(InvalidArgument): + self.gmp.modify_scanner(scanner_id="s1", scanner_type="-1") + + with self.assertRaises(InvalidArgument): + self.gmp.modify_scanner(scanner_id="s1", scanner_type=1) + + def test_modify_scanner_with_openvasd_type(self): + self.gmp.modify_scanner( + scanner_id="s1", + scanner_type=ScannerType.OPENVASD_SCANNER_TYPE, + ) + + self.connection.send.has_been_called_with( + b'' + b'6' + b'' + ) + + def test_modify_scanner_with_relay_host(self): + self.gmp.modify_scanner( + scanner_id="s1", + relay_host="localhost", + ) + + self.connection.send.has_been_called_with( + b'' + b'localhost' + b'' + ) + + def test_modify_scanner_with_relay_port(self): + self.gmp.modify_scanner( + scanner_id="s1", + relay_port=2345, + ) + + self.connection.send.has_been_called_with( + b'' + b'2345' + b'' + ) diff --git a/tests/protocols/gmpv227/entities/test_alerts.py b/tests/protocols/gmpv227/entities/test_alerts.py new file mode 100644 index 00000000..0b997447 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_alerts.py @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.alerts import ( + GmpCloneAlertTestMixin, + GmpCreateAlertTestMixin, + GmpDeleteAlertTestMixin, + GmpGetAlertsTestMixin, + GmpGetAlertTestMixin, + GmpModifyAlertTestMixin, + GmpTestAlertTestMixin, + GmpTriggerAlertTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneAlertTestCase(GmpCloneAlertTestMixin, GMPTestCase): + pass + + +class GMPCreateAlertTestCase(GmpCreateAlertTestMixin, GMPTestCase): + pass + + +class GMPDeleteAlertTestCase(GmpDeleteAlertTestMixin, GMPTestCase): + pass + + +class GMPGetAlertTestCase(GmpGetAlertTestMixin, GMPTestCase): + pass + + +class GMPGetAlertsTestCase(GmpGetAlertsTestMixin, GMPTestCase): + pass + + +class GMPModifyAlertTestCase(GmpModifyAlertTestMixin, GMPTestCase): + pass + + +class GMPTestAlertTestCase(GmpTestAlertTestMixin, GMPTestCase): + pass + + +class GMPTriggerAlertTestCase(GmpTriggerAlertTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_audit_reports.py b/tests/protocols/gmpv227/entities/test_audit_reports.py new file mode 100644 index 00000000..7578f3d9 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_audit_reports.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv227 import GMPTestCase +from ...gmpv226.entities.audit_reports import ( + GmpDeleteAuditReportTestMixin, + GmpGetAuditReportsTestMixin, + GmpGetAuditReportTestMixin, +) + + +class GMPDeleteAuditReportTestCase(GmpDeleteAuditReportTestMixin, GMPTestCase): + pass + + +class GMPGetAuditReportTestCase(GmpGetAuditReportTestMixin, GMPTestCase): + pass + + +class GMPGetAuditReportsTestCase(GmpGetAuditReportsTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_audits.py b/tests/protocols/gmpv227/entities/test_audits.py new file mode 100644 index 00000000..0d9b9e1a --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_audits.py @@ -0,0 +1,53 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.audits import ( + GmpCloneAuditTestMixin, + GmpCreateAuditTestMixin, + GmpDeleteAuditTestMixin, + GmpGetAuditsTestMixin, + GmpGetAuditTestMixin, + GmpModifyAuditTestMixin, + GmpResumeAuditTestMixin, + GmpStartAuditTestMixin, + GmpStopAuditTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneAuditTestCase(GmpCloneAuditTestMixin, GMPTestCase): + pass + + +class GMPCreateAuditTestCase(GmpCreateAuditTestMixin, GMPTestCase): + pass + + +class GMPDeleteAuditTestCase(GmpDeleteAuditTestMixin, GMPTestCase): + pass + + +class GMPGetAuditTestCase(GmpGetAuditTestMixin, GMPTestCase): + pass + + +class GMPGetAuditsTestCase(GmpGetAuditsTestMixin, GMPTestCase): + pass + + +class GMPModifyAuditTestCase(GmpModifyAuditTestMixin, GMPTestCase): + pass + + +class GMPResumeAuditTestCase(GmpResumeAuditTestMixin, GMPTestCase): + pass + + +class GMPStartAuditTestCase(GmpStartAuditTestMixin, GMPTestCase): + pass + + +class GMPStopAuditTestCase(GmpStopAuditTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_credentials.py b/tests/protocols/gmpv227/entities/test_credentials.py new file mode 100644 index 00000000..5843ed24 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_credentials.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.credentials import ( + GmpCloneCredentialTestMixin, + GmpCreateCredentialTestMixin, + GmpDeleteCredentialTestMixin, + GmpGetCredentialsTestMixin, + GmpGetCredentialTestMixin, + GmpModifyCredentialTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneCredentialTestCase(GmpCloneCredentialTestMixin, GMPTestCase): + pass + + +class GMPCreateCredentialTestCase(GmpCreateCredentialTestMixin, GMPTestCase): + pass + + +class GMPDeleteCredentialTestCase(GmpDeleteCredentialTestMixin, GMPTestCase): + pass + + +class GMPGetCredentialTestCase(GmpGetCredentialTestMixin, GMPTestCase): + pass + + +class GMPGetCredentialsTestCase(GmpGetCredentialsTestMixin, GMPTestCase): + pass + + +class GMPModifyCredentialTestCase(GmpModifyCredentialTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_filters.py b/tests/protocols/gmpv227/entities/test_filters.py new file mode 100644 index 00000000..b309163d --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_filters.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.filters import ( + GmpCloneFilterTestMixin, + GmpCreateFilterTestMixin, + GmpDeleteFilterTestMixin, + GmpGetFiltersTestMixin, + GmpGetFilterTestMixin, + GmpModifyFilterTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteFilterTestCase(GmpDeleteFilterTestMixin, GMPTestCase): + pass + + +class GMPGetFilterTestCase(GmpGetFilterTestMixin, GMPTestCase): + pass + + +class GMPGetFiltersTestCase(GmpGetFiltersTestMixin, GMPTestCase): + pass + + +class GMPCloneFilterTestCase(GmpCloneFilterTestMixin, GMPTestCase): + pass + + +class GMPCreateFilterTestCase(GmpCreateFilterTestMixin, GMPTestCase): + pass + + +class GMPModifyFilterTestCase(GmpModifyFilterTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_groups.py b/tests/protocols/gmpv227/entities/test_groups.py new file mode 100644 index 00000000..cffe3080 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_groups.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.groups import ( + GmpCloneGroupTestMixin, + GmpCreateGroupTestMixin, + GmpDeleteGroupTestMixin, + GmpGetGroupsTestMixin, + GmpGetGroupTestMixin, + GmpModifyGroupTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteGroupTestCase(GmpDeleteGroupTestMixin, GMPTestCase): + pass + + +class GMPGetGroupTestCase(GmpGetGroupTestMixin, GMPTestCase): + pass + + +class GMPGetGroupsTestCase(GmpGetGroupsTestMixin, GMPTestCase): + pass + + +class GMPCloneGroupTestCase(GmpCloneGroupTestMixin, GMPTestCase): + pass + + +class GMPCreateGroupTestCase(GmpCreateGroupTestMixin, GMPTestCase): + pass + + +class GMPModifyGroupTestCase(GmpModifyGroupTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_hosts.py b/tests/protocols/gmpv227/entities/test_hosts.py new file mode 100644 index 00000000..a54ca0b0 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_hosts.py @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.hosts import ( + GmpCreateHostTestMixin, + GmpDeleteHostTestMixin, + GmpGetHostsTestMixin, + GmpGetHostTestMixin, + GmpModifyHostTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCreateHostTestCase(GmpCreateHostTestMixin, GMPTestCase): + pass + + +class GMPDeleteHostTestCase(GmpDeleteHostTestMixin, GMPTestCase): + pass + + +class GMPGetHostTestCase(GmpGetHostTestMixin, GMPTestCase): + pass + + +class GMPGetHostsTestCase(GmpGetHostsTestMixin, GMPTestCase): + pass + + +class GMPModifyHostTestCase(GmpModifyHostTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_notes.py b/tests/protocols/gmpv227/entities/test_notes.py new file mode 100644 index 00000000..489ba2b2 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_notes.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.notes import ( + GmpCloneNoteTestMixin, + GmpCreateNoteTestMixin, + GmpDeleteNoteTestMixin, + GmpGetNotesTestMixin, + GmpGetNoteTestMixin, + GmpModifyNoteTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteNoteTestCase(GmpDeleteNoteTestMixin, GMPTestCase): + pass + + +class GMPGetNoteTestCase(GmpGetNoteTestMixin, GMPTestCase): + pass + + +class GMPGetNotesTestCase(GmpGetNotesTestMixin, GMPTestCase): + pass + + +class GMPCloneNoteTestCase(GmpCloneNoteTestMixin, GMPTestCase): + pass + + +class GMPCreateNoteTestCase(GmpCreateNoteTestMixin, GMPTestCase): + pass + + +class GMPModifyNoteTestCase(GmpModifyNoteTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_operating_systems.py b/tests/protocols/gmpv227/entities/test_operating_systems.py new file mode 100644 index 00000000..f6f31165 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_operating_systems.py @@ -0,0 +1,36 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.operating_systems import ( + GmpDeleteOperatingSystemTestMixin, + GmpGetOperatingSystemsTestMixin, + GmpGetOperatingSystemTestMixin, + GmpModifyOperatingSystemTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteOperatingSystemTestCase( + GmpDeleteOperatingSystemTestMixin, GMPTestCase +): + pass + + +class GMPGetOperatingSystemTestCase( + GmpGetOperatingSystemTestMixin, GMPTestCase +): + pass + + +class GMPGetOperatingSystemsTestCase( + GmpGetOperatingSystemsTestMixin, GMPTestCase +): + pass + + +class GMPModifyOperatingSystemTestCase( + GmpModifyOperatingSystemTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/entities/test_overrides.py b/tests/protocols/gmpv227/entities/test_overrides.py new file mode 100644 index 00000000..a6748e09 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_overrides.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.overrides import ( + GmpCloneOverrideTestMixin, + GmpCreateOverrideTestMixin, + GmpDeleteOverrideTestMixin, + GmpGetOverridesTestMixin, + GmpGetOverrideTestMixin, + GmpModifyOverrideTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneOverrideTestCase(GmpCloneOverrideTestMixin, GMPTestCase): + pass + + +class GMPCreateOverrideTestCase(GmpCreateOverrideTestMixin, GMPTestCase): + pass + + +class GMPDeleteOverrideTestCase(GmpDeleteOverrideTestMixin, GMPTestCase): + pass + + +class GMPGetOverrideTestCase(GmpGetOverrideTestMixin, GMPTestCase): + pass + + +class GMPGetOverridesTestCase(GmpGetOverridesTestMixin, GMPTestCase): + pass + + +class GMPModifyOverrideTestCase(GmpModifyOverrideTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_permissions.py b/tests/protocols/gmpv227/entities/test_permissions.py new file mode 100644 index 00000000..c92c0dca --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_permissions.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.permissions import ( + GmpClonePermissionTestMixin, + GmpCreatePermissionTestMixin, + GmpDeletePermissionTestMixin, + GmpGetPermissionsTestMixin, + GmpGetPermissionTestMixin, + GmpModifyPermissionTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeletePermissionTestCase(GmpDeletePermissionTestMixin, GMPTestCase): + pass + + +class GMPGetPermissionTestCase(GmpGetPermissionTestMixin, GMPTestCase): + pass + + +class GMPGetPermissionsTestCase(GmpGetPermissionsTestMixin, GMPTestCase): + pass + + +class GMPClonePermissionTestCase(GmpClonePermissionTestMixin, GMPTestCase): + pass + + +class GMPCreatePermissionTestCase(GmpCreatePermissionTestMixin, GMPTestCase): + pass + + +class GMPModifyPermissionTestCase(GmpModifyPermissionTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_policies.py b/tests/protocols/gmpv227/entities/test_policies.py new file mode 100644 index 00000000..8a51095f --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_policies.py @@ -0,0 +1,80 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.policies import ( + GmpClonePolicyTestMixin, + GmpCreatePolicyTestMixin, + GmpDeletePolicyTestMixin, + GmpGetPoliciesTestMixin, + GmpGetPolicyTestMixin, + GmpImportPolicyTestMixin, + GmpModifyPolicySetCommentTestMixin, + GmpModifyPolicySetFamilySelectionTestMixin, + GmpModifyPolicySetNameTestMixin, + GmpModifyPolicySetNvtPreferenceTestMixin, + GmpModifyPolicySetNvtSelectionTestMixin, + GmpModifyPolicySetScannerPreferenceTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPClonePolicyTestCase(GmpClonePolicyTestMixin, GMPTestCase): + pass + + +class GMPCreatePolicyTestCase(GmpCreatePolicyTestMixin, GMPTestCase): + pass + + +class GMPDeletePolicyTestCase(GmpDeletePolicyTestMixin, GMPTestCase): + pass + + +class GMPGetPolicyTestCase(GmpGetPolicyTestMixin, GMPTestCase): + pass + + +class GMPGetPoliciesTestCase(GmpGetPoliciesTestMixin, GMPTestCase): + pass + + +class GMPImportPolicyTestCase(GmpImportPolicyTestMixin, GMPTestCase): + pass + + +class GMPModifyPolicySetCommentTestCase( + GmpModifyPolicySetCommentTestMixin, GMPTestCase +): + pass + + +class GMPModifyPolicySetFamilySelectionTestCase( + GmpModifyPolicySetFamilySelectionTestMixin, GMPTestCase +): + pass + + +class GMPModifyPolicySetNvtSelectionTestCase( + GmpModifyPolicySetNvtSelectionTestMixin, GMPTestCase +): + pass + + +class GMPModifyPolicySetNameTestCase( + GmpModifyPolicySetNameTestMixin, GMPTestCase +): + pass + + +class GMPModifyPolicySetNvtPreferenceTestCase( + GmpModifyPolicySetNvtPreferenceTestMixin, GMPTestCase +): + pass + + +class GMPModifyPolicySetScannerPreferenceTestCase( + GmpModifyPolicySetScannerPreferenceTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/entities/test_port_lists.py b/tests/protocols/gmpv227/entities/test_port_lists.py new file mode 100644 index 00000000..82b997f0 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_port_lists.py @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.port_lists import ( + GmpClonePortListTestMixin, + GmpCreatePortListTestMixin, + GmpCreatePortRangeTestMixin, + GmpDeletePortListTestMixin, + GmpDeletePortRangeTestMixin, + GmpGetPortListsTestMixin, + GmpGetPortListTestMixin, + GmpModifyPortListTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPClonePortListTestCase(GmpClonePortListTestMixin, GMPTestCase): + pass + + +class GMPCreatePortListTestCase(GmpCreatePortListTestMixin, GMPTestCase): + pass + + +class GMPCreatePortRangeListTestCase(GmpCreatePortRangeTestMixin, GMPTestCase): + pass + + +class GMPDeletePortListTestCase(GmpDeletePortListTestMixin, GMPTestCase): + pass + + +class GMPDeletePortRangeTestCase(GmpDeletePortRangeTestMixin, GMPTestCase): + pass + + +class GMPGetPortListTestCase(GmpGetPortListTestMixin, GMPTestCase): + pass + + +class GMPGetPortListsTestCase(GmpGetPortListsTestMixin, GMPTestCase): + pass + + +class GMPModifyPortListTestCase(GmpModifyPortListTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_report_configs.py b/tests/protocols/gmpv227/entities/test_report_configs.py new file mode 100644 index 00000000..5b2b5fa2 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_report_configs.py @@ -0,0 +1,44 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv227 import GMPTestCase +from ...gmpv226.entities.report_configs import ( + GMPCloneReportConfigTestMixin, + GMPCreateReportConfigTestMixin, + GMPDeleteReportConfigTestMixin, + GMPGetReportConfigsTestMixin, + GMPGetReportConfigTestMixin, + GMPModifyReportConfigTestMixin, +) + + +class GMPCloneReportConfigTestCase(GMPCloneReportConfigTestMixin, GMPTestCase): + pass + + +class GMPCreateReportConfigTestCase( + GMPCreateReportConfigTestMixin, GMPTestCase +): + pass + + +class GMPDeleteReportConfigTestCase( + GMPDeleteReportConfigTestMixin, GMPTestCase +): + pass + + +class GMPGetReportConfigTestCase(GMPGetReportConfigTestMixin, GMPTestCase): + pass + + +class GMPGetReportConfigsTestCase(GMPGetReportConfigsTestMixin, GMPTestCase): + pass + + +class GMPModifyReportConfigTestCase( + GMPModifyReportConfigTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/entities/test_report_formats.py b/tests/protocols/gmpv227/entities/test_report_formats.py new file mode 100644 index 00000000..b036feaa --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_report_formats.py @@ -0,0 +1,51 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.report_formats import ( + GmpCloneReportFormatTestMixin, + GmpDeleteReportFormatTestMixin, + GmpGetReportFormatsTestMixin, + GmpGetReportFormatTestMixin, + GmpImportReportFormatTestMixin, + GmpModifyReportFormatTestMixin, + GmpVerifyReportFormatTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteReportFormatTestCase( + GmpDeleteReportFormatTestMixin, GMPTestCase +): + pass + + +class GMPGetReportFormatTestCase(GmpGetReportFormatTestMixin, GMPTestCase): + pass + + +class GMPGetReportFormatsTestCase(GmpGetReportFormatsTestMixin, GMPTestCase): + pass + + +class GMPCloneReportFormatTestCase(GmpCloneReportFormatTestMixin, GMPTestCase): + pass + + +class GMPImportReportFormatTestCase( + GmpImportReportFormatTestMixin, GMPTestCase +): + pass + + +class GMPModifyReportFormatTestCase( + GmpModifyReportFormatTestMixin, GMPTestCase +): + pass + + +class GMPVerifyReportFormatTestCase( + GmpVerifyReportFormatTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/entities/test_reports.py b/tests/protocols/gmpv227/entities/test_reports.py new file mode 100644 index 00000000..0b00b951 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_reports.py @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv227 import GMPTestCase +from ...gmpv226.entities.reports import ( + GmpDeleteReportTestMixin, + GmpGetReportsTestMixin, + GmpGetReportTestMixin, + GmpImportReportTestMixin, +) + + +class GMPDeleteReportTestCase(GmpDeleteReportTestMixin, GMPTestCase): + pass + + +class GMPGetReportTestCase(GmpGetReportTestMixin, GMPTestCase): + pass + + +class GMPGetReportsTestCase(GmpGetReportsTestMixin, GMPTestCase): + pass + + +class GMPImportReportTestCase(GmpImportReportTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_resource_names.py b/tests/protocols/gmpv227/entities/test_resource_names.py new file mode 100644 index 00000000..b291c34f --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_resource_names.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv227 import GMPTestCase +from ...gmpv226.entities.resourcenames import ( + GmpGetResourceNamesListTestMixin, + GmpGetResourceNameTestMixin, +) + + +class GMPGetResourceNamesListTestCase( + GmpGetResourceNamesListTestMixin, GMPTestCase +): + pass + + +class GMPGetResourceNameTestCase(GmpGetResourceNameTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_results.py b/tests/protocols/gmpv227/entities/test_results.py new file mode 100644 index 00000000..a2d0e342 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_results.py @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.results import ( + GmpGetResultsTestMixin, + GmpGetResultTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPGetResultTestCase(GmpGetResultTestMixin, GMPTestCase): + pass + + +class GMPGetResultsTestCase(GmpGetResultsTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_roles.py b/tests/protocols/gmpv227/entities/test_roles.py new file mode 100644 index 00000000..3480a85a --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_roles.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.roles import ( + GmpCloneRoleTestMixin, + GmpCreateRoleTestMixin, + GmpDeleteRoleTestMixin, + GmpGetRolesTestMixin, + GmpGetRoleTestMixin, + GmpModifyRoleTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteRoleTestCase(GmpDeleteRoleTestMixin, GMPTestCase): + pass + + +class GMPGetRoleTestCase(GmpGetRoleTestMixin, GMPTestCase): + pass + + +class GMPGetRolesTestCase(GmpGetRolesTestMixin, GMPTestCase): + pass + + +class GMPCloneRoleTestCase(GmpCloneRoleTestMixin, GMPTestCase): + pass + + +class GMPCreateRoleTestCase(GmpCreateRoleTestMixin, GMPTestCase): + pass + + +class GMPModifyRoleTestCase(GmpModifyRoleTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_scan_configs.py b/tests/protocols/gmpv227/entities/test_scan_configs.py new file mode 100644 index 00000000..236d21c7 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_scan_configs.py @@ -0,0 +1,80 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.scan_configs import ( + GmpCloneScanConfigTestMixin, + GmpCreateScanConfigTestMixin, + GmpDeleteScanConfigTestMixin, + GmpGetScanConfigsTestMixin, + GmpGetScanConfigTestMixin, + GmpImportScanConfigTestMixin, + GmpModifyScanConfigSetCommentTestMixin, + GmpModifyScanConfigSetFamilySelectionTestMixin, + GmpModifyScanConfigSetNameTestMixin, + GmpModifyScanConfigSetNvtPreferenceTestMixin, + GmpModifyScanConfigSetNvtSelectionTestMixin, + GmpModifyScanConfigSetScannerPreferenceTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneScanConfigTestCase(GmpCloneScanConfigTestMixin, GMPTestCase): + pass + + +class GMPCreateScanConfigTestCase(GmpCreateScanConfigTestMixin, GMPTestCase): + pass + + +class GMPDeleteScanConfigTestCase(GmpDeleteScanConfigTestMixin, GMPTestCase): + pass + + +class GMPGetScanConfigTestCase(GmpGetScanConfigTestMixin, GMPTestCase): + pass + + +class GMPGetScanConfigsTestCase(GmpGetScanConfigsTestMixin, GMPTestCase): + pass + + +class GMPImportScanConfigTestCase(GmpImportScanConfigTestMixin, GMPTestCase): + pass + + +class GMPModifyScanConfigSetCommentTestCase( + GmpModifyScanConfigSetCommentTestMixin, GMPTestCase +): + pass + + +class GMPModifyScanConfigSetFamilySelectionTestCase( + GmpModifyScanConfigSetFamilySelectionTestMixin, GMPTestCase +): + pass + + +class GMPModifyScanConfigSetNvtSelectionTestCase( + GmpModifyScanConfigSetNvtSelectionTestMixin, GMPTestCase +): + pass + + +class GMPModifyScanConfigSetNameTestCase( + GmpModifyScanConfigSetNameTestMixin, GMPTestCase +): + pass + + +class GMPModifyScanConfigSetNvtPreferenceTestCase( + GmpModifyScanConfigSetNvtPreferenceTestMixin, GMPTestCase +): + pass + + +class GMPModifyScanConfigSetScannerPreferenceTestCase( + GmpModifyScanConfigSetScannerPreferenceTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/entities/test_scanners.py b/tests/protocols/gmpv227/entities/test_scanners.py new file mode 100644 index 00000000..49e7c024 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_scanners.py @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from tests.protocols.gmpv227.entities.scanners import ( + GmpCloneScannerTestMixin, + GmpCreateScannerTestMixin, + GmpDeleteScannerTestMixin, + GmpGetScannersTestMixin, + GmpGetScannerTestMixin, + GmpModifyScannerTestMixin, +) +from tests.protocols.gmpv227 import GMPTestCase + + +class GMPDeleteScannerTestCase(GmpDeleteScannerTestMixin, GMPTestCase): + pass + + +class GMPGetScannerTestCase(GmpGetScannerTestMixin, GMPTestCase): + pass + + +class GMPGetScannersTestCase(GmpGetScannersTestMixin, GMPTestCase): + pass + + +class GMPCloneScannerTestCase(GmpCloneScannerTestMixin, GMPTestCase): + pass + + +class GMPCreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): + pass + + +class GMPModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): + pass \ No newline at end of file diff --git a/tests/protocols/gmpv227/entities/test_schedules.py b/tests/protocols/gmpv227/entities/test_schedules.py new file mode 100644 index 00000000..bc056bcd --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_schedules.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.schedules import ( + GmpCloneScheduleTestMixin, + GmpCreateScheduleTestMixin, + GmpDeleteScheduleTestMixin, + GmpGetSchedulesTestMixin, + GmpGetScheduleTestMixin, + GmpModifyScheduleTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteScheduleTestCase(GmpDeleteScheduleTestMixin, GMPTestCase): + pass + + +class GMPGetScheduleTestCase(GmpGetScheduleTestMixin, GMPTestCase): + pass + + +class GMPGetSchedulesTestCase(GmpGetSchedulesTestMixin, GMPTestCase): + pass + + +class GMPCloneScheduleTestCase(GmpCloneScheduleTestMixin, GMPTestCase): + pass + + +class GMPCreateScheduleTestCase(GmpCreateScheduleTestMixin, GMPTestCase): + pass + + +class GMPModifyScheduleTestCase(GmpModifyScheduleTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_secinfo.py b/tests/protocols/gmpv227/entities/test_secinfo.py new file mode 100644 index 00000000..2dc29eae --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_secinfo.py @@ -0,0 +1,83 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.secinfo import ( + GmpGetCertBundListTestMixin, + GmpGetCertBundTestMixin, + GmpGetCpeListTestMixin, + GmpGetCpeTestMixin, + GmpGetCveListTestMixin, + GmpGetCveTestMixin, + GmpGetDfnCertListTestMixin, + GmpGetDfnCertTestMixin, + GmpGetInfoListTestMixin, + GmpGetInfoTestMixin, + GmpGetNvtFamiliesTestMixin, + GmpGetNvtListTestMixin, + GmpGetNvtTestMixin, + GmpGetScanConfigNvtsTestMixin, + GmpGetScanConfigNvtTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPGetCertBundTestCase(GmpGetCertBundTestMixin, GMPTestCase): + pass + + +class GMPGetCpeTestCase(GmpGetCpeTestMixin, GMPTestCase): + pass + + +class GMPGetCveTestCase(GmpGetCveTestMixin, GMPTestCase): + pass + + +class GMPGetDfnCertCase(GmpGetDfnCertTestMixin, GMPTestCase): + pass + + +class GMPGetInfoListTestCase(GmpGetInfoListTestMixin, GMPTestCase): + pass + + +class GMPGetInfoTestCase(GmpGetInfoTestMixin, GMPTestCase): + pass + + +class GMPGetNvtTestCase(GmpGetNvtTestMixin, GMPTestCase): + pass + + +class GMPGetScanConfigNvtTestCase(GmpGetScanConfigNvtTestMixin, GMPTestCase): + pass + + +class GMPGetNvtFamiliesTestCase(GmpGetNvtFamiliesTestMixin, GMPTestCase): + pass + + +class GMPGetScanConfigNvtsTestCase(GmpGetScanConfigNvtsTestMixin, GMPTestCase): + pass + + +class GMPGetCertBundListTestCase(GmpGetCertBundListTestMixin, GMPTestCase): + pass + + +class GMPGetCpeListTestCase(GmpGetCpeListTestMixin, GMPTestCase): + pass + + +class GMPGetCveListTestCase(GmpGetCveListTestMixin, GMPTestCase): + pass + + +class GMPGetDfnCertListCase(GmpGetDfnCertListTestMixin, GMPTestCase): + pass + + +class GMPGetNvtListTestCase(GmpGetNvtListTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_tags.py b/tests/protocols/gmpv227/entities/test_tags.py new file mode 100644 index 00000000..6035d3e2 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_tags.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.tags import ( + GmpCloneTagTestMixin, + GmpCreateTagTestMixin, + GmpDeleteTagTestMixin, + GmpGetTagsTestMixin, + GmpGetTagTestMixin, + GmpModifyTagTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteTagTestCase(GmpDeleteTagTestMixin, GMPTestCase): + pass + + +class GMPGetTagTestCase(GmpGetTagTestMixin, GMPTestCase): + pass + + +class GMPGetTagsTestCase(GmpGetTagsTestMixin, GMPTestCase): + pass + + +class GMPCloneTagTestCase(GmpCloneTagTestMixin, GMPTestCase): + pass + + +class GMPCreateTagTestCase(GmpCreateTagTestMixin, GMPTestCase): + pass + + +class GMPModifyTagTestCase(GmpModifyTagTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_targets.py b/tests/protocols/gmpv227/entities/test_targets.py new file mode 100644 index 00000000..f8c3408f --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_targets.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.targets import ( + GmpCloneTargetTestMixin, + GmpCreateTargetTestMixin, + GmpDeleteTargetTestMixin, + GmpGetTargetsTestMixin, + GmpGetTargetTestMixin, + GmpModifyTargetTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneTargetTestCase(GmpCloneTargetTestMixin, GMPTestCase): + pass + + +class GMPCreateTargetTestCase(GmpCreateTargetTestMixin, GMPTestCase): + pass + + +class GMPDeleteTargetTestCase(GmpDeleteTargetTestMixin, GMPTestCase): + pass + + +class GMPGetTargetTestCase(GmpGetTargetTestMixin, GMPTestCase): + pass + + +class GMPGetTargetsTestCase(GmpGetTargetsTestMixin, GMPTestCase): + pass + + +class GMPModifyTargetTestCase(GmpModifyTargetTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_tasks.py b/tests/protocols/gmpv227/entities/test_tasks.py new file mode 100644 index 00000000..0ad450b2 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_tasks.py @@ -0,0 +1,65 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.tasks import ( + GmpCloneTaskTestMixin, + GmpCreateContainerTaskTestMixin, + GmpCreateTaskTestMixin, + GmpDeleteTaskTestMixin, + GmpGetTasksTestMixin, + GmpGetTaskTestMixin, + GmpModifyTaskTestMixin, + GmpMoveTaskTestMixin, + GmpResumeTaskTestMixin, + GmpStartTaskTestMixin, + GmpStopTaskTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneTaskTestCase(GmpCloneTaskTestMixin, GMPTestCase): + pass + + +class GMPCreateContainerTaskTestCase( + GmpCreateContainerTaskTestMixin, GMPTestCase +): + pass + + +class GMPCreateTaskTestCase(GmpCreateTaskTestMixin, GMPTestCase): + pass + + +class GMPDeleteTaskTestCase(GmpDeleteTaskTestMixin, GMPTestCase): + pass + + +class GMPGetTaskTestCase(GmpGetTaskTestMixin, GMPTestCase): + pass + + +class GMPGetTasksTestCase(GmpGetTasksTestMixin, GMPTestCase): + pass + + +class GMPModifyTaskTestCase(GmpModifyTaskTestMixin, GMPTestCase): + pass + + +class GMPMoveTaskTestCase(GmpMoveTaskTestMixin, GMPTestCase): + pass + + +class GMPResumeTaskTestCase(GmpResumeTaskTestMixin, GMPTestCase): + pass + + +class GMPStartTaskTestCase(GmpStartTaskTestMixin, GMPTestCase): + pass + + +class GMPStopTaskTestCase(GmpStopTaskTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_tickets.py b/tests/protocols/gmpv227/entities/test_tickets.py new file mode 100644 index 00000000..77cf9c34 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_tickets.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.tickets import ( + GmpCloneTicketTestMixin, + GmpCreateTicketTestMixin, + GmpDeleteTicketTestMixin, + GmpGetTicketsTestMixin, + GmpGetTicketTestMixin, + GmpModifyTicketTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteTicketTestCase(GmpDeleteTicketTestMixin, GMPTestCase): + pass + + +class GMPGetTicketTestCase(GmpGetTicketTestMixin, GMPTestCase): + pass + + +class GMPGetTicketsTestCase(GmpGetTicketsTestMixin, GMPTestCase): + pass + + +class GMPCloneTicketTestCase(GmpCloneTicketTestMixin, GMPTestCase): + pass + + +class GMPCreateTicketTestCase(GmpCreateTicketTestMixin, GMPTestCase): + pass + + +class GMPModifyTicketTestCase(GmpModifyTicketTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_tls_certificates.py b/tests/protocols/gmpv227/entities/test_tls_certificates.py new file mode 100644 index 00000000..9e6c9072 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_tls_certificates.py @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.tls_certificates import ( + GmpCloneTLSCertificateTestMixin, + GmpCreateTLSCertificateTestMixin, + GmpDeleteTLSCertificateTestMixin, + GmpGetTLSCertificatesTestMixin, + GmpGetTLSCertificateTestMixin, + GmpModifyTLSCertificateTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneTLSCertificateTestCase( + GmpCloneTLSCertificateTestMixin, GMPTestCase +): + pass + + +class GMPCreateTLSCertificateTestCase( + GmpCreateTLSCertificateTestMixin, GMPTestCase +): + pass + + +class GMPDeleteTLSCertificateTestCase( + GmpDeleteTLSCertificateTestMixin, GMPTestCase +): + pass + + +class GMPGetTLSCertificateTestCase(GmpGetTLSCertificateTestMixin, GMPTestCase): + pass + + +class GMPGetTLSCertificatesTestCase( + GmpGetTLSCertificatesTestMixin, GMPTestCase +): + pass + + +class GMPModifyTLSCertificateTestCase( + GmpModifyTLSCertificateTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/entities/test_users.py b/tests/protocols/gmpv227/entities/test_users.py new file mode 100644 index 00000000..8ea68acc --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_users.py @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.users import ( + GmpCloneUserTestMixin, + GmpCreateUserTestMixin, + GmpDeleteUserTestMixin, + GmpGetUsersTestMixin, + GmpGetUserTestMixin, + GmpModifyUserTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPCloneUserTestCase(GmpCloneUserTestMixin, GMPTestCase): + pass + + +class GMPCreateUserTestCase(GmpCreateUserTestMixin, GMPTestCase): + pass + + +class GMPDeleteUserTestCase(GmpDeleteUserTestMixin, GMPTestCase): + pass + + +class GMPGetUserTestCase(GmpGetUserTestMixin, GMPTestCase): + pass + + +class GMPGetUsersTestCase(GmpGetUsersTestMixin, GMPTestCase): + pass + + +class GMPModifyUserTestCase(GmpModifyUserTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_vulnerabilities.py b/tests/protocols/gmpv227/entities/test_vulnerabilities.py new file mode 100644 index 00000000..d9bc0bd5 --- /dev/null +++ b/tests/protocols/gmpv227/entities/test_vulnerabilities.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv224.entities.vulnerabilities import ( + GmpGetVulnerabilitiesTestMixin, + GmpGetVulnerabilityTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPGetVulnerabilityTestCase(GmpGetVulnerabilityTestMixin, GMPTestCase): + pass + + +class GMPGetVulnerabilitiesTestCase( + GmpGetVulnerabilitiesTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv227/enums/__init__.py b/tests/protocols/gmpv227/enums/__init__.py new file mode 100644 index 00000000..baae7654 --- /dev/null +++ b/tests/protocols/gmpv227/enums/__init__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# diff --git a/tests/protocols/gmpv227/enums/test_aggregate_statistic.py b/tests/protocols/gmpv227/enums/test_aggregate_statistic.py new file mode 100644 index 00000000..a5e4f90e --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_aggregate_statistic.py @@ -0,0 +1,57 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import AggregateStatistic + + +class GetAggregateStatisticFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + AggregateStatistic.from_string("foo") + + def test_none_or_empty(self): + ct = AggregateStatistic.from_string(None) + self.assertIsNone(ct) + ct = AggregateStatistic.from_string("") + self.assertIsNone(ct) + + def test_count(self): + ct = AggregateStatistic.from_string("count") + self.assertEqual(ct, AggregateStatistic.COUNT) + + def test_c_count(self): + ct = AggregateStatistic.from_string("c_count") + self.assertEqual(ct, AggregateStatistic.C_COUNT) + + def test_c_sum(self): + ct = AggregateStatistic.from_string("c_sum") + self.assertEqual(ct, AggregateStatistic.C_SUM) + + def test_max(self): + ct = AggregateStatistic.from_string("max") + self.assertEqual(ct, AggregateStatistic.MAX) + + def test_mean(self): + ct = AggregateStatistic.from_string("mean") + self.assertEqual(ct, AggregateStatistic.MEAN) + + def test_min(self): + ct = AggregateStatistic.from_string("min") + self.assertEqual(ct, AggregateStatistic.MIN) + + def test_sum(self): + ct = AggregateStatistic.from_string("sum") + self.assertEqual(ct, AggregateStatistic.SUM) + + def test_text(self): + ct = AggregateStatistic.from_string("text") + self.assertEqual(ct, AggregateStatistic.TEXT) + + def test_value(self): + ct = AggregateStatistic.from_string("value") + self.assertEqual(ct, AggregateStatistic.VALUE) diff --git a/tests/protocols/gmpv227/enums/test_alert_condition.py b/tests/protocols/gmpv227/enums/test_alert_condition.py new file mode 100644 index 00000000..1552d7c8 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_alert_condition.py @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import AlertCondition + + +class GetAlertConditionFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + AlertCondition.from_string("foo") + + def test_none_or_empty(self): + ct = AlertCondition.from_string(None) + self.assertIsNone(ct) + ct = AlertCondition.from_string("") + self.assertIsNone(ct) + + def test_always(self): + ct = AlertCondition.from_string("always") + self.assertEqual(ct, AlertCondition.ALWAYS) + + def test_filter_count_at_least(self): + ct = AlertCondition.from_string("filter count at least") + self.assertEqual(ct, AlertCondition.FILTER_COUNT_AT_LEAST) + + def test_filter_count_changed(self): + ct = AlertCondition.from_string("filter count changed") + self.assertEqual(ct, AlertCondition.FILTER_COUNT_CHANGED) + + def test_severity_at_least(self): + ct = AlertCondition.from_string("severity at least") + self.assertEqual(ct, AlertCondition.SEVERITY_AT_LEAST) + + def test_severity_changed(self): + ct = AlertCondition.from_string("severity changed") + self.assertEqual(ct, AlertCondition.SEVERITY_CHANGED) + + def test_error(self): + ct = AlertCondition.from_string("error") + self.assertEqual(ct, AlertCondition.ERROR) diff --git a/tests/protocols/gmpv227/enums/test_alert_event.py b/tests/protocols/gmpv227/enums/test_alert_event.py new file mode 100644 index 00000000..4a273c1a --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_alert_event.py @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import AlertEvent + + +class GetAlertEventFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + AlertEvent.from_string("foo") + + def test_none_or_empty(self): + ct = AlertEvent.from_string(None) + self.assertIsNone(ct) + ct = AlertEvent.from_string("") + self.assertIsNone(ct) + + def test_task_run_status_changed(self): + ct = AlertEvent.from_string("Task run status changed") + self.assertEqual(ct, AlertEvent.TASK_RUN_STATUS_CHANGED) + + def test_new_secinfo_arrived(self): + ct = AlertEvent.from_string("New SecInfo arrived") + self.assertEqual(ct, AlertEvent.NEW_SECINFO_ARRIVED) + + def test_updated_secinfo_arrived(self): + ct = AlertEvent.from_string("Updated SecInfo arrived") + self.assertEqual(ct, AlertEvent.UPDATED_SECINFO_ARRIVED) + + def test_ticket_received(self): + ct = AlertEvent.from_string("ticket received") + self.assertEqual(ct, AlertEvent.TICKET_RECEIVED) + + def test_assigned_ticket_changed(self): + ct = AlertEvent.from_string("assigned ticket changed") + self.assertEqual(ct, AlertEvent.ASSIGNED_TICKET_CHANGED) + + def test_owned_ticket_changed(self): + ct = AlertEvent.from_string("owned ticket changed") + self.assertEqual(ct, AlertEvent.OWNED_TICKET_CHANGED) diff --git a/tests/protocols/gmpv227/enums/test_alert_method.py b/tests/protocols/gmpv227/enums/test_alert_method.py new file mode 100644 index 00000000..c1a46e35 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_alert_method.py @@ -0,0 +1,69 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import AlertMethod + + +class GetAlertMethodFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + AlertMethod.from_string("foo") + + def test_none_or_empty(self): + ct = AlertMethod.from_string(None) + self.assertIsNone(ct) + ct = AlertMethod.from_string("") + self.assertIsNone(ct) + + def test_email(self): + ct = AlertMethod.from_string("email") + self.assertEqual(ct, AlertMethod.EMAIL) + + def test_scp(self): + ct = AlertMethod.from_string("scp") + self.assertEqual(ct, AlertMethod.SCP) + + def test_send(self): + ct = AlertMethod.from_string("send") + self.assertEqual(ct, AlertMethod.SEND) + + def test_smb(self): + ct = AlertMethod.from_string("smb") + self.assertEqual(ct, AlertMethod.SMB) + + def test_snmp(self): + ct = AlertMethod.from_string("snmp") + self.assertEqual(ct, AlertMethod.SNMP) + + def test_syslog(self): + ct = AlertMethod.from_string("syslog") + self.assertEqual(ct, AlertMethod.SYSLOG) + + def test_http_get(self): + ct = AlertMethod.from_string("HTTP Get") + self.assertEqual(ct, AlertMethod.HTTP_GET) + + def test_start_task(self): + ct = AlertMethod.from_string("Start Task") + self.assertEqual(ct, AlertMethod.START_TASK) + + def test_sourcefire_connector(self): + ct = AlertMethod.from_string("sourcefire Connector") + self.assertEqual(ct, AlertMethod.SOURCEFIRE_CONNECTOR) + + def test_verinice_connector(self): + ct = AlertMethod.from_string("verinice Connector") + self.assertEqual(ct, AlertMethod.VERINICE_CONNECTOR) + + def test_tippingpoint_sms(self): + ct = AlertMethod.from_string("Tippingpoint SMS") + self.assertEqual(ct, AlertMethod.TIPPINGPOINT_SMS) + + def test_alemba_vfire(self): + ct = AlertMethod.from_string("Alemba vFire") + self.assertEqual(ct, AlertMethod.ALEMBA_VFIRE) diff --git a/tests/protocols/gmpv227/enums/test_alive_test.py b/tests/protocols/gmpv227/enums/test_alive_test.py new file mode 100644 index 00000000..ad15c7e1 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_alive_test.py @@ -0,0 +1,61 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import AliveTest + + +class GetAliveTestFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + AliveTest.from_string("foo") + + def test_none_or_empty(self): + ct = AliveTest.from_string(None) + self.assertIsNone(ct) + ct = AliveTest.from_string("") + self.assertIsNone(ct) + + def test_scan_config_default(self): + ct = AliveTest.from_string("Scan Config Default") + self.assertEqual(ct, AliveTest.SCAN_CONFIG_DEFAULT) + + def test_icmp_ping(self): + ct = AliveTest.from_string("ICMP Ping") + self.assertEqual(ct, AliveTest.ICMP_PING) + + def test_tcp_ack_service_ping(self): + ct = AliveTest.from_string("TCP-ACK Service Ping") + self.assertEqual(ct, AliveTest.TCP_ACK_SERVICE_PING) + + def test_tcp_sync_service_ping(self): + ct = AliveTest.from_string("TCP-SYN Service Ping") + self.assertEqual(ct, AliveTest.TCP_SYN_SERVICE_PING) + + def test_arp_ping(self): + ct = AliveTest.from_string("ARP Ping") + self.assertEqual(ct, AliveTest.ARP_PING) + + def test_icmp_and_tcp_ack_service_ping(self): + ct = AliveTest.from_string("ICMP & TCP-ACK Service Ping") + self.assertEqual(ct, AliveTest.ICMP_AND_TCP_ACK_SERVICE_PING) + + def test_icmp_and_arp_ping(self): + ct = AliveTest.from_string("ICMP & ARP Ping") + self.assertEqual(ct, AliveTest.ICMP_AND_ARP_PING) + + def test_tcp_ack_service_and_arp_ping(self): + ct = AliveTest.from_string("TCP-ACK Service & ARP Ping") + self.assertEqual(ct, AliveTest.TCP_ACK_SERVICE_AND_ARP_PING) + + def test_icmp_tcp_ack_service_and_arp_ping(self): + ct = AliveTest.from_string("ICMP, TCP-ACK Service & ARP Ping") + self.assertEqual(ct, AliveTest.ICMP_TCP_ACK_SERVICE_AND_ARP_PING) + + def test_consider_alive(self): + ct = AliveTest.from_string("Consider Alive") + self.assertEqual(ct, AliveTest.CONSIDER_ALIVE) diff --git a/tests/protocols/gmpv227/enums/test_credential_format.py b/tests/protocols/gmpv227/enums/test_credential_format.py new file mode 100644 index 00000000..125ec9f7 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_credential_format.py @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import CredentialFormat + + +class GetCredentialFormatFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + CredentialFormat.from_string("foo") + + def test_none_or_empty(self): + ct = CredentialFormat.from_string(None) + self.assertIsNone(ct) + ct = CredentialFormat.from_string("") + self.assertIsNone(ct) + + def test_key(self): + ct = CredentialFormat.from_string("key") + self.assertEqual(ct, CredentialFormat.KEY) + + def test_rpm(self): + ct = CredentialFormat.from_string("rpm") + self.assertEqual(ct, CredentialFormat.RPM) + + def test_deb(self): + ct = CredentialFormat.from_string("deb") + self.assertEqual(ct, CredentialFormat.DEB) + + def test_exe(self): + ct = CredentialFormat.from_string("exe") + self.assertEqual(ct, CredentialFormat.EXE) + + def test_pem(self): + ct = CredentialFormat.from_string("pem") + self.assertEqual(ct, CredentialFormat.PEM) diff --git a/tests/protocols/gmpv227/enums/test_credential_type.py b/tests/protocols/gmpv227/enums/test_credential_type.py new file mode 100644 index 00000000..92cb62a9 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_credential_type.py @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import CredentialType + + +class GetCredentialTypeFromStringTestCase(unittest.TestCase): + def test_invalid_type(self): + with self.assertRaises(InvalidArgument): + CredentialType.from_string("foo") + + def test_none_or_empty_type(self): + ct = CredentialType.from_string(None) + self.assertIsNone(ct) + ct = CredentialType.from_string("") + self.assertIsNone(ct) + + def test_client_certificate(self): + ct = CredentialType.from_string("client_certificate") + self.assertEqual(ct, CredentialType.CLIENT_CERTIFICATE) + + def test_snmp(self): + ct = CredentialType.from_string("snmp") + self.assertEqual(ct, CredentialType.SNMP) + + def test_username_password(self): + ct = CredentialType.from_string("username_password") + self.assertEqual(ct, CredentialType.USERNAME_PASSWORD) + + def test_username_ssh_key(self): + ct = CredentialType.from_string("username_ssh_key") + self.assertEqual(ct, CredentialType.USERNAME_SSH_KEY) + + def test_smime_certificate(self): + ct = CredentialType.from_string("smime_certificate") + self.assertEqual(ct, CredentialType.SMIME_CERTIFICATE) + + def test_pgp_encryption_key(self): + ct = CredentialType.from_string("pgp_encryption_key") + self.assertEqual(ct, CredentialType.PGP_ENCRYPTION_KEY) + + def test_password_only(self): + ct = CredentialType.from_string("password_only") + self.assertEqual(ct, CredentialType.PASSWORD_ONLY) diff --git a/tests/protocols/gmpv227/enums/test_entity_type.py b/tests/protocols/gmpv227/enums/test_entity_type.py new file mode 100644 index 00000000..d3b80621 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_entity_type.py @@ -0,0 +1,166 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import EntityType + + +class GetEntityTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + EntityType.from_string("foo") + + def test_none_or_empty(self): + ct = EntityType.from_string(None) + self.assertIsNone(ct) + ct = EntityType.from_string("") + self.assertIsNone(ct) + + def test_audit(self): + ct = EntityType.from_string("audit") + self.assertEqual(ct, EntityType.AUDIT) + + def test_alert(self): + ct = EntityType.from_string("alert") + self.assertEqual(ct, EntityType.ALERT) + + def test_asset(self): + ct = EntityType.from_string("asset") + self.assertEqual(ct, EntityType.ASSET) + + def test_cert_bund_adv(self): + ct = EntityType.from_string("cert_bund_adv") + self.assertEqual(ct, EntityType.CERT_BUND_ADV) + + def test_cpe(self): + ct = EntityType.from_string("cpe") + self.assertEqual(ct, EntityType.CPE) + + def test_credential(self): + ct = EntityType.from_string("credential") + self.assertEqual(ct, EntityType.CREDENTIAL) + + def test_dfn_cert_adv(self): + ct = EntityType.from_string("dfn_cert_adv") + self.assertEqual(ct, EntityType.DFN_CERT_ADV) + + def test_filter(self): + ct = EntityType.from_string("filter") + self.assertEqual(ct, EntityType.FILTER) + + def test_group(self): + ct = EntityType.from_string("group") + self.assertEqual(ct, EntityType.GROUP) + + def test_host(self): + ct = EntityType.from_string("host") + self.assertEqual(ct, EntityType.HOST) + + def test_info(self): + ct = EntityType.from_string("info") + self.assertEqual(ct, EntityType.INFO) + + def test_note(self): + ct = EntityType.from_string("note") + self.assertEqual(ct, EntityType.NOTE) + + def test_nvt(self): + ct = EntityType.from_string("nvt") + self.assertEqual(ct, EntityType.NVT) + + def test_operating_system(self): + ct = EntityType.from_string("os") + self.assertEqual(ct, EntityType.OPERATING_SYSTEM) + + ct = EntityType.from_string("operating_system") + self.assertEqual(ct, EntityType.OPERATING_SYSTEM) + + def test_ovaldef(self): + ct = EntityType.from_string("ovaldef") + self.assertEqual(ct, EntityType.OVALDEF) + + def test_override(self): + ct = EntityType.from_string("override") + self.assertEqual(ct, EntityType.OVERRIDE) + + def test_permission(self): + ct = EntityType.from_string("permission") + self.assertEqual(ct, EntityType.PERMISSION) + + def test_policy(self): + ct = EntityType.from_string("policy") + self.assertEqual(ct, EntityType.POLICY) + + def test_port_list(self): + ct = EntityType.from_string("port_list") + self.assertEqual(ct, EntityType.PORT_LIST) + + def test_report(self): + ct = EntityType.from_string("report") + self.assertEqual(ct, EntityType.REPORT) + + def test_report_format(self): + ct = EntityType.from_string("report_format") + self.assertEqual(ct, EntityType.REPORT_FORMAT) + + def test_result(self): + ct = EntityType.from_string("result") + self.assertEqual(ct, EntityType.RESULT) + + def test_role(self): + ct = EntityType.from_string("role") + self.assertEqual(ct, EntityType.ROLE) + + def test_scan_config(self): + ct = EntityType.from_string("config") + self.assertEqual(ct, EntityType.SCAN_CONFIG) + + ct = EntityType.from_string("scan_config") + self.assertEqual(ct, EntityType.SCAN_CONFIG) + + def test_scanner(self): + ct = EntityType.from_string("scanner") + self.assertEqual(ct, EntityType.SCANNER) + + def test_schedule(self): + ct = EntityType.from_string("schedule") + self.assertEqual(ct, EntityType.SCHEDULE) + + def test_tag(self): + ct = EntityType.from_string("tag") + self.assertEqual(ct, EntityType.TAG) + + def test_target(self): + ct = EntityType.from_string("target") + self.assertEqual(ct, EntityType.TARGET) + + def test_task(self): + ct = EntityType.from_string("task") + self.assertEqual(ct, EntityType.TASK) + + def test_ticket(self): + ct = EntityType.from_string("ticket") + self.assertEqual(ct, EntityType.TICKET) + + def test_tls_certificate(self): + ft = EntityType.from_string("tls_certificate") + self.assertEqual(ft, EntityType.TLS_CERTIFICATE) + + def test_user(self): + ct = EntityType.from_string("user") + self.assertEqual(ct, EntityType.USER) + + def test_vulnerability(self): + ct = EntityType.from_string("vuln") + self.assertEqual(ct, EntityType.VULNERABILITY) + + ct = EntityType.from_string("vulnerability") + self.assertEqual(ct, EntityType.VULNERABILITY) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/protocols/gmpv227/enums/test_feed_type.py b/tests/protocols/gmpv227/enums/test_feed_type.py new file mode 100644 index 00000000..d8847353 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_feed_type.py @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import FeedType + + +class GetFeedTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + FeedType.from_string("foo") + + def test_none_or_empty(self): + ct = FeedType.from_string(None) + self.assertIsNone(ct) + ct = FeedType.from_string("") + self.assertIsNone(ct) + + def test_nvt(self): + ct = FeedType.from_string("nvt") + self.assertEqual(ct, FeedType.NVT) + + def test_cert(self): + ct = FeedType.from_string("cert") + self.assertEqual(ct, FeedType.CERT) + + def test_scap(self): + ct = FeedType.from_string("scap") + self.assertEqual(ct, FeedType.SCAP) + + def test_gvmd_data(self): + ct = FeedType.from_string("gvmd_data") + self.assertEqual(ct, FeedType.GVMD_DATA) diff --git a/tests/protocols/gmpv227/enums/test_filter_type.py b/tests/protocols/gmpv227/enums/test_filter_type.py new file mode 100644 index 00000000..8f9037f9 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_filter_type.py @@ -0,0 +1,146 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import FilterType + + +class GetFilterTypeFomStringTestCase(unittest.TestCase): + def test_filter_type_alert(self): + ft = FilterType.from_string("alert") + self.assertEqual(ft, FilterType.ALERT) + + def test_filter_type_asset(self): + ft = FilterType.from_string("asset") + self.assertEqual(ft, FilterType.ASSET) + + def test_filter_type_credential(self): + ft = FilterType.from_string("credential") + self.assertEqual(ft, FilterType.CREDENTIAL) + + def test_filter_type_filter(self): + ft = FilterType.from_string("filter") + self.assertEqual(ft, FilterType.FILTER) + + def test_filter_type_group(self): + ft = FilterType.from_string("group") + self.assertEqual(ft, FilterType.GROUP) + + def test_filter_type_host(self): + ft = FilterType.from_string("host") + self.assertEqual(ft, FilterType.HOST) + + def test_filter_type_note(self): + ft = FilterType.from_string("note") + self.assertEqual(ft, FilterType.NOTE) + + def test_filter_type_override(self): + ft = FilterType.from_string("override") + self.assertEqual(ft, FilterType.OVERRIDE) + + def test_filter_type_permission(self): + ft = FilterType.from_string("permission") + self.assertEqual(ft, FilterType.PERMISSION) + + def test_filter_type_port_list(self): + ft = FilterType.from_string("port_list") + self.assertEqual(ft, FilterType.PORT_LIST) + + def test_filter_type_report(self): + ft = FilterType.from_string("report") + self.assertEqual(ft, FilterType.REPORT) + + def test_filter_type_report_format(self): + ft = FilterType.from_string("report_format") + self.assertEqual(ft, FilterType.REPORT_FORMAT) + + def test_filter_type_result(self): + ft = FilterType.from_string("result") + self.assertEqual(ft, FilterType.RESULT) + + def test_filter_type_role(self): + ft = FilterType.from_string("role") + self.assertEqual(ft, FilterType.ROLE) + + def test_filter_type_schedule(self): + ft = FilterType.from_string("schedule") + self.assertEqual(ft, FilterType.SCHEDULE) + + def test_filter_type_secinfo(self): + ft = FilterType.from_string("secinfo") + self.assertEqual(ft, FilterType.ALL_SECINFO) + + def test_filter_type_all_secinfo(self): + ft = FilterType.from_string("all_secinfo") + self.assertEqual(ft, FilterType.ALL_SECINFO) + + def test_filter_type_tag(self): + ft = FilterType.from_string("tag") + self.assertEqual(ft, FilterType.TAG) + + def test_filter_type_task(self): + ft = FilterType.from_string("task") + self.assertEqual(ft, FilterType.TASK) + + def test_filter_type_target(self): + ft = FilterType.from_string("target") + self.assertEqual(ft, FilterType.TARGET) + + def test_filter_type_ticket(self): + ft = FilterType.from_string("ticket") + self.assertEqual(ft, FilterType.TICKET) + + def test_filter_type_tls_certificate(self): + ft = FilterType.from_string("tls_certificate") + self.assertEqual(ft, FilterType.TLS_CERTIFICATE) + + def test_filter_type_operating_system(self): + ft = FilterType.from_string("operating_system") + self.assertEqual(ft, FilterType.OPERATING_SYSTEM) + + def test_filter_type_user(self): + ft = FilterType.from_string("user") + self.assertEqual(ft, FilterType.USER) + + def test_filter_type_vuln(self): + ft = FilterType.from_string("vuln") + self.assertEqual(ft, FilterType.VULNERABILITY) + + def test_filter_type_vulnerability(self): + ft = FilterType.from_string("vulnerability") + self.assertEqual(ft, FilterType.VULNERABILITY) + + def test_filter_type_config(self): + ft = FilterType.from_string("config") + self.assertEqual(ft, FilterType.SCAN_CONFIG) + + def test_filter_type_scan_config(self): + ft = FilterType.from_string("scan_config") + self.assertEqual(ft, FilterType.SCAN_CONFIG) + + def test_filter_type_os(self): + ft = FilterType.from_string("os") + self.assertEqual(ft, FilterType.OPERATING_SYSTEM) + + def test_filter_type_report_config(self): + ft = FilterType.from_string("report_config") + self.assertEqual(ft, FilterType.REPORT_CONFIG) + + def test_filter_type_audit_report(self): + ft = FilterType.from_string("audit_report") + self.assertEqual(ft, FilterType.AUDIT_REPORT) + + def test_invalid_filter_type(self): + with self.assertRaises(InvalidArgument): + FilterType.from_string("foo") + + def test_non_or_empty_filter_type(self): + ft = FilterType.from_string(None) + self.assertIsNone(ft) + + ft = FilterType.from_string("") + self.assertIsNone(ft) diff --git a/tests/protocols/gmpv227/enums/test_help_format.py b/tests/protocols/gmpv227/enums/test_help_format.py new file mode 100644 index 00000000..ba74db75 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_help_format.py @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import HelpFormat + + +class GetHelpFormatFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + HelpFormat.from_string("foo") + + def test_none_or_empty(self): + ct = HelpFormat.from_string(None) + self.assertIsNone(ct) + ct = HelpFormat.from_string("") + self.assertIsNone(ct) + + def test_task_run_status_changed(self): + ct = HelpFormat.from_string("HtMl") + self.assertEqual(ct, HelpFormat.HTML) + + def test_new_secinfo_arrived(self): + ct = HelpFormat.from_string("rNc") + self.assertEqual(ct, HelpFormat.RNC) + + def test_updated_secinfo_arrived(self): + ct = HelpFormat.from_string("tExT") + self.assertEqual(ct, HelpFormat.TEXT) + + def test_ticket_received(self): + ct = HelpFormat.from_string("XmL") + self.assertEqual(ct, HelpFormat.XML) diff --git a/tests/protocols/gmpv227/enums/test_hosts_ordering.py b/tests/protocols/gmpv227/enums/test_hosts_ordering.py new file mode 100644 index 00000000..79557e43 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_hosts_ordering.py @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import HostsOrdering + + +class GetHostsOrderingFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + HostsOrdering.from_string("foo") + + def test_none_or_empty(self): + ct = HostsOrdering.from_string(None) + self.assertIsNone(ct) + ct = HostsOrdering.from_string("") + self.assertIsNone(ct) + + def test_sequential(self): + ct = HostsOrdering.from_string("sequential") + self.assertEqual(ct, HostsOrdering.SEQUENTIAL) + + def test_random(self): + ct = HostsOrdering.from_string("random") + self.assertEqual(ct, HostsOrdering.RANDOM) + + def test_reverse(self): + ct = HostsOrdering.from_string("reverse") + self.assertEqual(ct, HostsOrdering.REVERSE) diff --git a/tests/protocols/gmpv227/enums/test_info_type.py b/tests/protocols/gmpv227/enums/test_info_type.py new file mode 100644 index 00000000..030765ae --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_info_type.py @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import InfoType + + +class GetInfoTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + InfoType.from_string("foo") + + def test_none_or_empty(self): + ct = InfoType.from_string(None) + self.assertIsNone(ct) + ct = InfoType.from_string("") + self.assertIsNone(ct) + + def test_cert_bund_adv(self): + ct = InfoType.from_string("cert_bund_adv") + self.assertEqual(ct, InfoType.CERT_BUND_ADV) + + def test_cpe(self): + ct = InfoType.from_string("cpe") + self.assertEqual(ct, InfoType.CPE) + + def test_cve(self): + ct = InfoType.from_string("cve") + self.assertEqual(ct, InfoType.CVE) + + def test_dfn_cert_adv(self): + ct = InfoType.from_string("dfn_cert_adv") + self.assertEqual(ct, InfoType.DFN_CERT_ADV) + + def test_nvt(self): + ct = InfoType.from_string("nvt") + self.assertEqual(ct, InfoType.NVT) + + def test_ovaldef(self): + ct = InfoType.from_string("ovaldef") + self.assertEqual(ct, InfoType.OVALDEF) + + def test_allinfo(self): + with self.assertRaises(InvalidArgument): + InfoType.from_string("allinfo") diff --git a/tests/protocols/gmpv227/enums/test_permission_subject_type.py b/tests/protocols/gmpv227/enums/test_permission_subject_type.py new file mode 100644 index 00000000..e303cad7 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_permission_subject_type.py @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import PermissionSubjectType + + +class GetPermissionSubjectTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + PermissionSubjectType.from_string("foo") + + def test_none_or_empty(self): + ct = PermissionSubjectType.from_string(None) + self.assertIsNone(ct) + ct = PermissionSubjectType.from_string("") + self.assertIsNone(ct) + + def test_user(self): + ct = PermissionSubjectType.from_string("user") + self.assertEqual(ct, PermissionSubjectType.USER) + + def test_role(self): + ct = PermissionSubjectType.from_string("role") + self.assertEqual(ct, PermissionSubjectType.ROLE) + + def test_group(self): + ct = PermissionSubjectType.from_string("group") + self.assertEqual(ct, PermissionSubjectType.GROUP) diff --git a/tests/protocols/gmpv227/enums/test_port_range_type.py b/tests/protocols/gmpv227/enums/test_port_range_type.py new file mode 100644 index 00000000..ad4aef05 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_port_range_type.py @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import PortRangeType + + +class GetPortRangeTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + PortRangeType.from_string("foo") + + def test_none_or_empty(self): + ct = PortRangeType.from_string(None) + self.assertIsNone(ct) + ct = PortRangeType.from_string("") + self.assertIsNone(ct) + + def test_tcp(self): + ct = PortRangeType.from_string("tcp") + self.assertEqual(ct, PortRangeType.TCP) + + def test_udp(self): + ct = PortRangeType.from_string("udp") + self.assertEqual(ct, PortRangeType.UDP) diff --git a/tests/protocols/gmpv227/enums/test_report_format_type.py b/tests/protocols/gmpv227/enums/test_report_format_type.py new file mode 100644 index 00000000..083e208e --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_report_format_type.py @@ -0,0 +1,97 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import ReportFormatType + + +class GetPortRangeTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + ReportFormatType.from_string("foo") + + def test_none_or_empty(self): + ct = ReportFormatType.from_string(None) + self.assertIsNone(ct) + ct = ReportFormatType.from_string("") + self.assertIsNone(ct) + + def test_anonymous_pdf(self): + ct = ReportFormatType.from_string("anonymous xml") + self.assertEqual(ct, ReportFormatType.ANONYMOUS_XML) + + def test_arf(self): + ct = ReportFormatType.from_string("arf") + self.assertEqual(ct, ReportFormatType.ARF) + + def test_(self): + ct = ReportFormatType.from_string("cpe") + self.assertEqual(ct, ReportFormatType.CPE) + + def test_csv_hosts(self): + ct = ReportFormatType.from_string("csv hosts") + self.assertEqual(ct, ReportFormatType.CSV_HOSTS) + + def test_csv_results(self): + ct = ReportFormatType.from_string("csv results") + self.assertEqual(ct, ReportFormatType.CSV_RESULTS) + + def test_gcr_pdf(self): + ct = ReportFormatType.from_string("gcr pdf") + self.assertEqual(ct, ReportFormatType.GCR_PDF) + + def test_gsr_html(self): + ct = ReportFormatType.from_string("gsr html") + self.assertEqual(ct, ReportFormatType.GSR_HTML) + + def test_gsr_pdf(self): + ct = ReportFormatType.from_string("gsr pdf") + self.assertEqual(ct, ReportFormatType.GSR_PDF) + + def test_gxcr_pdf(self): + ct = ReportFormatType.from_string("gxcr pdf") + self.assertEqual(ct, ReportFormatType.GXCR_PDF) + + def test_gxr_pdf(self): + ct = ReportFormatType.from_string("gxr pdf") + self.assertEqual(ct, ReportFormatType.GXR_PDF) + + def test_itg(self): + ct = ReportFormatType.from_string("itg") + self.assertEqual(ct, ReportFormatType.ITG) + + def test_latex(self): + ct = ReportFormatType.from_string("latex") + self.assertEqual(ct, ReportFormatType.LATEX) + + def test_nbe(self): + ct = ReportFormatType.from_string("nbe") + self.assertEqual(ct, ReportFormatType.NBE) + + def test_pdf(self): + ct = ReportFormatType.from_string("pdf") + self.assertEqual(ct, ReportFormatType.PDF) + + def test_svg(self): + ct = ReportFormatType.from_string("svg") + self.assertEqual(ct, ReportFormatType.SVG) + + def test_txt(self): + ct = ReportFormatType.from_string("txt") + self.assertEqual(ct, ReportFormatType.TXT) + + def test_verinice_ism(self): + ct = ReportFormatType.from_string("verinice ism") + self.assertEqual(ct, ReportFormatType.VERINICE_ISM) + + def test_verinice_itg(self): + ct = ReportFormatType.from_string("verinice itg") + self.assertEqual(ct, ReportFormatType.VERINICE_ITG) + + def test_xml(self): + ct = ReportFormatType.from_string("xml") + self.assertEqual(ct, ReportFormatType.XML) diff --git a/tests/protocols/gmpv227/enums/test_resource_type.py b/tests/protocols/gmpv227/enums/test_resource_type.py new file mode 100644 index 00000000..5856fcb6 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_resource_type.py @@ -0,0 +1,133 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import ResourceType + + +class GetResourceTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + ResourceType.from_string("foo") + + def test_none_or_empty(self): + ct = ResourceType.from_string(None) + self.assertIsNone(ct) + ct = ResourceType.from_string("") + self.assertIsNone(ct) + + def test_alert(self): + ct = ResourceType.from_string("alert") + self.assertEqual(ct, ResourceType.ALERT) + + def test_cert_bund_adv(self): + ct = ResourceType.from_string("cert_bund_adv") + self.assertEqual(ct, ResourceType.CERT_BUND_ADV) + + def test_config(self): + ct = ResourceType.from_string("config") + self.assertEqual(ct, ResourceType.CONFIG) + + def test_cpe(self): + ct = ResourceType.from_string("cpe") + self.assertEqual(ct, ResourceType.CPE) + + def test_credential(self): + ct = ResourceType.from_string("credential") + self.assertEqual(ct, ResourceType.CREDENTIAL) + + def test_cve(self): + ct = ResourceType.from_string("cve") + self.assertEqual(ct, ResourceType.CVE) + + def test_dfn_cert_adv(self): + ct = ResourceType.from_string("dfn_cert_adv") + self.assertEqual(ct, ResourceType.DFN_CERT_ADV) + + def test_filter(self): + ct = ResourceType.from_string("filter") + self.assertEqual(ct, ResourceType.FILTER) + + def test_group(self): + ct = ResourceType.from_string("group") + self.assertEqual(ct, ResourceType.GROUP) + + def test_host(self): + ct = ResourceType.from_string("host") + self.assertEqual(ct, ResourceType.HOST) + + def test_note(self): + ct = ResourceType.from_string("note") + self.assertEqual(ct, ResourceType.NOTE) + + def test_nvt(self): + ct = ResourceType.from_string("nvt") + self.assertEqual(ct, ResourceType.NVT) + + def test_os(self): + ct = ResourceType.from_string("os") + self.assertEqual(ct, ResourceType.OS) + + def test_override(self): + ct = ResourceType.from_string("override") + self.assertEqual(ct, ResourceType.OVERRIDE) + + def test_permission(self): + ct = ResourceType.from_string("permission") + self.assertEqual(ct, ResourceType.PERMISSION) + + def test_port_list(self): + ct = ResourceType.from_string("port_list") + self.assertEqual(ct, ResourceType.PORT_LIST) + + def test_report_format(self): + ct = ResourceType.from_string("report_format") + self.assertEqual(ct, ResourceType.REPORT_FORMAT) + + def test_report(self): + ct = ResourceType.from_string("report") + self.assertEqual(ct, ResourceType.REPORT) + + def test_report_config(self): + ct = ResourceType.from_string("report_config") + self.assertEqual(ct, ResourceType.REPORT_CONFIG) + + def test_result(self): + ct = ResourceType.from_string("result") + self.assertEqual(ct, ResourceType.RESULT) + + def test_role(self): + ct = ResourceType.from_string("role") + self.assertEqual(ct, ResourceType.ROLE) + + def test_scanner(self): + ct = ResourceType.from_string("scanner") + self.assertEqual(ct, ResourceType.SCANNER) + + def test_schedule(self): + ct = ResourceType.from_string("schedule") + self.assertEqual(ct, ResourceType.SCHEDULE) + + def test_target(self): + ct = ResourceType.from_string("target") + self.assertEqual(ct, ResourceType.TARGET) + + def test_task(self): + ct = ResourceType.from_string("task") + self.assertEqual(ct, ResourceType.TASK) + + def test_tls_certificate(self): + ct = ResourceType.from_string("tls_certificate") + self.assertEqual(ct, ResourceType.TLS_CERTIFICATE) + + def test_user(self): + ct = ResourceType.from_string("user") + self.assertEqual(ct, ResourceType.USER) + + def test_allresources(self): + with self.assertRaises(InvalidArgument): + ResourceType.from_string("allresources") diff --git a/tests/protocols/gmpv227/enums/test_scanner_type.py b/tests/protocols/gmpv227/enums/test_scanner_type.py new file mode 100644 index 00000000..9ea4cce5 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_scanner_type.py @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v227 import ScannerType + + +class GetScannerTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + ScannerType.from_string("foo") + + def test_none_or_empty(self): + ct = ScannerType.from_string(None) + self.assertIsNone(ct) + ct = ScannerType.from_string("") + self.assertIsNone(ct) + + def test_openvas_scanner(self): + ct = ScannerType.from_string("2") + self.assertEqual(ct, ScannerType.OPENVAS_SCANNER_TYPE) + + ct = ScannerType.from_string("openvas") + self.assertEqual(ct, ScannerType.OPENVAS_SCANNER_TYPE) + + def test_cve_scanner(self): + ct = ScannerType.from_string("3") + self.assertEqual(ct, ScannerType.CVE_SCANNER_TYPE) + + ct = ScannerType.from_string("cve") + self.assertEqual(ct, ScannerType.CVE_SCANNER_TYPE) + + def test_gmp_scanner(self): + with self.assertRaises(InvalidArgument): + ScannerType.from_string("4") + + with self.assertRaises(InvalidArgument): + ScannerType.from_string("gmp") + + def test_greenbone_sensor_scanner(self): + ct = ScannerType.from_string("5") + self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) + + ct = ScannerType.from_string("greenbone") + self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) + + def test_openvasd_scanner(self): + ct = ScannerType.from_string("6") + self.assertEqual(ct, ScannerType.OPENVASD_SCANNER_TYPE) + + ct = ScannerType.from_string("openvasd") + self.assertEqual(ct, ScannerType.OPENVASD_SCANNER_TYPE) diff --git a/tests/protocols/gmpv227/enums/test_snmp_algorithms.py b/tests/protocols/gmpv227/enums/test_snmp_algorithms.py new file mode 100644 index 00000000..1aad8b4d --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_snmp_algorithms.py @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v226 import ( + SnmpAuthAlgorithm, + SnmpPrivacyAlgorithm, +) + + +class GetSnmpAuthAlgorithmFromStringTestCase(unittest.TestCase): + def test_invalid_status(self): + with self.assertRaises(InvalidArgument): + SnmpAuthAlgorithm.from_string("foo") + + def test_none_or_empty_type(self): + ts = SnmpAuthAlgorithm.from_string(None) + self.assertIsNone(ts) + ts = SnmpAuthAlgorithm.from_string("") + self.assertIsNone(ts) + + def test_sha1(self): + ts = SnmpAuthAlgorithm.from_string("sha1") + self.assertEqual(ts, SnmpAuthAlgorithm.SHA1) + + def test_md5(self): + ts = SnmpAuthAlgorithm.from_string("md5") + self.assertEqual(ts, SnmpAuthAlgorithm.MD5) + + +class GetSnmpPrivacyAlgorithmFromStringTestCase(unittest.TestCase): + def test_invalid_status(self): + with self.assertRaises(InvalidArgument): + SnmpPrivacyAlgorithm.from_string("foo") + + def test_none_or_empty_type(self): + ts = SnmpPrivacyAlgorithm.from_string(None) + self.assertIsNone(ts) + ts = SnmpPrivacyAlgorithm.from_string("") + self.assertIsNone(ts) + + def test_aes(self): + ts = SnmpPrivacyAlgorithm.from_string("aes") + self.assertEqual(ts, SnmpPrivacyAlgorithm.AES) + + def test_des(self): + ts = SnmpPrivacyAlgorithm.from_string("des") + self.assertEqual(ts, SnmpPrivacyAlgorithm.DES) diff --git a/tests/protocols/gmpv227/enums/test_sort_order.py b/tests/protocols/gmpv227/enums/test_sort_order.py new file mode 100644 index 00000000..464788d0 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_sort_order.py @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v226 import SortOrder + + +class GetSortOrderFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + SortOrder.from_string("foo") + + def test_none_or_empty(self): + ct = SortOrder.from_string(None) + self.assertIsNone(ct) + ct = SortOrder.from_string("") + self.assertIsNone(ct) + + def test_ascending(self): + ct = SortOrder.from_string("ascending") + self.assertEqual(ct, SortOrder.ASCENDING) + + def test_descending(self): + ct = SortOrder.from_string("descending") + self.assertEqual(ct, SortOrder.DESCENDING) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/protocols/gmpv227/enums/test_ticket_status.py b/tests/protocols/gmpv227/enums/test_ticket_status.py new file mode 100644 index 00000000..cac6f68c --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_ticket_status.py @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v226 import TicketStatus + + +class GetTicketStatusFromStringTestCase(unittest.TestCase): + def test_invalid_status(self): + with self.assertRaises(InvalidArgument): + TicketStatus.from_string("foo") + + def test_none_or_empty_type(self): + ts = TicketStatus.from_string(None) + self.assertIsNone(ts) + ts = TicketStatus.from_string("") + self.assertIsNone(ts) + + def test_ticket_status_open(self): + ts = TicketStatus.from_string("open") + self.assertEqual(ts, TicketStatus.OPEN) + + def test_ticket_status_fixed(self): + ts = TicketStatus.from_string("fixed") + self.assertEqual(ts, TicketStatus.FIXED) + + def test_ticket_status_closed(self): + ts = TicketStatus.from_string("closed") + self.assertEqual(ts, TicketStatus.CLOSED) diff --git a/tests/protocols/gmpv227/enums/test_user_auth_type.py b/tests/protocols/gmpv227/enums/test_user_auth_type.py new file mode 100644 index 00000000..cec6e7a5 --- /dev/null +++ b/tests/protocols/gmpv227/enums/test_user_auth_type.py @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: 2023-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import unittest + +from gvm.errors import InvalidArgument +from gvm.protocols.gmp.requests.v226 import UserAuthType + + +class GetUserAuthTypeFromStringTestCase(unittest.TestCase): + def test_invalid(self): + with self.assertRaises(InvalidArgument): + UserAuthType.from_string("foo") + + def test_none_or_empty(self): + ct = UserAuthType.from_string(None) + self.assertIsNone(ct) + ct = UserAuthType.from_string("") + self.assertIsNone(ct) + + def test_file(self): + ct = UserAuthType.from_string("file") + self.assertEqual(ct, UserAuthType.FILE) + + def test_radius_connect(self): + ct = UserAuthType.from_string("radius_connect") + self.assertEqual(ct, UserAuthType.RADIUS_CONNECT) + + def test_ldap_connect(self): + ct = UserAuthType.from_string("ldap_connect") + self.assertEqual(ct, UserAuthType.LDAP_CONNECT) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/protocols/test_latest.py b/tests/protocols/test_latest.py index 3e7a6e93..570822c6 100644 --- a/tests/protocols/test_latest.py +++ b/tests/protocols/test_latest.py @@ -12,7 +12,7 @@ class LatestProtocolsTestCase(unittest.TestCase): def test_gmp_version(self): - self.assertEqual(Gmp.get_protocol_version(), (22, 6)) + self.assertEqual(Gmp.get_protocol_version(), (22, 7)) def test_osp_version(self): self.assertEqual(Osp.get_protocol_version(), (1, 2)) diff --git a/tests/protocols/test_next.py b/tests/protocols/test_next.py index 496f1413..01ceb6dc 100644 --- a/tests/protocols/test_next.py +++ b/tests/protocols/test_next.py @@ -12,7 +12,7 @@ class LatestProtocolsTestCase(unittest.TestCase): def test_gmp_version(self): - self.assertEqual(Gmp.get_protocol_version(), (22, 6)) + self.assertEqual(Gmp.get_protocol_version(), (22, 7)) def test_osp_version(self): self.assertEqual(Osp.get_protocol_version(), (1, 2)) From 1cbb4faee186a00b9c05d30d3f843a1cfe9da27a Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Thu, 10 Apr 2025 14:46:52 +0200 Subject: [PATCH 3/6] Adjust formatting --- tests/protocols/gmpv227/__init__.py | 2 +- .../gmpv227/entities/scanners/test_create_scanner.py | 6 +++--- .../gmpv227/entities/scanners/test_modify_scanner.py | 12 ++++++------ tests/protocols/gmpv227/entities/test_scanners.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/protocols/gmpv227/__init__.py b/tests/protocols/gmpv227/__init__.py index 87d02934..db8faeb7 100644 --- a/tests/protocols/gmpv227/__init__.py +++ b/tests/protocols/gmpv227/__init__.py @@ -9,4 +9,4 @@ class GMPTestCase(BaseGMPTestCase): - gmp_class = GMPv227 \ No newline at end of file + gmp_class = GMPv227 diff --git a/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py b/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py index 83e1b08b..9ae83ab3 100644 --- a/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py +++ b/tests/protocols/gmpv227/entities/scanners/test_create_scanner.py @@ -228,7 +228,7 @@ def test_create_scanner_with_relay_host(self): b"1234" b"6" b'' - b'localhost' + b"localhost" b"" ) @@ -249,6 +249,6 @@ def test_create_scanner_with_relay_port(self): b"1234" b"6" b'' - b'2345' + b"2345" b"" - ) \ No newline at end of file + ) diff --git a/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py b/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py index eb1b6b41..cd98e81b 100644 --- a/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py +++ b/tests/protocols/gmpv227/entities/scanners/test_modify_scanner.py @@ -134,8 +134,8 @@ def test_modify_scanner_with_openvasd_type(self): self.connection.send.has_been_called_with( b'' - b'6' - b'' + b"6" + b"" ) def test_modify_scanner_with_relay_host(self): @@ -146,8 +146,8 @@ def test_modify_scanner_with_relay_host(self): self.connection.send.has_been_called_with( b'' - b'localhost' - b'' + b"localhost" + b"" ) def test_modify_scanner_with_relay_port(self): @@ -158,6 +158,6 @@ def test_modify_scanner_with_relay_port(self): self.connection.send.has_been_called_with( b'' - b'2345' - b'' + b"2345" + b"" ) diff --git a/tests/protocols/gmpv227/entities/test_scanners.py b/tests/protocols/gmpv227/entities/test_scanners.py index 49e7c024..10eb4785 100644 --- a/tests/protocols/gmpv227/entities/test_scanners.py +++ b/tests/protocols/gmpv227/entities/test_scanners.py @@ -39,4 +39,4 @@ class GMPCreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): class GMPModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): - pass \ No newline at end of file + pass From c45002e9314e7dbdb7b6d324d95e0eeb30699049 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Mon, 14 Apr 2025 10:26:45 +0200 Subject: [PATCH 4/6] Ignore type error for create_scanner, modify_scanner --- gvm/protocols/gmp/_gmp227.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gvm/protocols/gmp/_gmp227.py b/gvm/protocols/gmp/_gmp227.py index fff1d04f..8a7d7193 100644 --- a/gvm/protocols/gmp/_gmp227.py +++ b/gvm/protocols/gmp/_gmp227.py @@ -35,7 +35,7 @@ class GMPv227(GMPv226[T]): def get_protocol_version() -> tuple[int, int]: return (22, 7) - def create_scanner( + def create_scanner( # type:ignore[override] self, name: str, host: str, @@ -76,7 +76,7 @@ def create_scanner( ) ) - def modify_scanner( + def modify_scanner( # type:ignore[override] self, scanner_id: EntityID, *, From 4336648d9d769a559de543f7d7c8f84f2ca5df2e Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Mon, 14 Apr 2025 10:27:56 +0200 Subject: [PATCH 5/6] Clean up imports --- gvm/protocols/gmp/_gmp227.py | 2 +- gvm/protocols/gmp/requests/v226/__init__.py | 4 ++-- gvm/protocols/gmp/requests/v227/__init__.py | 6 +++--- .../protocols/gmpv227/entities/scanners/__init__.py | 13 +++++++------ .../gmpv227/entities/test_audit_reports.py | 2 +- .../gmpv227/entities/test_report_configs.py | 2 +- tests/protocols/gmpv227/entities/test_reports.py | 2 +- .../gmpv227/entities/test_resource_names.py | 2 +- tests/protocols/gmpv227/entities/test_scanners.py | 7 ++----- 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/gvm/protocols/gmp/_gmp227.py b/gvm/protocols/gmp/_gmp227.py index 8a7d7193..68c17c05 100644 --- a/gvm/protocols/gmp/_gmp227.py +++ b/gvm/protocols/gmp/_gmp227.py @@ -6,7 +6,7 @@ Greenbone Management Protocol (GMP) version 22.7 """ -from typing import Optional, Sequence, Union +from typing import Optional, Union from .._protocol import T from ._gmp226 import GMPv226 diff --git a/gvm/protocols/gmp/requests/v226/__init__.py b/gvm/protocols/gmp/requests/v226/__init__.py index ae1c68c0..268e2a07 100644 --- a/gvm/protocols/gmp/requests/v226/__init__.py +++ b/gvm/protocols/gmp/requests/v226/__init__.py @@ -47,9 +47,9 @@ ReportFormatType, Results, Roles, - ScannerType, - Scanners, ScanConfigs, + Scanners, + ScannerType, Schedules, SecInfo, Severity, diff --git a/gvm/protocols/gmp/requests/v227/__init__.py b/gvm/protocols/gmp/requests/v227/__init__.py index ab7db8b0..40d7af52 100644 --- a/gvm/protocols/gmp/requests/v227/__init__.py +++ b/gvm/protocols/gmp/requests/v227/__init__.py @@ -6,6 +6,8 @@ GMP Request implementations for GMP version 22.7. """ +from gvm.protocols.gmp.requests.v227._scanners import Scanners, ScannerType + from .._entity_id import EntityID from .._version import Version from ..v226 import ( @@ -46,8 +48,8 @@ Policies, PortLists, PortRangeType, - ReportConfigs, ReportConfigParameter, + ReportConfigs, ReportFormats, ReportFormatType, Reports, @@ -76,8 +78,6 @@ Vulnerabilities, ) -from gvm.protocols.gmp.requests.v227._scanners import Scanners, ScannerType - __all__ = ( "Aggregates", "AggregateStatistic", diff --git a/tests/protocols/gmpv227/entities/scanners/__init__.py b/tests/protocols/gmpv227/entities/scanners/__init__.py index e2e2fd4e..6fc0da19 100644 --- a/tests/protocols/gmpv227/entities/scanners/__init__.py +++ b/tests/protocols/gmpv227/entities/scanners/__init__.py @@ -3,15 +3,16 @@ # SPDX-License-Identifier: GPL-3.0-or-later # +from ....gmpv224.entities.scanners import ( + GmpCloneScannerTestMixin, + GmpDeleteScannerTestMixin, + GmpGetScannersTestMixin, + GmpGetScannerTestMixin, + GmpVerifyScannerTestMixin, +) from .test_create_scanner import GmpCreateScannerTestMixin from .test_modify_scanner import GmpModifyScannerTestMixin -from ....gmpv224.entities.scanners import GmpCloneScannerTestMixin -from ....gmpv224.entities.scanners import GmpDeleteScannerTestMixin -from ....gmpv224.entities.scanners import GmpGetScannerTestMixin -from ....gmpv224.entities.scanners import GmpGetScannersTestMixin -from ....gmpv224.entities.scanners import GmpVerifyScannerTestMixin - __all__ = ( "GmpCloneScannerTestMixin", "GmpCreateScannerTestMixin", diff --git a/tests/protocols/gmpv227/entities/test_audit_reports.py b/tests/protocols/gmpv227/entities/test_audit_reports.py index 7578f3d9..7f37e4e7 100644 --- a/tests/protocols/gmpv227/entities/test_audit_reports.py +++ b/tests/protocols/gmpv227/entities/test_audit_reports.py @@ -3,12 +3,12 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -from ...gmpv227 import GMPTestCase from ...gmpv226.entities.audit_reports import ( GmpDeleteAuditReportTestMixin, GmpGetAuditReportsTestMixin, GmpGetAuditReportTestMixin, ) +from ...gmpv227 import GMPTestCase class GMPDeleteAuditReportTestCase(GmpDeleteAuditReportTestMixin, GMPTestCase): diff --git a/tests/protocols/gmpv227/entities/test_report_configs.py b/tests/protocols/gmpv227/entities/test_report_configs.py index 5b2b5fa2..077d29e4 100644 --- a/tests/protocols/gmpv227/entities/test_report_configs.py +++ b/tests/protocols/gmpv227/entities/test_report_configs.py @@ -3,7 +3,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -from ...gmpv227 import GMPTestCase from ...gmpv226.entities.report_configs import ( GMPCloneReportConfigTestMixin, GMPCreateReportConfigTestMixin, @@ -12,6 +11,7 @@ GMPGetReportConfigTestMixin, GMPModifyReportConfigTestMixin, ) +from ...gmpv227 import GMPTestCase class GMPCloneReportConfigTestCase(GMPCloneReportConfigTestMixin, GMPTestCase): diff --git a/tests/protocols/gmpv227/entities/test_reports.py b/tests/protocols/gmpv227/entities/test_reports.py index 0b00b951..4cfff33d 100644 --- a/tests/protocols/gmpv227/entities/test_reports.py +++ b/tests/protocols/gmpv227/entities/test_reports.py @@ -3,13 +3,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -from ...gmpv227 import GMPTestCase from ...gmpv226.entities.reports import ( GmpDeleteReportTestMixin, GmpGetReportsTestMixin, GmpGetReportTestMixin, GmpImportReportTestMixin, ) +from ...gmpv227 import GMPTestCase class GMPDeleteReportTestCase(GmpDeleteReportTestMixin, GMPTestCase): diff --git a/tests/protocols/gmpv227/entities/test_resource_names.py b/tests/protocols/gmpv227/entities/test_resource_names.py index b291c34f..a076f524 100644 --- a/tests/protocols/gmpv227/entities/test_resource_names.py +++ b/tests/protocols/gmpv227/entities/test_resource_names.py @@ -3,11 +3,11 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -from ...gmpv227 import GMPTestCase from ...gmpv226.entities.resourcenames import ( GmpGetResourceNamesListTestMixin, GmpGetResourceNameTestMixin, ) +from ...gmpv227 import GMPTestCase class GMPGetResourceNamesListTestCase( diff --git a/tests/protocols/gmpv227/entities/test_scanners.py b/tests/protocols/gmpv227/entities/test_scanners.py index 10eb4785..5bccfce4 100644 --- a/tests/protocols/gmpv227/entities/test_scanners.py +++ b/tests/protocols/gmpv227/entities/test_scanners.py @@ -2,11 +2,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later # -# SPDX-License-Identifier: GPL-3.0-or-later -# -# SPDX-License-Identifier: GPL-3.0-or-later -# + +from tests.protocols.gmpv227 import GMPTestCase from tests.protocols.gmpv227.entities.scanners import ( GmpCloneScannerTestMixin, GmpCreateScannerTestMixin, @@ -15,7 +13,6 @@ GmpGetScannerTestMixin, GmpModifyScannerTestMixin, ) -from tests.protocols.gmpv227 import GMPTestCase class GMPDeleteScannerTestCase(GmpDeleteScannerTestMixin, GMPTestCase): From a56aff299da1cca4c3446888b48ec7eea8d8893c Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Mon, 14 Apr 2025 12:40:35 +0200 Subject: [PATCH 6/6] Add missing verify_scanner tests --- tests/protocols/gmpv224/entities/test_scanners.py | 5 +++++ tests/protocols/gmpv225/entities/test_scanners.py | 5 +++++ tests/protocols/gmpv226/entities/test_scanners.py | 5 +++++ tests/protocols/gmpv227/entities/test_scanners.py | 7 +++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/protocols/gmpv224/entities/test_scanners.py b/tests/protocols/gmpv224/entities/test_scanners.py index 15d49059..ec6d1a45 100644 --- a/tests/protocols/gmpv224/entities/test_scanners.py +++ b/tests/protocols/gmpv224/entities/test_scanners.py @@ -11,6 +11,7 @@ GmpGetScannersTestMixin, GmpGetScannerTestMixin, GmpModifyScannerTestMixin, + GmpVerifyScannerTestMixin, ) @@ -36,3 +37,7 @@ class Gmpv224CreateScannerTestCase(GmpCreateScannerTestMixin, Gmpv224TestCase): class Gmpv224ModifyScannerTestCase(GmpModifyScannerTestMixin, Gmpv224TestCase): pass + + +class Gmpv224VerifyScannerTestCase(GmpVerifyScannerTestMixin, Gmpv224TestCase): + pass diff --git a/tests/protocols/gmpv225/entities/test_scanners.py b/tests/protocols/gmpv225/entities/test_scanners.py index 9fcafe60..36b4d1b8 100644 --- a/tests/protocols/gmpv225/entities/test_scanners.py +++ b/tests/protocols/gmpv225/entities/test_scanners.py @@ -10,6 +10,7 @@ GmpGetScannersTestMixin, GmpGetScannerTestMixin, GmpModifyScannerTestMixin, + GmpVerifyScannerTestMixin, ) from ...gmpv225 import GMPTestCase @@ -36,3 +37,7 @@ class Gmpv225CreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): class Gmpv225ModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): pass + + +class Gmpv225VerifyScannerTestCase(GmpVerifyScannerTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv226/entities/test_scanners.py b/tests/protocols/gmpv226/entities/test_scanners.py index 2de40c13..dfc3114b 100644 --- a/tests/protocols/gmpv226/entities/test_scanners.py +++ b/tests/protocols/gmpv226/entities/test_scanners.py @@ -10,6 +10,7 @@ GmpGetScannersTestMixin, GmpGetScannerTestMixin, GmpModifyScannerTestMixin, + GmpVerifyScannerTestMixin, ) from tests.protocols.gmpv226 import GMPTestCase @@ -36,3 +37,7 @@ class GMPCreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): class GMPModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): pass + + +class GMPVerifyScannerTestCase(GmpVerifyScannerTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv227/entities/test_scanners.py b/tests/protocols/gmpv227/entities/test_scanners.py index 5bccfce4..8d61d46e 100644 --- a/tests/protocols/gmpv227/entities/test_scanners.py +++ b/tests/protocols/gmpv227/entities/test_scanners.py @@ -2,8 +2,7 @@ # # SPDX-License-Identifier: GPL-3.0-or-later # - - +from tests.protocols.gmpv224.entities.scanners import GmpVerifyScannerTestMixin from tests.protocols.gmpv227 import GMPTestCase from tests.protocols.gmpv227.entities.scanners import ( GmpCloneScannerTestMixin, @@ -37,3 +36,7 @@ class GMPCreateScannerTestCase(GmpCreateScannerTestMixin, GMPTestCase): class GMPModifyScannerTestCase(GmpModifyScannerTestMixin, GMPTestCase): pass + + +class GMPVerifyScannerTestCase(GmpVerifyScannerTestMixin, GMPTestCase): + pass