From 3636248ff6ef18665652a5250e540d8719deb60e Mon Sep 17 00:00:00 2001 From: ozgen Date: Tue, 22 Sep 2026 13:01:05 +0200 Subject: [PATCH] add: add get_features and get_timezones requests support --- gvm/protocols/gmp/_gmpnext.py | 18 ++++++++++++++++++ gvm/protocols/gmp/requests/next/__init__.py | 8 ++++++++ gvm/protocols/gmp/requests/next/_features.py | 13 +++++++++++++ gvm/protocols/gmp/requests/next/_timezones.py | 13 +++++++++++++ .../entities/features/test_get_features.py | 10 ++++++++++ .../gmpnext/entities/test_features.py | 14 ++++++++++++++ .../gmpnext/entities/test_timezones.py | 14 ++++++++++++++ .../entities/timezones/test_get_timezones.py | 10 ++++++++++ 8 files changed, 100 insertions(+) create mode 100644 gvm/protocols/gmp/requests/next/_features.py create mode 100644 gvm/protocols/gmp/requests/next/_timezones.py create mode 100644 tests/protocols/gmpnext/entities/features/test_get_features.py create mode 100644 tests/protocols/gmpnext/entities/test_features.py create mode 100644 tests/protocols/gmpnext/entities/test_timezones.py create mode 100644 tests/protocols/gmpnext/entities/timezones/test_get_timezones.py diff --git a/gvm/protocols/gmp/_gmpnext.py b/gvm/protocols/gmp/_gmpnext.py index 114e2df9..e5316957 100644 --- a/gvm/protocols/gmp/_gmpnext.py +++ b/gvm/protocols/gmp/_gmpnext.py @@ -20,6 +20,7 @@ Credentials, CredentialStoreCredentialType, CredentialStores, + Features, IntegrationConfigs, OCIImageTargets, ReportApplications, @@ -35,6 +36,7 @@ ScanReports, Targets, Tasks, + Timezones, WebApplicationTargets, ) from .requests.v224 import AliveTest as AliveTestV224 @@ -2042,3 +2044,19 @@ def cancel_report_export( report_export_id=report_export_id, ) ) + + def get_features( + self, + ) -> T: + """Request a list of optional features.""" + return self._send_request_and_transform_response( + Features.get_features() + ) + + def get_timezones( + self, + ) -> T: + """Request a list of supported timezones.""" + return self._send_request_and_transform_response( + Timezones.get_timezones() + ) diff --git a/gvm/protocols/gmp/requests/next/__init__.py b/gvm/protocols/gmp/requests/next/__init__.py index ff9cbcff..c9b70972 100644 --- a/gvm/protocols/gmp/requests/next/__init__.py +++ b/gvm/protocols/gmp/requests/next/__init__.py @@ -14,6 +14,9 @@ Credentials, CredentialStoreCredentialType, ) +from gvm.protocols.gmp.requests.next._features import ( + Features, +) from gvm.protocols.gmp.requests.next._integration_configs import ( IntegrationConfigs, ) @@ -51,6 +54,9 @@ from gvm.protocols.gmp.requests.next._scan_report import ScanReports from gvm.protocols.gmp.requests.next._targets import AliveTest, Targets from gvm.protocols.gmp.requests.next._tasks import Tasks +from gvm.protocols.gmp.requests.next._timezones import ( + Timezones, +) from gvm.protocols.gmp.requests.next._web_application_targets import ( WebApplicationTargets, ) @@ -150,6 +156,7 @@ "DfnCertAdvisories", "EntityID", "EntityType", + "Features", "Feed", "FeedType", "FilterType", @@ -207,6 +214,7 @@ "Tasks", "TicketStatus", "Tickets", + "Timezones", "TrashCan", "UserAuthType", "UserSettings", diff --git a/gvm/protocols/gmp/requests/next/_features.py b/gvm/protocols/gmp/requests/next/_features.py new file mode 100644 index 00000000..6845cb8d --- /dev/null +++ b/gvm/protocols/gmp/requests/next/_features.py @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: 2026 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from gvm.protocols.core import Request +from gvm.xml import XmlCommand + + +class Features: + @classmethod + def get_features(cls) -> Request: + """Request a list of optional features.""" + return XmlCommand("get_features") diff --git a/gvm/protocols/gmp/requests/next/_timezones.py b/gvm/protocols/gmp/requests/next/_timezones.py new file mode 100644 index 00000000..13c9dedc --- /dev/null +++ b/gvm/protocols/gmp/requests/next/_timezones.py @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: 2026 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from gvm.protocols.core import Request +from gvm.xml import XmlCommand + + +class Timezones: + @classmethod + def get_timezones(cls) -> Request: + """Request a list of supported timezones.""" + return XmlCommand("get_timezones") diff --git a/tests/protocols/gmpnext/entities/features/test_get_features.py b/tests/protocols/gmpnext/entities/features/test_get_features.py new file mode 100644 index 00000000..c6268418 --- /dev/null +++ b/tests/protocols/gmpnext/entities/features/test_get_features.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2026 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + + +class GmpGetFeaturesTestMixin: + def test_get_features(self): + self.gmp.get_features() + + self.connection.send.has_been_called_with(b"") diff --git a/tests/protocols/gmpnext/entities/test_features.py b/tests/protocols/gmpnext/entities/test_features.py new file mode 100644 index 00000000..682a8fc5 --- /dev/null +++ b/tests/protocols/gmpnext/entities/test_features.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2026 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + + +from ...gmpnext import GMPTestCase +from .features.test_get_features import ( + GmpGetFeaturesTestMixin, +) + + +class GmpGetFeaturesTestCase(GmpGetFeaturesTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpnext/entities/test_timezones.py b/tests/protocols/gmpnext/entities/test_timezones.py new file mode 100644 index 00000000..ce9a0281 --- /dev/null +++ b/tests/protocols/gmpnext/entities/test_timezones.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2026 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + + +from ...gmpnext import GMPTestCase +from .timezones.test_get_timezones import ( + GmpGetTimezonesTestMixin, +) + + +class GmpGetTimezonesTestCase(GmpGetTimezonesTestMixin, GMPTestCase): + pass diff --git a/tests/protocols/gmpnext/entities/timezones/test_get_timezones.py b/tests/protocols/gmpnext/entities/timezones/test_get_timezones.py new file mode 100644 index 00000000..d89f6341 --- /dev/null +++ b/tests/protocols/gmpnext/entities/timezones/test_get_timezones.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2026 Greenbone AG +# +# SPDX-License-Identifier: GPL-3.0-or-later + + +class GmpGetTimezonesTestMixin: + def test_get_timezones(self): + self.gmp.get_timezones() + + self.connection.send.has_been_called_with(b"")