From 9789256161d9202d21236be998243e07c8f577a7 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Mon, 7 Jul 2025 15:20:10 +0200 Subject: [PATCH] Add: New GMP version 22.8 with agent installers This adds the GMP version 22.8 with the new commands get_agent_installer, get_agent_installer_file and get_agent_installers. --- docs/api/gmp.md | 1 + docs/api/gmpv228.md | 157 +++++++++++++++++ gvm/protocols/gmp/__init__.py | 5 +- gvm/protocols/gmp/_gmp.py | 16 +- gvm/protocols/gmp/_gmp228.py | 76 ++++++++ gvm/protocols/gmp/requests/v228/__init__.py | 150 ++++++++++++++++ .../gmp/requests/v228/_agent_installers.py | 83 +++++++++ tests/protocols/gmp/test_context_manager.py | 29 ++- tests/protocols/gmpv228/__init__.py | 12 ++ tests/protocols/gmpv228/entities/__init__.py | 3 + .../entities/agent_installers/__init__.py | 3 + .../test_get_agent_installer.py | 23 +++ .../test_get_agent_installer_file.py | 23 +++ .../test_get_agent_installers.py | 47 +++++ .../gmpv228/entities/test_agent_installers.py | 31 ++++ .../protocols/gmpv228/entities/test_alerts.py | 48 +++++ .../gmpv228/entities/test_audit_reports.py | 23 +++ .../protocols/gmpv228/entities/test_audits.py | 53 ++++++ .../gmpv228/entities/test_credentials.py | 38 ++++ .../gmpv228/entities/test_filters.py | 38 ++++ .../protocols/gmpv228/entities/test_groups.py | 38 ++++ .../protocols/gmpv228/entities/test_hosts.py | 33 ++++ .../protocols/gmpv228/entities/test_notes.py | 38 ++++ .../entities/test_operating_systems.py | 36 ++++ .../gmpv228/entities/test_overrides.py | 38 ++++ .../gmpv228/entities/test_permissions.py | 38 ++++ .../gmpv228/entities/test_policies.py | 80 +++++++++ .../gmpv228/entities/test_port_lists.py | 48 +++++ .../gmpv228/entities/test_report_configs.py | 44 +++++ .../gmpv228/entities/test_report_formats.py | 51 ++++++ .../gmpv228/entities/test_reports.py | 28 +++ .../gmpv228/entities/test_resource_names.py | 20 +++ .../gmpv228/entities/test_results.py | 18 ++ .../protocols/gmpv228/entities/test_roles.py | 38 ++++ .../gmpv228/entities/test_scan_configs.py | 80 +++++++++ .../gmpv228/entities/test_scanners.py | 42 +++++ .../gmpv228/entities/test_schedules.py | 38 ++++ .../gmpv228/entities/test_secinfo.py | 83 +++++++++ tests/protocols/gmpv228/entities/test_tags.py | 38 ++++ .../gmpv228/entities/test_targets.py | 38 ++++ .../protocols/gmpv228/entities/test_tasks.py | 65 +++++++ .../gmpv228/entities/test_tickets.py | 38 ++++ .../gmpv228/entities/test_tls_certificates.py | 48 +++++ .../protocols/gmpv228/entities/test_users.py | 38 ++++ .../gmpv228/entities/test_vulnerabilities.py | 20 +++ tests/protocols/gmpv228/enums/__init__.py | 4 + .../gmpv228/enums/test_aggregate_statistic.py | 57 ++++++ .../gmpv228/enums/test_alert_condition.py | 45 +++++ .../gmpv228/enums/test_alert_event.py | 45 +++++ .../gmpv228/enums/test_alert_method.py | 69 ++++++++ .../gmpv228/enums/test_alive_test.py | 61 +++++++ .../gmpv228/enums/test_credential_format.py | 41 +++++ .../gmpv228/enums/test_credential_type.py | 49 ++++++ .../gmpv228/enums/test_entity_type.py | 166 ++++++++++++++++++ .../protocols/gmpv228/enums/test_feed_type.py | 37 ++++ .../gmpv228/enums/test_filter_type.py | 146 +++++++++++++++ .../gmpv228/enums/test_help_format.py | 37 ++++ .../gmpv228/enums/test_hosts_ordering.py | 33 ++++ .../protocols/gmpv228/enums/test_info_type.py | 49 ++++++ .../enums/test_permission_subject_type.py | 33 ++++ .../gmpv228/enums/test_port_range_type.py | 29 +++ .../gmpv228/enums/test_report_format_type.py | 97 ++++++++++ .../gmpv228/enums/test_resource_type.py | 133 ++++++++++++++ .../gmpv228/enums/test_scanner_type.py | 56 ++++++ .../gmpv228/enums/test_snmp_algorithms.py | 52 ++++++ .../gmpv228/enums/test_sort_order.py | 33 ++++ .../gmpv228/enums/test_ticket_status.py | 33 ++++ .../gmpv228/enums/test_user_auth_type.py | 37 ++++ 68 files changed, 3267 insertions(+), 10 deletions(-) create mode 100644 docs/api/gmpv228.md create mode 100644 gvm/protocols/gmp/_gmp228.py create mode 100644 gvm/protocols/gmp/requests/v228/__init__.py create mode 100644 gvm/protocols/gmp/requests/v228/_agent_installers.py create mode 100644 tests/protocols/gmpv228/__init__.py create mode 100644 tests/protocols/gmpv228/entities/__init__.py create mode 100644 tests/protocols/gmpv228/entities/agent_installers/__init__.py create mode 100644 tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer.py create mode 100644 tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer_file.py create mode 100644 tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installers.py create mode 100644 tests/protocols/gmpv228/entities/test_agent_installers.py create mode 100644 tests/protocols/gmpv228/entities/test_alerts.py create mode 100644 tests/protocols/gmpv228/entities/test_audit_reports.py create mode 100644 tests/protocols/gmpv228/entities/test_audits.py create mode 100644 tests/protocols/gmpv228/entities/test_credentials.py create mode 100644 tests/protocols/gmpv228/entities/test_filters.py create mode 100644 tests/protocols/gmpv228/entities/test_groups.py create mode 100644 tests/protocols/gmpv228/entities/test_hosts.py create mode 100644 tests/protocols/gmpv228/entities/test_notes.py create mode 100644 tests/protocols/gmpv228/entities/test_operating_systems.py create mode 100644 tests/protocols/gmpv228/entities/test_overrides.py create mode 100644 tests/protocols/gmpv228/entities/test_permissions.py create mode 100644 tests/protocols/gmpv228/entities/test_policies.py create mode 100644 tests/protocols/gmpv228/entities/test_port_lists.py create mode 100644 tests/protocols/gmpv228/entities/test_report_configs.py create mode 100644 tests/protocols/gmpv228/entities/test_report_formats.py create mode 100644 tests/protocols/gmpv228/entities/test_reports.py create mode 100644 tests/protocols/gmpv228/entities/test_resource_names.py create mode 100644 tests/protocols/gmpv228/entities/test_results.py create mode 100644 tests/protocols/gmpv228/entities/test_roles.py create mode 100644 tests/protocols/gmpv228/entities/test_scan_configs.py create mode 100644 tests/protocols/gmpv228/entities/test_scanners.py create mode 100644 tests/protocols/gmpv228/entities/test_schedules.py create mode 100644 tests/protocols/gmpv228/entities/test_secinfo.py create mode 100644 tests/protocols/gmpv228/entities/test_tags.py create mode 100644 tests/protocols/gmpv228/entities/test_targets.py create mode 100644 tests/protocols/gmpv228/entities/test_tasks.py create mode 100644 tests/protocols/gmpv228/entities/test_tickets.py create mode 100644 tests/protocols/gmpv228/entities/test_tls_certificates.py create mode 100644 tests/protocols/gmpv228/entities/test_users.py create mode 100644 tests/protocols/gmpv228/entities/test_vulnerabilities.py create mode 100644 tests/protocols/gmpv228/enums/__init__.py create mode 100644 tests/protocols/gmpv228/enums/test_aggregate_statistic.py create mode 100644 tests/protocols/gmpv228/enums/test_alert_condition.py create mode 100644 tests/protocols/gmpv228/enums/test_alert_event.py create mode 100644 tests/protocols/gmpv228/enums/test_alert_method.py create mode 100644 tests/protocols/gmpv228/enums/test_alive_test.py create mode 100644 tests/protocols/gmpv228/enums/test_credential_format.py create mode 100644 tests/protocols/gmpv228/enums/test_credential_type.py create mode 100644 tests/protocols/gmpv228/enums/test_entity_type.py create mode 100644 tests/protocols/gmpv228/enums/test_feed_type.py create mode 100644 tests/protocols/gmpv228/enums/test_filter_type.py create mode 100644 tests/protocols/gmpv228/enums/test_help_format.py create mode 100644 tests/protocols/gmpv228/enums/test_hosts_ordering.py create mode 100644 tests/protocols/gmpv228/enums/test_info_type.py create mode 100644 tests/protocols/gmpv228/enums/test_permission_subject_type.py create mode 100644 tests/protocols/gmpv228/enums/test_port_range_type.py create mode 100644 tests/protocols/gmpv228/enums/test_report_format_type.py create mode 100644 tests/protocols/gmpv228/enums/test_resource_type.py create mode 100644 tests/protocols/gmpv228/enums/test_scanner_type.py create mode 100644 tests/protocols/gmpv228/enums/test_snmp_algorithms.py create mode 100644 tests/protocols/gmpv228/enums/test_sort_order.py create mode 100644 tests/protocols/gmpv228/enums/test_ticket_status.py create mode 100644 tests/protocols/gmpv228/enums/test_user_auth_type.py diff --git a/docs/api/gmp.md b/docs/api/gmp.md index 2fb725791..2a6cf5c0a 100644 --- a/docs/api/gmp.md +++ b/docs/api/gmp.md @@ -18,4 +18,5 @@ gmpv224 gmpv225 gmpv226 gmpv227 +gmpv228 ``` diff --git a/docs/api/gmpv228.md b/docs/api/gmpv228.md new file mode 100644 index 000000000..3dff0de74 --- /dev/null +++ b/docs/api/gmpv228.md @@ -0,0 +1,157 @@ +(gmpv228)= + +# GMP v22.8 + +```{eval-rst} +.. automodule:: gvm.protocols.gmp._gmp228 +``` + +## Protocol + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.GMPv228 + :members: + :inherited-members: +``` + +## Enums + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.AlertCondition + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.AlertEvent + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.AlertMethod + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.AliveTest + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.CredentialFormat + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.CredentialType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.EntityType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.FeedType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.FilterType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.HostsOrdering + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.HelpFormat + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.InfoType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.PermissionSubjectType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.PortRangeType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.ReportFormatType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.ResourceType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.ScannerType + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.SnmpAuthAlgorithm + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.SnmpPrivacyAlgorithm + :members: + :undoc-members: + :no-index: +``` + +```{eval-rst} +.. autoclass:: gvm.protocols.gmp.requests.v228.TicketStatus + :members: + :undoc-members: + :no-index: +``` diff --git a/gvm/protocols/gmp/__init__.py b/gvm/protocols/gmp/__init__.py index d95d42895..3c052aa15 100644 --- a/gvm/protocols/gmp/__init__.py +++ b/gvm/protocols/gmp/__init__.py @@ -9,13 +9,14 @@ 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`, -:class:`GMPv225`, :class:`GMPv226` or :class:`GMPv227` classes. +:class:`GMPv225`, :class:`GMPv226`, :class:`GMPv227` or :class:`GMPv228` 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 +* :class:`GMPv228` - GMP version 22.8 """ from ._gmp import GMP @@ -23,6 +24,7 @@ from ._gmp225 import GMPv225 from ._gmp226 import GMPv226 from ._gmp227 import GMPv227 +from ._gmp228 import GMPv228 Gmp = GMP # for backwards compatibility @@ -33,4 +35,5 @@ "GMPv225", "GMPv226", "GMPv227", + "GMPv228", ) diff --git a/gvm/protocols/gmp/_gmp.py b/gvm/protocols/gmp/_gmp.py index 80d11ad08..75965dff8 100644 --- a/gvm/protocols/gmp/_gmp.py +++ b/gvm/protocols/gmp/_gmp.py @@ -16,10 +16,13 @@ from ._gmp225 import GMPv225 from ._gmp226 import GMPv226 from ._gmp227 import GMPv227 +from ._gmp228 import GMPv228 from .requests import Version -SUPPORTED_GMP_VERSIONS = Union[GMPv224[T], GMPv225[T], GMPv226[T], GMPv227[T]] -_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6", "22.7"] +SUPPORTED_GMP_VERSIONS = Union[ + GMPv224[T], GMPv225[T], GMPv226[T], GMPv227[T], GMPv228[T] +] +_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6", "22.7", "22.8"] class GMP(GvmProtocol[T]): @@ -38,7 +41,8 @@ class GMP(GvmProtocol[T]): # gvm.protocols.gmp.GMPv224, # gvm.protocols.gmp.GMPv225, # gvm.protocols.gmp.GMPv226, - # or gvm.protocols.gmp.GMPv227 + # gvm.protocols.gmp.GMPv227, + # or gvm.protocols.gmp.GMPv228 # depending on the supported GMP version of the remote manager daemon resp = gmp.get_tasks() """ @@ -93,9 +97,11 @@ def determine_supported_gmp(self) -> SUPPORTED_GMP_VERSIONS: gmp_class = GMPv225 elif major_version == 22 and minor_version == 6: gmp_class = GMPv226 - elif major_version == 22 and minor_version >= 7: + elif major_version == 22 and minor_version == 7: gmp_class = GMPv227 - if minor_version > 7: + elif major_version == 22 and minor_version >= 8: + gmp_class = GMPv228 + if minor_version > 8: warnings.warn( "Remote manager daemon uses a newer GMP version than " f"supported by python-gvm {__version__}. Please update to " diff --git a/gvm/protocols/gmp/_gmp228.py b/gvm/protocols/gmp/_gmp228.py new file mode 100644 index 000000000..857694353 --- /dev/null +++ b/gvm/protocols/gmp/_gmp228.py @@ -0,0 +1,76 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from typing import Optional + +from gvm.protocols.gmp.requests import EntityID + +from .._protocol import T +from ._gmp227 import GMPv227 +from .requests.v228 import AgentInstallers + + +class GMPv228(GMPv227[T]): + """ + A class implementing the Greenbone Management Protocol (GMP) version 22.8 + + Example: + + .. code-block:: python + + from gvm.protocols.gmp import GMPv228 as GMP + + with GMP(connection) as gmp: + resp = gmp.get_tasks() + """ + + @staticmethod + def get_protocol_version() -> tuple[int, int]: + return (22, 8) + + def get_agent_installers( + self, + *, + filter_string: Optional[str] = None, + filter_id: Optional[EntityID] = None, + trash: Optional[bool] = None, + details: Optional[bool] = None, + ) -> T: + """Request a list of agent installers + + 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 agent installers instead + details: Whether to include extra details like tasks using this + scanner + """ + return self._send_request_and_transform_response( + AgentInstallers.get_agent_installers( + filter_string=filter_string, + filter_id=filter_id, + trash=trash, + details=details, + ) + ) + + def get_agent_installer(self, agent_installer_id: EntityID) -> T: + """Request a single agent installer + + Args: + agent_installer_id: UUID of an existing agent installer + """ + return self._send_request_and_transform_response( + AgentInstallers.get_agent_installer(agent_installer_id) + ) + + def get_agent_installer_file(self, agent_installer_id: EntityID) -> T: + """Request a single agent installer file + + Args: + agent_installer_id: UUID of an existing agent installer + """ + return self._send_request_and_transform_response( + AgentInstallers.get_agent_installer_file(agent_installer_id) + ) diff --git a/gvm/protocols/gmp/requests/v228/__init__.py b/gvm/protocols/gmp/requests/v228/__init__.py new file mode 100644 index 000000000..d84b0e88c --- /dev/null +++ b/gvm/protocols/gmp/requests/v228/__init__.py @@ -0,0 +1,150 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from gvm.protocols.gmp.requests.v228._agent_installers import AgentInstallers + +from .._entity_id import EntityID +from .._version import Version +from ..v227 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, + ReportConfigParameter, + ReportConfigs, + ReportFormats, + ReportFormatType, + Reports, + ResourceNames, + ResourceType, + Results, + Roles, + ScanConfigs, + Scanners, + ScannerType, + Schedules, + SecInfo, + Severity, + SnmpAuthAlgorithm, + SnmpPrivacyAlgorithm, + SortOrder, + SystemReports, + Tags, + Targets, + Tasks, + Tickets, + TicketStatus, + TLSCertificates, + TrashCan, + UserAuthType, + Users, + UserSettings, + Vulnerabilities, +) + +__all__ = ( + "AgentInstallers", + "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/v228/_agent_installers.py b/gvm/protocols/gmp/requests/v228/_agent_installers.py new file mode 100644 index 000000000..9de4723da --- /dev/null +++ b/gvm/protocols/gmp/requests/v228/_agent_installers.py @@ -0,0 +1,83 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from typing import Optional + +from gvm.errors import RequiredArgument +from gvm.protocols.core import Request +from gvm.protocols.gmp.requests._entity_id import EntityID +from gvm.utils import to_bool +from gvm.xml import XmlCommand + + +class AgentInstallers: + + @staticmethod + def get_agent_installers( + *, + filter_string: Optional[str] = None, + filter_id: Optional[EntityID] = None, + trash: Optional[bool] = None, + details: Optional[bool] = None, + ) -> Request: + """Request a list of agent installers + + 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 agent installers instead + details: Whether to include extra details like tasks using this + scanner + """ + cmd = XmlCommand("get_agent_installers") + 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_agent_installer(cls, agent_installer_id: EntityID) -> Request: + """Request a single agent installer + + Args: + agent_installer_id: UUID of an existing agent installer + """ + if not agent_installer_id: + raise RequiredArgument( + function=cls.get_agent_installer.__name__, + argument="agent_installer_id", + ) + + cmd = XmlCommand("get_agent_installers") + cmd.set_attribute("agent_installer_id", str(agent_installer_id)) + + # for single entity always request all details + cmd.set_attribute("details", "1") + + return cmd + + @classmethod + def get_agent_installer_file(cls, agent_installer_id: EntityID) -> Request: + """Request a single agent installer + + Args: + agent_installer_id: UUID of an existing agent installer + """ + if not agent_installer_id: + raise RequiredArgument( + function=cls.get_agent_installer.__name__, + argument="agent_installer_id", + ) + + cmd = XmlCommand("get_agent_installer_file") + cmd.set_attribute("agent_installer_id", str(agent_installer_id)) + + return cmd diff --git a/tests/protocols/gmp/test_context_manager.py b/tests/protocols/gmp/test_context_manager.py index af0877eea..eba761f2e 100644 --- a/tests/protocols/gmp/test_context_manager.py +++ b/tests/protocols/gmp/test_context_manager.py @@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch from gvm.errors import GvmError -from gvm.protocols.gmp import Gmp +from gvm.protocols.gmp import Gmp, GMPv228 from gvm.protocols.gmp._gmp224 import GMPv224 from gvm.protocols.gmp._gmp225 import GMPv225 from gvm.protocols.gmp._gmp226 import GMPv226 @@ -146,7 +146,17 @@ def test_select_gmpv227(self): self.assertEqual(gmp.get_protocol_version(), (22, 7)) self.assertIsInstance(gmp, GMPv227) - def test_next_version_fallback(self): + def test_select_gmpv228(self): + self.connection.read.return_value( + b'' + b"22.08" + b"" + ) + + with self.gmp as gmp: + self.assertEqual(gmp.get_protocol_version(), (22, 8)) + self.assertIsInstance(gmp, GMPv228) + self.connection.read.return_value( b'' b"22.8" @@ -154,7 +164,18 @@ def test_next_version_fallback(self): ) with self.gmp as gmp: - self.assertEqual(gmp.get_protocol_version(), (22, 7)) + self.assertEqual(gmp.get_protocol_version(), (22, 8)) + self.assertIsInstance(gmp, GMPv227) + + def test_next_version_fallback(self): + self.connection.read.return_value( + b'' + b"22.9" + b"" + ) + + with self.gmp as gmp: + self.assertEqual(gmp.get_protocol_version(), (22, 8)) self.assertIsInstance(gmp, GMPv227) def test_newer_version_fallback(self): @@ -165,7 +186,7 @@ def test_newer_version_fallback(self): ) with self.gmp as gmp: - self.assertEqual(gmp.get_protocol_version(), (22, 7)) + self.assertEqual(gmp.get_protocol_version(), (22, 8)) self.assertIsInstance(gmp, GMPv227) def test_unknown_protocol(self): diff --git a/tests/protocols/gmpv228/__init__.py b/tests/protocols/gmpv228/__init__.py new file mode 100644 index 000000000..2b9ead19c --- /dev/null +++ b/tests/protocols/gmpv228/__init__.py @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gvm.protocols.gmp import GMPv228 + +from .. import GmpTestCase as BaseGMPTestCase + + +class GMPTestCase(BaseGMPTestCase): + gmp_class = GMPv228 diff --git a/tests/protocols/gmpv228/entities/__init__.py b/tests/protocols/gmpv228/entities/__init__.py new file mode 100644 index 000000000..9c0a68e73 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/agent_installers/__init__.py b/tests/protocols/gmpv228/entities/agent_installers/__init__.py new file mode 100644 index 000000000..7cb84d4c1 --- /dev/null +++ b/tests/protocols/gmpv228/entities/agent_installers/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later diff --git a/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer.py b/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer.py new file mode 100644 index 000000000..69b8426c3 --- /dev/null +++ b/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2018-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gvm.errors import RequiredArgument + + +class GmpGetAgentInstallerTestMixin: + + def test_get_agent_installer(self): + self.gmp.get_agent_installer(agent_installer_id="installer1") + + self.connection.send.has_been_called_with( + b'' + ) + + def test_get_agent_installer_without_id(self): + with self.assertRaises(RequiredArgument): + self.gmp.get_agent_installer(None) + + with self.assertRaises(RequiredArgument): + self.gmp.get_agent_installer("") diff --git a/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer_file.py b/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer_file.py new file mode 100644 index 000000000..735d5a952 --- /dev/null +++ b/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installer_file.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2018-2024 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gvm.errors import RequiredArgument + + +class GmpGetAgentInstallerFileTestMixin: + + def test_get_agent_installer(self): + self.gmp.get_agent_installer_file(agent_installer_id="installer1") + + self.connection.send.has_been_called_with( + b'' + ) + + def test_get_agent_installer_without_id(self): + with self.assertRaises(RequiredArgument): + self.gmp.get_agent_installer_file(None) + + with self.assertRaises(RequiredArgument): + self.gmp.get_agent_installer_file("") diff --git a/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installers.py b/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installers.py new file mode 100644 index 000000000..819e5121e --- /dev/null +++ b/tests/protocols/gmpv228/entities/agent_installers/test_get_agent_installers.py @@ -0,0 +1,47 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + + +class GmpGetAgentInstallersTestMixin: + def test_get_agent_installers(self): + self.gmp.get_agent_installers() + + self.connection.send.has_been_called_with(b"") + + def test_get_agent_installers_trash(self): + self.gmp.get_agent_installers(trash=True) + + self.connection.send.has_been_called_with( + b'' + ) + + def test_get_agent_installers_with_filter_string(self): + self.gmp.get_agent_installers( + filter_string="name=foo", + ) + + self.connection.send.has_been_called_with( + b'' + ) + + def test_get_agent_installers_with_filter_id(self): + self.gmp.get_agent_installers(filter_id="f1") + + self.connection.send.has_been_called_with( + b'' + ) + + def test_get_agent_installers_with_details(self): + self.gmp.get_agent_installers(details=True) + + self.connection.send.has_been_called_with( + b'' + ) + + def test_get_agent_installers_without_details(self): + self.gmp.get_agent_installers(details=False) + + self.connection.send.has_been_called_with( + b'' + ) diff --git a/tests/protocols/gmpv228/entities/test_agent_installers.py b/tests/protocols/gmpv228/entities/test_agent_installers.py new file mode 100644 index 000000000..6c6051601 --- /dev/null +++ b/tests/protocols/gmpv228/entities/test_agent_installers.py @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv228 import GMPTestCase +from .agent_installers.test_get_agent_installer import ( + GmpGetAgentInstallerTestMixin, +) +from .agent_installers.test_get_agent_installer_file import ( + GmpGetAgentInstallerFileTestMixin, +) +from .agent_installers.test_get_agent_installers import ( + GmpGetAgentInstallersTestMixin, +) + + +class GMPGetAgentInstallerTestCase(GmpGetAgentInstallerTestMixin, GMPTestCase): + pass + + +class GMPGetAgentInstallerFileTestCase( + GmpGetAgentInstallerFileTestMixin, GMPTestCase +): + pass + + +class GMPGetAgentInstallersTestCase( + GmpGetAgentInstallersTestMixin, GMPTestCase +): + pass diff --git a/tests/protocols/gmpv228/entities/test_alerts.py b/tests/protocols/gmpv228/entities/test_alerts.py new file mode 100644 index 000000000..0b997447a --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_audit_reports.py b/tests/protocols/gmpv228/entities/test_audit_reports.py new file mode 100644 index 000000000..7f37e4e7c --- /dev/null +++ b/tests/protocols/gmpv228/entities/test_audit_reports.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv226.entities.audit_reports import ( + GmpDeleteAuditReportTestMixin, + GmpGetAuditReportsTestMixin, + GmpGetAuditReportTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPDeleteAuditReportTestCase(GmpDeleteAuditReportTestMixin, GMPTestCase): + pass + + +class GMPGetAuditReportTestCase(GmpGetAuditReportTestMixin, GMPTestCase): + pass + + +class GMPGetAuditReportsTestCase(GmpGetAuditReportsTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv228/entities/test_audits.py b/tests/protocols/gmpv228/entities/test_audits.py new file mode 100644 index 000000000..0d9b9e1a8 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_credentials.py b/tests/protocols/gmpv228/entities/test_credentials.py new file mode 100644 index 000000000..5843ed24f --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_filters.py b/tests/protocols/gmpv228/entities/test_filters.py new file mode 100644 index 000000000..b309163d4 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_groups.py b/tests/protocols/gmpv228/entities/test_groups.py new file mode 100644 index 000000000..cffe3080a --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_hosts.py b/tests/protocols/gmpv228/entities/test_hosts.py new file mode 100644 index 000000000..a54ca0b0a --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_notes.py b/tests/protocols/gmpv228/entities/test_notes.py new file mode 100644 index 000000000..489ba2b2e --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_operating_systems.py b/tests/protocols/gmpv228/entities/test_operating_systems.py new file mode 100644 index 000000000..f6f311652 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_overrides.py b/tests/protocols/gmpv228/entities/test_overrides.py new file mode 100644 index 000000000..a6748e097 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_permissions.py b/tests/protocols/gmpv228/entities/test_permissions.py new file mode 100644 index 000000000..c92c0dca4 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_policies.py b/tests/protocols/gmpv228/entities/test_policies.py new file mode 100644 index 000000000..8a51095f8 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_port_lists.py b/tests/protocols/gmpv228/entities/test_port_lists.py new file mode 100644 index 000000000..82b997f0c --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_report_configs.py b/tests/protocols/gmpv228/entities/test_report_configs.py new file mode 100644 index 000000000..077d29e4f --- /dev/null +++ b/tests/protocols/gmpv228/entities/test_report_configs.py @@ -0,0 +1,44 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv226.entities.report_configs import ( + GMPCloneReportConfigTestMixin, + GMPCreateReportConfigTestMixin, + GMPDeleteReportConfigTestMixin, + GMPGetReportConfigsTestMixin, + GMPGetReportConfigTestMixin, + GMPModifyReportConfigTestMixin, +) +from ...gmpv227 import GMPTestCase + + +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/gmpv228/entities/test_report_formats.py b/tests/protocols/gmpv228/entities/test_report_formats.py new file mode 100644 index 000000000..b036feaa8 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_reports.py b/tests/protocols/gmpv228/entities/test_reports.py new file mode 100644 index 000000000..4cfff33d3 --- /dev/null +++ b/tests/protocols/gmpv228/entities/test_reports.py @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv226.entities.reports import ( + GmpDeleteReportTestMixin, + GmpGetReportsTestMixin, + GmpGetReportTestMixin, + GmpImportReportTestMixin, +) +from ...gmpv227 import GMPTestCase + + +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/gmpv228/entities/test_resource_names.py b/tests/protocols/gmpv228/entities/test_resource_names.py new file mode 100644 index 000000000..a076f5246 --- /dev/null +++ b/tests/protocols/gmpv228/entities/test_resource_names.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2023-2025 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from ...gmpv226.entities.resourcenames import ( + GmpGetResourceNamesListTestMixin, + GmpGetResourceNameTestMixin, +) +from ...gmpv227 import GMPTestCase + + +class GMPGetResourceNamesListTestCase( + GmpGetResourceNamesListTestMixin, GMPTestCase +): + pass + + +class GMPGetResourceNameTestCase(GmpGetResourceNameTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv228/entities/test_results.py b/tests/protocols/gmpv228/entities/test_results.py new file mode 100644 index 000000000..a2d0e3421 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_roles.py b/tests/protocols/gmpv228/entities/test_roles.py new file mode 100644 index 000000000..3480a85a9 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_scan_configs.py b/tests/protocols/gmpv228/entities/test_scan_configs.py new file mode 100644 index 000000000..236d21c76 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_scanners.py b/tests/protocols/gmpv228/entities/test_scanners.py new file mode 100644 index 000000000..8d61d46ec --- /dev/null +++ b/tests/protocols/gmpv228/entities/test_scanners.py @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2025 Greenbone AG +# +# 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, + GmpCreateScannerTestMixin, + GmpDeleteScannerTestMixin, + GmpGetScannersTestMixin, + GmpGetScannerTestMixin, + GmpModifyScannerTestMixin, +) + + +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 + + +class GMPVerifyScannerTestCase(GmpVerifyScannerTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpv228/entities/test_schedules.py b/tests/protocols/gmpv228/entities/test_schedules.py new file mode 100644 index 000000000..bc056bcd2 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_secinfo.py b/tests/protocols/gmpv228/entities/test_secinfo.py new file mode 100644 index 000000000..2dc29eae0 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_tags.py b/tests/protocols/gmpv228/entities/test_tags.py new file mode 100644 index 000000000..6035d3e20 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_targets.py b/tests/protocols/gmpv228/entities/test_targets.py new file mode 100644 index 000000000..f8c3408fb --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_tasks.py b/tests/protocols/gmpv228/entities/test_tasks.py new file mode 100644 index 000000000..0ad450b22 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_tickets.py b/tests/protocols/gmpv228/entities/test_tickets.py new file mode 100644 index 000000000..77cf9c341 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_tls_certificates.py b/tests/protocols/gmpv228/entities/test_tls_certificates.py new file mode 100644 index 000000000..9e6c90723 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_users.py b/tests/protocols/gmpv228/entities/test_users.py new file mode 100644 index 000000000..8ea68accf --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/entities/test_vulnerabilities.py b/tests/protocols/gmpv228/entities/test_vulnerabilities.py new file mode 100644 index 000000000..d9bc0bd5b --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/__init__.py b/tests/protocols/gmpv228/enums/__init__.py new file mode 100644 index 000000000..baae7654d --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_aggregate_statistic.py b/tests/protocols/gmpv228/enums/test_aggregate_statistic.py new file mode 100644 index 000000000..a5e4f90e9 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_alert_condition.py b/tests/protocols/gmpv228/enums/test_alert_condition.py new file mode 100644 index 000000000..1552d7c88 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_alert_event.py b/tests/protocols/gmpv228/enums/test_alert_event.py new file mode 100644 index 000000000..4a273c1af --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_alert_method.py b/tests/protocols/gmpv228/enums/test_alert_method.py new file mode 100644 index 000000000..c1a46e356 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_alive_test.py b/tests/protocols/gmpv228/enums/test_alive_test.py new file mode 100644 index 000000000..ad15c7e1c --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_credential_format.py b/tests/protocols/gmpv228/enums/test_credential_format.py new file mode 100644 index 000000000..125ec9f79 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_credential_type.py b/tests/protocols/gmpv228/enums/test_credential_type.py new file mode 100644 index 000000000..92cb62a99 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_entity_type.py b/tests/protocols/gmpv228/enums/test_entity_type.py new file mode 100644 index 000000000..d3b806213 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_feed_type.py b/tests/protocols/gmpv228/enums/test_feed_type.py new file mode 100644 index 000000000..d8847353a --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_filter_type.py b/tests/protocols/gmpv228/enums/test_filter_type.py new file mode 100644 index 000000000..8f9037f95 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_help_format.py b/tests/protocols/gmpv228/enums/test_help_format.py new file mode 100644 index 000000000..ba74db750 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_hosts_ordering.py b/tests/protocols/gmpv228/enums/test_hosts_ordering.py new file mode 100644 index 000000000..79557e430 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_info_type.py b/tests/protocols/gmpv228/enums/test_info_type.py new file mode 100644 index 000000000..030765ae0 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_permission_subject_type.py b/tests/protocols/gmpv228/enums/test_permission_subject_type.py new file mode 100644 index 000000000..e303cad71 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_port_range_type.py b/tests/protocols/gmpv228/enums/test_port_range_type.py new file mode 100644 index 000000000..ad4aef051 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_report_format_type.py b/tests/protocols/gmpv228/enums/test_report_format_type.py new file mode 100644 index 000000000..083e208e8 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_resource_type.py b/tests/protocols/gmpv228/enums/test_resource_type.py new file mode 100644 index 000000000..5856fcb6f --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_scanner_type.py b/tests/protocols/gmpv228/enums/test_scanner_type.py new file mode 100644 index 000000000..9ea4cce53 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_snmp_algorithms.py b/tests/protocols/gmpv228/enums/test_snmp_algorithms.py new file mode 100644 index 000000000..1aad8b4da --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_sort_order.py b/tests/protocols/gmpv228/enums/test_sort_order.py new file mode 100644 index 000000000..464788d0f --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_ticket_status.py b/tests/protocols/gmpv228/enums/test_ticket_status.py new file mode 100644 index 000000000..cac6f68c3 --- /dev/null +++ b/tests/protocols/gmpv228/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/gmpv228/enums/test_user_auth_type.py b/tests/protocols/gmpv228/enums/test_user_auth_type.py new file mode 100644 index 000000000..cec6e7a5d --- /dev/null +++ b/tests/protocols/gmpv228/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()