From 8c6400f3401c797430590a90aaae65a8e7aed2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 15:26:23 +0200 Subject: [PATCH 01/15] Detach Trashcan into TrashcanMixin, restore -> restore_from_trashcan --- gvm/protocols/gmpv208/__init__.py | 2 + gvm/protocols/gmpv208/entities/trashcan.py | 55 +++++++++++++++++++ gvm/protocols/gmpv208/gmpv208.py | 30 ---------- gvm/protocols/gmpv214/__init__.py | 2 + tests/protocols/gmpv208/testcmds/__init__.py | 2 +- ...store.py => test_restore_from_trashcan.py} | 6 +- 6 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 gvm/protocols/gmpv208/entities/trashcan.py rename tests/protocols/gmpv208/testcmds/{test_restore.py => test_restore_from_trashcan.py} (88%) diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index 534beb859..1bf13fcd4 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -130,6 +130,7 @@ get_ticket_status_from_string, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin +from gvm.protocols.gmpv208.entities.trashcan import TrashcanMixin from gvm.protocols.gmpv208.entities.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, @@ -168,6 +169,7 @@ class Gmp( TasksMixin, TicketsMixin, TLSCertificateMixin, + TrashcanMixin, ScanConfigsMixin, ScannersMixin, SchedulesMixin, diff --git a/gvm/protocols/gmpv208/entities/trashcan.py b/gvm/protocols/gmpv208/entities/trashcan.py new file mode 100644 index 000000000..0d2d43c0f --- /dev/null +++ b/gvm/protocols/gmpv208/entities/trashcan.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from typing import Any + +from gvm.errors import RequiredArgument +from gvm.xml import XmlCommand + + +class TrashcanMixin: + def empty_trashcan(self) -> Any: + """Empty the trashcan + + Remove all entities from the trashcan. **Attention:** this command can + not be reverted + + Returns: + The response. See :py:meth:`send_command` for details. + """ + return self._send_xml_command(XmlCommand("empty_trashcan")) + + def restore_from_trashcan(self, entity_id: str) -> Any: + """Restore an entity from the trashcan + + Arguments: + entity_id: ID of the entity to be restored from the trashcan + + Returns: + The response. See :py:meth:`send_command` for details. + """ + if not entity_id: + raise RequiredArgument( + function=self.restore_from_trashcan.__name__, + argument='entity_id', + ) + + cmd = XmlCommand("restore") + cmd.set_attribute("id", entity_id) + + return self._send_xml_command(cmd) diff --git a/gvm/protocols/gmpv208/gmpv208.py b/gvm/protocols/gmpv208/gmpv208.py index e8f74b92c..b31a16258 100644 --- a/gvm/protocols/gmpv208/gmpv208.py +++ b/gvm/protocols/gmpv208/gmpv208.py @@ -127,17 +127,6 @@ def describe_auth(self) -> Any: """ return self._send_xml_command(XmlCommand("describe_auth")) - def empty_trashcan(self) -> Any: - """Empty the trashcan - - Remove all entities from the trashcan. **Attention:** this command can - not be reverted - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("empty_trashcan")) - def get_system_reports( self, *, @@ -260,25 +249,6 @@ def modify_auth(self, group_name: str, auth_conf_settings: dict) -> Any: return self._send_xml_command(cmd) - def restore(self, entity_id: str) -> Any: - """Restore an entity from the trashcan - - Arguments: - entity_id: ID of the entity to be restored from the trashcan - - Returns: - The response. See :py:meth:`send_command` for details. - """ - if not entity_id: - raise RequiredArgument( - function=self.restore.__name__, argument='entity_id' - ) - - cmd = XmlCommand("restore") - cmd.set_attribute("id", entity_id) - - return self._send_xml_command(cmd) - def sync_cert(self) -> Any: """Request a synchronization with the CERT feed service diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index ae646d1ee..f7e912914 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -118,6 +118,7 @@ get_ticket_status_from_string, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin +from gvm.protocols.gmpv208.entities.trashcan import TrashcanMixin from gvm.protocols.gmpv208.entities.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, @@ -174,6 +175,7 @@ class Gmp( TasksMixin, TicketsMixin, TLSCertificateMixin, + TrashcanMixin, ScanConfigsMixin, ScannersMixin, SchedulesMixin, diff --git a/tests/protocols/gmpv208/testcmds/__init__.py b/tests/protocols/gmpv208/testcmds/__init__.py index db9c9fd17..89f4ec681 100644 --- a/tests/protocols/gmpv208/testcmds/__init__.py +++ b/tests/protocols/gmpv208/testcmds/__init__.py @@ -26,7 +26,7 @@ from .test_get_version import GmpGetVersionCommandTestCase from .test_help import GmpHelpTestCase from .test_modify_auth import GmpModifyAuthTestCase -from .test_restore import GmpRestoreTestCase +from .test_restore_from_trashcan import GmpRestoreTestCase from .test_sync_cert import GmpSyncCertCommandTestCase from .test_sync_scap import GmpSyncScapCommandTestCase from .test_with_statement import GmpWithStatementTestCase diff --git a/tests/protocols/gmpv208/testcmds/test_restore.py b/tests/protocols/gmpv208/testcmds/test_restore_from_trashcan.py similarity index 88% rename from tests/protocols/gmpv208/testcmds/test_restore.py rename to tests/protocols/gmpv208/testcmds/test_restore_from_trashcan.py index fd8cddc25..f7411424a 100644 --- a/tests/protocols/gmpv208/testcmds/test_restore.py +++ b/tests/protocols/gmpv208/testcmds/test_restore_from_trashcan.py @@ -21,13 +21,13 @@ class GmpRestoreTestCase: def test_restore(self): - self.gmp.restore('a1') + self.gmp.restore_from_trashcan('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): - self.gmp.restore(None) + self.gmp.restore_from_trashcan(None) with self.assertRaises(GvmError): - self.gmp.restore('') + self.gmp.restore_from_trashcan('') From 9ef070575cde5950c1e30f66b9be9ade32ddd842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 17:23:06 +0200 Subject: [PATCH 02/15] Detach Authentication functions into AuthenticationMixin --- gvm/protocols/gmpv208/__init__.py | 22 ++++ .../gmpv208/entities/authentication.py | 114 ++++++++++++++++++ gvm/protocols/gmpv208/gmpv208.py | 112 +---------------- gvm/protocols/gmpv214/__init__.py | 2 + 4 files changed, 139 insertions(+), 111 deletions(-) create mode 100644 gvm/protocols/gmpv208/entities/authentication.py diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index 1bf13fcd4..ae4a982d2 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -45,6 +45,7 @@ get_alert_method_from_string, ) from gvm.protocols.gmpv208.entities.audits import AuditsMixin +from gvm.protocols.gmpv208.entities.authentication import AuthenticationMixin from gvm.protocols.gmpv208.entities.credentials import ( CredentialFormat, CredentialsMixin, @@ -148,6 +149,7 @@ class Gmp( AggregatesMixin, AlertsMixin, AuditsMixin, + AuthenticationMixin, CredentialsMixin, FeedsMixin, FiltersMixin, @@ -178,6 +180,26 @@ class Gmp( UsersMixin, VulnerabilitiesMixin, ): + """Python interface for Greenbone Management Protocol + + This class implements the `Greenbone Management Protocol version 20.08`_ + + Arguments: + connection: Connection to use to talk with the gvmd daemon. See + :mod:`gvm.connections` for possible connection types. + transform: Optional transform `callable`_ to convert response data. + After each request the callable gets passed the plain response data + which can be used to check the data and/or conversion into different + representations like a xml dom. + + See :mod:`gvm.transforms` for existing transforms. + + .. _Greenbone Management Protocol version 20.08: + https://docs.greenbone.net/API/GMP/gmp-20.08.html + .. _callable: + https://docs.python.org/3/library/functions.html#callable + """ + def __init__( self, connection: GvmConnection, diff --git a/gvm/protocols/gmpv208/entities/authentication.py b/gvm/protocols/gmpv208/entities/authentication.py new file mode 100644 index 000000000..54d66d9d7 --- /dev/null +++ b/gvm/protocols/gmpv208/entities/authentication.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from typing import Any + +from gvm.errors import RequiredArgument +from gvm.utils import check_command_status +from gvm.xml import XmlCommand + + +class AuthenticationMixin: + def is_authenticated(self) -> bool: + """Checks if the user is authenticated + + If the user is authenticated privileged GMP commands like get_tasks + may be send to gvmd. + + Returns: + bool: True if an authenticated connection to gvmd has been + established. + """ + return self._authenticated + + def authenticate(self, username: str, password: str) -> Any: + """Authenticate to gvmd. + + The generated authenticate command will be send to server. + Afterwards the response is read, transformed and returned. + + Arguments: + username: Username + password: Password + + Returns: + Transformed response from server. + """ + cmd = XmlCommand("authenticate") + + if not username: + raise RequiredArgument( + function=self.authenticate.__name__, argument='username' + ) + + if not password: + raise RequiredArgument( + function=self.authenticate.__name__, argument='password' + ) + + credentials = cmd.add_element("credentials") + credentials.add_element("username", username) + credentials.add_element("password", password) + + self._send(cmd.to_string()) + response = self._read() + + if check_command_status(response): + self._authenticated = True + + return self._transform(response) + + def describe_auth(self) -> Any: + """Describe authentication methods + + Returns a list of all used authentication methods if such a list is + available. + + Returns: + The response. See :py:meth:`send_command` for details. + """ + return self._send_xml_command(XmlCommand("describe_auth")) + + def modify_auth(self, group_name: str, auth_conf_settings: dict) -> Any: + """Modifies an existing auth. + + Arguments: + group_name: Name of the group to be modified. + auth_conf_settings: The new auth config. + + Returns: + The response. See :py:meth:`send_command` for details. + """ + if not group_name: + raise RequiredArgument( + function=self.modify_auth.__name__, argument='group_name' + ) + if not auth_conf_settings: + raise RequiredArgument( + function=self.modify_auth.__name__, + argument='auth_conf_settings', + ) + cmd = XmlCommand("modify_auth") + _xmlgroup = cmd.add_element("group", attrs={"name": str(group_name)}) + + for key, value in auth_conf_settings.items(): + _xmlauthconf = _xmlgroup.add_element("auth_conf_setting") + _xmlauthconf.add_element("key", key) + _xmlauthconf.add_element("value", value) + + return self._send_xml_command(cmd) diff --git a/gvm/protocols/gmpv208/gmpv208.py b/gvm/protocols/gmpv208/gmpv208.py index b31a16258..4c0056609 100644 --- a/gvm/protocols/gmpv208/gmpv208.py +++ b/gvm/protocols/gmpv208/gmpv208.py @@ -30,12 +30,11 @@ from typing import Any, Optional -from gvm.errors import InvalidArgument, RequiredArgument +from gvm.errors import InvalidArgument from gvm.protocols.base import GvmProtocol from gvm.utils import ( - check_command_status, to_bool, ) from gvm.xml import XmlCommand @@ -47,86 +46,6 @@ class GmpV208Mixin(GvmProtocol): - """Python interface for Greenbone Management Protocol - - This class implements the `Greenbone Management Protocol version 20.08`_ - - Arguments: - connection: Connection to use to talk with the gvmd daemon. See - :mod:`gvm.connections` for possible connection types. - transform: Optional transform `callable`_ to convert response data. - After each request the callable gets passed the plain response data - which can be used to check the data and/or conversion into different - representations like a xml dom. - - See :mod:`gvm.transforms` for existing transforms. - - .. _Greenbone Management Protocol version 20.08: - https://docs.greenbone.net/API/GMP/gmp-20.08.html - .. _callable: - https://docs.python.org/3/library/functions.html#callable - """ - - def is_authenticated(self) -> bool: - """Checks if the user is authenticated - - If the user is authenticated privileged GMP commands like get_tasks - may be send to gvmd. - - Returns: - bool: True if an authenticated connection to gvmd has been - established. - """ - return self._authenticated - - def authenticate(self, username: str, password: str) -> Any: - """Authenticate to gvmd. - - The generated authenticate command will be send to server. - Afterwards the response is read, transformed and returned. - - Arguments: - username: Username - password: Password - - Returns: - Transformed response from server. - """ - cmd = XmlCommand("authenticate") - - if not username: - raise RequiredArgument( - function=self.authenticate.__name__, argument='username' - ) - - if not password: - raise RequiredArgument( - function=self.authenticate.__name__, argument='password' - ) - - credentials = cmd.add_element("credentials") - credentials.add_element("username", username) - credentials.add_element("password", password) - - self._send(cmd.to_string()) - response = self._read() - - if check_command_status(response): - self._authenticated = True - - return self._transform(response) - - def describe_auth(self) -> Any: - """Describe authentication methods - - Returns a list of all used authentication methods if such a list is - available. - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("describe_auth")) - def get_system_reports( self, *, @@ -220,35 +139,6 @@ def help( return self._send_xml_command(cmd) - def modify_auth(self, group_name: str, auth_conf_settings: dict) -> Any: - """Modifies an existing auth. - - Arguments: - group_name: Name of the group to be modified. - auth_conf_settings: The new auth config. - - Returns: - The response. See :py:meth:`send_command` for details. - """ - if not group_name: - raise RequiredArgument( - function=self.modify_auth.__name__, argument='group_name' - ) - if not auth_conf_settings: - raise RequiredArgument( - function=self.modify_auth.__name__, - argument='auth_conf_settings', - ) - cmd = XmlCommand("modify_auth") - _xmlgroup = cmd.add_element("group", attrs={"name": str(group_name)}) - - for key, value in auth_conf_settings.items(): - _xmlauthconf = _xmlgroup.add_element("auth_conf_setting") - _xmlauthconf.add_element("key", key) - _xmlauthconf.add_element("value", value) - - return self._send_xml_command(cmd) - def sync_cert(self) -> Any: """Request a synchronization with the CERT feed service diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index f7e912914..919cc6ba4 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -45,6 +45,7 @@ get_alert_method_from_string, ) from gvm.protocols.gmpv208.entities.audits import AuditsMixin +from gvm.protocols.gmpv208.entities.authentication import AuthenticationMixin from gvm.protocols.gmpv208.entities.credentials import ( CredentialFormat, CredentialsMixin, @@ -154,6 +155,7 @@ class Gmp( AggregatesMixin, AlertsMixin, AuditsMixin, + AuthenticationMixin, CredentialsMixin, FeedsMixin, FiltersMixin, From dd91dacdf2304e68f1dae6a93553c2d6268bf042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 17:25:15 +0200 Subject: [PATCH 03/15] Move missed feed functions into FeedMixin --- gvm/protocols/gmpv208/entities/feeds.py | 16 ++++++++++++++++ gvm/protocols/gmpv208/gmpv208.py | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gvm/protocols/gmpv208/entities/feeds.py b/gvm/protocols/gmpv208/entities/feeds.py index 390afdc07..8b5756a44 100644 --- a/gvm/protocols/gmpv208/entities/feeds.py +++ b/gvm/protocols/gmpv208/entities/feeds.py @@ -90,3 +90,19 @@ def sync_feed(self) -> Any: The response. See :py:meth:`send_command` for details. """ return self._send_xml_command(XmlCommand("sync_feed")) + + def sync_cert(self) -> Any: + """Request a synchronization with the CERT feed service + + Returns: + The response. See :py:meth:`send_command` for details. + """ + return self._send_xml_command(XmlCommand("sync_cert")) + + def sync_scap(self) -> Any: + """Request a synchronization with the SCAP feed service + + Returns: + The response. See :py:meth:`send_command` for details. + """ + return self._send_xml_command(XmlCommand("sync_scap")) diff --git a/gvm/protocols/gmpv208/gmpv208.py b/gvm/protocols/gmpv208/gmpv208.py index 4c0056609..b09d8af18 100644 --- a/gvm/protocols/gmpv208/gmpv208.py +++ b/gvm/protocols/gmpv208/gmpv208.py @@ -138,19 +138,3 @@ def help( cmd.set_attribute("format", format) return self._send_xml_command(cmd) - - def sync_cert(self) -> Any: - """Request a synchronization with the CERT feed service - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("sync_cert")) - - def sync_scap(self) -> Any: - """Request a synchronization with the SCAP feed service - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("sync_scap")) From 7b9ac9831e0975cf03083d45b840a920f423562a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 17:29:45 +0200 Subject: [PATCH 04/15] Move Missed Feed tests into new structure --- .../gmpv208/entities/feeds/__init__.py | 2 ++ .../feeds}/test_sync_cert.py | 2 +- .../feeds}/test_sync_scap.py | 2 +- tests/protocols/gmpv208/entities/test_feeds.py | 10 ++++++++++ tests/protocols/gmpv208/test_new_gmpv208.py | 12 ------------ tests/protocols/gmpv208/testcmds/__init__.py | 2 -- tests/protocols/gmpv214/entities/test_feeds.py | 18 ++++++++++++++---- .../gmpv214/test_v208_from_gmpv214.py | 12 ------------ 8 files changed, 28 insertions(+), 32 deletions(-) rename tests/protocols/gmpv208/{testcmds => entities/feeds}/test_sync_cert.py (96%) rename tests/protocols/gmpv208/{testcmds => entities/feeds}/test_sync_scap.py (96%) diff --git a/tests/protocols/gmpv208/entities/feeds/__init__.py b/tests/protocols/gmpv208/entities/feeds/__init__.py index 4f27dca09..30640d44b 100644 --- a/tests/protocols/gmpv208/entities/feeds/__init__.py +++ b/tests/protocols/gmpv208/entities/feeds/__init__.py @@ -19,3 +19,5 @@ from .test_get_feed import GmpGetFeedTestMixin from .test_get_feeds import GmpGetFeedsTestMixin from .test_sync_feed import GmpSyncFeedTestMixin +from .test_sync_cert import GmpSyncCertTestMixin +from .test_sync_scap import GmpSyncScapTestMixin diff --git a/tests/protocols/gmpv208/testcmds/test_sync_cert.py b/tests/protocols/gmpv208/entities/feeds/test_sync_cert.py similarity index 96% rename from tests/protocols/gmpv208/testcmds/test_sync_cert.py rename to tests/protocols/gmpv208/entities/feeds/test_sync_cert.py index 0844c61d1..2e1e388d7 100644 --- a/tests/protocols/gmpv208/testcmds/test_sync_cert.py +++ b/tests/protocols/gmpv208/entities/feeds/test_sync_cert.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -class GmpSyncCertCommandTestCase: +class GmpSyncCertTestMixin: def test_sync_cert(self): self.gmp.sync_cert() diff --git a/tests/protocols/gmpv208/testcmds/test_sync_scap.py b/tests/protocols/gmpv208/entities/feeds/test_sync_scap.py similarity index 96% rename from tests/protocols/gmpv208/testcmds/test_sync_scap.py rename to tests/protocols/gmpv208/entities/feeds/test_sync_scap.py index 7e0c8a9c1..639575e2a 100644 --- a/tests/protocols/gmpv208/testcmds/test_sync_scap.py +++ b/tests/protocols/gmpv208/entities/feeds/test_sync_scap.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -class GmpSyncScapCommandTestCase: +class GmpSyncScapTestMixin: def test_sync_scap(self): self.gmp.sync_scap() diff --git a/tests/protocols/gmpv208/entities/test_feeds.py b/tests/protocols/gmpv208/entities/test_feeds.py index 4a10a4576..dcc8a96d7 100644 --- a/tests/protocols/gmpv208/entities/test_feeds.py +++ b/tests/protocols/gmpv208/entities/test_feeds.py @@ -20,7 +20,9 @@ from .feeds import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, + GmpSyncCertTestMixin, GmpSyncFeedTestMixin, + GmpSyncScapTestMixin, ) @@ -32,5 +34,13 @@ class Gmpv208GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv208TestCase): pass +class Gmpv208SyncCertTestMixin(GmpSyncCertTestMixin, Gmpv208TestCase): + pass + + class Gmpv208SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv208TestCase): pass + + +class Gmpv208SyncScapTestMixin(GmpSyncScapTestMixin, Gmpv208TestCase): + pass diff --git a/tests/protocols/gmpv208/test_new_gmpv208.py b/tests/protocols/gmpv208/test_new_gmpv208.py index f5fbce557..61110a78d 100644 --- a/tests/protocols/gmpv208/test_new_gmpv208.py +++ b/tests/protocols/gmpv208/test_new_gmpv208.py @@ -60,17 +60,5 @@ class Gmpv208RestoreTestCase(GmpRestoreTestCase, Gmpv208TestCase): pass -class Gmpv208SyncCertCommandTestCase( - GmpSyncCertCommandTestCase, Gmpv208TestCase -): - pass - - -class Gmpv208SyncScapCommandTestCase( - GmpSyncScapCommandTestCase, Gmpv208TestCase -): - pass - - class Gmpv208v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv208TestCase): pass diff --git a/tests/protocols/gmpv208/testcmds/__init__.py b/tests/protocols/gmpv208/testcmds/__init__.py index 89f4ec681..6329ae8d6 100644 --- a/tests/protocols/gmpv208/testcmds/__init__.py +++ b/tests/protocols/gmpv208/testcmds/__init__.py @@ -27,6 +27,4 @@ from .test_help import GmpHelpTestCase from .test_modify_auth import GmpModifyAuthTestCase from .test_restore_from_trashcan import GmpRestoreTestCase -from .test_sync_cert import GmpSyncCertCommandTestCase -from .test_sync_scap import GmpSyncScapCommandTestCase from .test_with_statement import GmpWithStatementTestCase diff --git a/tests/protocols/gmpv214/entities/test_feeds.py b/tests/protocols/gmpv214/entities/test_feeds.py index 498bbcb90..c56064f05 100644 --- a/tests/protocols/gmpv214/entities/test_feeds.py +++ b/tests/protocols/gmpv214/entities/test_feeds.py @@ -16,21 +16,31 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from ...gmpv208 import Gmpv208TestCase +from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.feeds import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, + GmpSyncCertTestMixin, GmpSyncFeedTestMixin, + GmpSyncScapTestMixin, ) -class Gmpv208GetFeedTestCase(GmpGetFeedTestMixin, Gmpv208TestCase): +class Gmpv214GetFeedTestCase(GmpGetFeedTestMixin, Gmpv214TestCase): pass -class Gmpv208GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv208TestCase): +class Gmpv214GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv214TestCase): pass -class Gmpv208SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv208TestCase): +class Gmpv214SyncCertTestMixin(GmpSyncCertTestMixin, Gmpv214TestCase): + pass + + +class Gmpv214SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv214TestCase): + pass + + +class Gmpv214SyncScapTestMixin(GmpSyncScapTestMixin, Gmpv214TestCase): pass diff --git a/tests/protocols/gmpv214/test_v208_from_gmpv214.py b/tests/protocols/gmpv214/test_v208_from_gmpv214.py index 0edae8910..ab87eee80 100644 --- a/tests/protocols/gmpv214/test_v208_from_gmpv214.py +++ b/tests/protocols/gmpv214/test_v208_from_gmpv214.py @@ -60,17 +60,5 @@ class Gmpv214RestoreTestCase(GmpRestoreTestCase, Gmpv214TestCase): pass -class Gmpv214SyncCertCommandTestCase( - GmpSyncCertCommandTestCase, Gmpv214TestCase -): - pass - - -class Gmpv214SyncScapCommandTestCase( - GmpSyncScapCommandTestCase, Gmpv214TestCase -): - pass - - class Gmpv214v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv214TestCase): pass From 53a987be4da0db17e451cc865d4bc1488f8d2152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 21:23:05 +0200 Subject: [PATCH 05/15] Moved the authentication tests into new structure --- .../entities/authentication/__init__.py | 21 ++++++++++ .../authentication}/test_authenticate.py | 2 +- .../authentication}/test_describe_auth.py | 2 +- .../authentication}/test_modify_auth.py | 2 +- .../gmpv208/entities/test_authentication.py | 38 +++++++++++++++++++ tests/protocols/gmpv208/test_new_gmpv208.py | 14 ------- tests/protocols/gmpv208/testcmds/__init__.py | 4 +- .../gmpv214/entities/test_authentication.py | 38 +++++++++++++++++++ .../gmpv214/test_v208_from_gmpv214.py | 14 ------- 9 files changed, 101 insertions(+), 34 deletions(-) create mode 100644 tests/protocols/gmpv208/entities/authentication/__init__.py rename tests/protocols/gmpv208/{testcmds => entities/authentication}/test_authenticate.py (98%) rename tests/protocols/gmpv208/{testcmds => entities/authentication}/test_describe_auth.py (95%) rename tests/protocols/gmpv208/{testcmds => entities/authentication}/test_modify_auth.py (98%) create mode 100644 tests/protocols/gmpv208/entities/test_authentication.py create mode 100644 tests/protocols/gmpv214/entities/test_authentication.py diff --git a/tests/protocols/gmpv208/entities/authentication/__init__.py b/tests/protocols/gmpv208/entities/authentication/__init__.py new file mode 100644 index 000000000..b95b49d89 --- /dev/null +++ b/tests/protocols/gmpv208/entities/authentication/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from .test_authenticate import GmpAuthenticateTestMixin +from .test_describe_auth import GmpDescribeAuthTestMixin +from .test_modify_auth import GmpModifyAuthTestMixin diff --git a/tests/protocols/gmpv208/testcmds/test_authenticate.py b/tests/protocols/gmpv208/entities/authentication/test_authenticate.py similarity index 98% rename from tests/protocols/gmpv208/testcmds/test_authenticate.py rename to tests/protocols/gmpv208/entities/authentication/test_authenticate.py index 304068d1f..d446789d7 100644 --- a/tests/protocols/gmpv208/testcmds/test_authenticate.py +++ b/tests/protocols/gmpv208/entities/authentication/test_authenticate.py @@ -19,7 +19,7 @@ from gvm.errors import RequiredArgument -class GmpAuthenticateTestCase: +class GmpAuthenticateTestMixin: def test_missing_username(self): with self.assertRaises(RequiredArgument): self.gmp.authenticate(None, 'foo') diff --git a/tests/protocols/gmpv208/testcmds/test_describe_auth.py b/tests/protocols/gmpv208/entities/authentication/test_describe_auth.py similarity index 95% rename from tests/protocols/gmpv208/testcmds/test_describe_auth.py rename to tests/protocols/gmpv208/entities/authentication/test_describe_auth.py index 8d47679a9..7a3099f7f 100644 --- a/tests/protocols/gmpv208/testcmds/test_describe_auth.py +++ b/tests/protocols/gmpv208/entities/authentication/test_describe_auth.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -class GmpDescribeAuthCommandTestCase: +class GmpDescribeAuthTestMixin: def test_describe_auth(self): self.gmp.describe_auth() diff --git a/tests/protocols/gmpv208/testcmds/test_modify_auth.py b/tests/protocols/gmpv208/entities/authentication/test_modify_auth.py similarity index 98% rename from tests/protocols/gmpv208/testcmds/test_modify_auth.py rename to tests/protocols/gmpv208/entities/authentication/test_modify_auth.py index e1c4a15d2..2e163dc61 100644 --- a/tests/protocols/gmpv208/testcmds/test_modify_auth.py +++ b/tests/protocols/gmpv208/entities/authentication/test_modify_auth.py @@ -21,7 +21,7 @@ from gvm.errors import RequiredArgument -class GmpModifyAuthTestCase: +class GmpModifyAuthTestMixin: def test_modify_auth(self): self.gmp.modify_auth( 'foo', OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')]) diff --git a/tests/protocols/gmpv208/entities/test_authentication.py b/tests/protocols/gmpv208/entities/test_authentication.py new file mode 100644 index 000000000..f29c62494 --- /dev/null +++ b/tests/protocols/gmpv208/entities/test_authentication.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ...gmpv208 import Gmpv208TestCase +from .authentication import ( + GmpAuthenticateTestMixin, + GmpDescribeAuthTestMixin, + GmpModifyAuthTestMixin, +) + + +class Gmpv208AuthenticateTestCase(GmpAuthenticateTestMixin, Gmpv208TestCase): + pass + + +class Gmpv208ModifyAuthTestCase(GmpModifyAuthTestMixin, Gmpv208TestCase): + pass + + +class Gmpv208DescribeAuthCommandTestCase( + GmpDescribeAuthTestMixin, Gmpv208TestCase +): + pass diff --git a/tests/protocols/gmpv208/test_new_gmpv208.py b/tests/protocols/gmpv208/test_new_gmpv208.py index 61110a78d..4453b322a 100644 --- a/tests/protocols/gmpv208/test_new_gmpv208.py +++ b/tests/protocols/gmpv208/test_new_gmpv208.py @@ -20,20 +20,10 @@ from .testcmds import * # pylint: disable=unused-wildcard-import, wildcard-import -class Gmpv208AuthenticateTestCase(GmpAuthenticateTestCase, Gmpv208TestCase): - pass - - class Gmpv208HelpTestCase(GmpHelpTestCase, Gmpv208TestCase): pass -class Gmpv208DescribeAuthCommandTestCase( - GmpDescribeAuthCommandTestCase, Gmpv208TestCase -): - pass - - class Gmpv208EmptyTrashcanCommandTestCase( GmpEmptyTrashcanCommandTestCase, Gmpv208TestCase ): @@ -52,10 +42,6 @@ class Gmpv208GetVersionCommandTestCase( pass -class Gmpv208ModifyAuthTestCase(GmpModifyAuthTestCase, Gmpv208TestCase): - pass - - class Gmpv208RestoreTestCase(GmpRestoreTestCase, Gmpv208TestCase): pass diff --git a/tests/protocols/gmpv208/testcmds/__init__.py b/tests/protocols/gmpv208/testcmds/__init__.py index 6329ae8d6..db627508b 100644 --- a/tests/protocols/gmpv208/testcmds/__init__.py +++ b/tests/protocols/gmpv208/testcmds/__init__.py @@ -19,12 +19,10 @@ # pylint: disable=no-member from .test_protocol_version import GmpProtocolVersionTestCase -from .test_authenticate import GmpAuthenticateTestCase -from .test_describe_auth import GmpDescribeAuthCommandTestCase + from .test_empty_trashcan import GmpEmptyTrashcanCommandTestCase from .test_get_system_reports import GmpGetSystemReportsTestCase from .test_get_version import GmpGetVersionCommandTestCase from .test_help import GmpHelpTestCase -from .test_modify_auth import GmpModifyAuthTestCase from .test_restore_from_trashcan import GmpRestoreTestCase from .test_with_statement import GmpWithStatementTestCase diff --git a/tests/protocols/gmpv214/entities/test_authentication.py b/tests/protocols/gmpv214/entities/test_authentication.py new file mode 100644 index 000000000..26826eee3 --- /dev/null +++ b/tests/protocols/gmpv214/entities/test_authentication.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ...gmpv214 import Gmpv214TestCase +from ...gmpv208.entities.authentication import ( + GmpAuthenticateTestMixin, + GmpDescribeAuthTestMixin, + GmpModifyAuthTestMixin, +) + + +class Gmpv214AuthenticateTestCase(GmpAuthenticateTestMixin, Gmpv214TestCase): + pass + + +class Gmpv214ModifyAuthTestCase(GmpModifyAuthTestMixin, Gmpv214TestCase): + pass + + +class Gmpv214DescribeAuthCommandTestCase( + GmpDescribeAuthTestMixin, Gmpv214TestCase +): + pass diff --git a/tests/protocols/gmpv214/test_v208_from_gmpv214.py b/tests/protocols/gmpv214/test_v208_from_gmpv214.py index ab87eee80..570e88cf0 100644 --- a/tests/protocols/gmpv214/test_v208_from_gmpv214.py +++ b/tests/protocols/gmpv214/test_v208_from_gmpv214.py @@ -20,20 +20,10 @@ from ..gmpv208.testcmds import * # pylint: disable=unused-wildcard-import,wildcard-import -class Gmpv214AuthenticateTestCase(GmpAuthenticateTestCase, Gmpv214TestCase): - pass - - class Gmpv214HelpTestCase(GmpHelpTestCase, Gmpv214TestCase): pass -class Gmpv214DescribeAuthCommandTestCase( - GmpDescribeAuthCommandTestCase, Gmpv214TestCase -): - pass - - class Gmpv214EmptyTrashcanCommandTestCase( GmpEmptyTrashcanCommandTestCase, Gmpv214TestCase ): @@ -52,10 +42,6 @@ class Gmpv214GetVersionCommandTestCase( pass -class Gmpv214ModifyAuthTestCase(GmpModifyAuthTestCase, Gmpv214TestCase): - pass - - class Gmpv214RestoreTestCase(GmpRestoreTestCase, Gmpv214TestCase): pass From 41f0fc5a4f38380eb7eb080e456fc1f5b090f98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 21:30:59 +0200 Subject: [PATCH 06/15] Moved Trashcan tests to new structure --- .../gmpv208/entities/test_trashcan.py | 33 +++++++++++++++++++ .../gmpv208/entities/trashcan/__init__.py | 20 +++++++++++ .../trashcan}/test_empty_trashcan.py | 2 +- .../trashcan}/test_restore_from_trashcan.py | 6 ++-- tests/protocols/gmpv208/test_new_gmpv208.py | 10 ------ tests/protocols/gmpv208/testcmds/__init__.py | 2 -- .../gmpv214/entities/test_trashcan.py | 33 +++++++++++++++++++ .../gmpv214/test_v208_from_gmpv214.py | 10 ------ 8 files changed, 90 insertions(+), 26 deletions(-) create mode 100644 tests/protocols/gmpv208/entities/test_trashcan.py create mode 100644 tests/protocols/gmpv208/entities/trashcan/__init__.py rename tests/protocols/gmpv208/{testcmds => entities/trashcan}/test_empty_trashcan.py (95%) rename tests/protocols/gmpv208/{testcmds => entities/trashcan}/test_restore_from_trashcan.py (89%) create mode 100644 tests/protocols/gmpv214/entities/test_trashcan.py diff --git a/tests/protocols/gmpv208/entities/test_trashcan.py b/tests/protocols/gmpv208/entities/test_trashcan.py new file mode 100644 index 000000000..4b2e89c57 --- /dev/null +++ b/tests/protocols/gmpv208/entities/test_trashcan.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ...gmpv208 import Gmpv208TestCase +from .trashcan import ( + GmpEmptyTrashcanTestMixin, + GmpRestoreFromTrashcanTestMixin, +) + + +class Gmpv208EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv208TestCase): + pass + + +class Gmpv208RestoreFromTrashcanTestCase( + GmpRestoreFromTrashcanTestMixin, Gmpv208TestCase +): + pass diff --git a/tests/protocols/gmpv208/entities/trashcan/__init__.py b/tests/protocols/gmpv208/entities/trashcan/__init__.py new file mode 100644 index 000000000..c174afe91 --- /dev/null +++ b/tests/protocols/gmpv208/entities/trashcan/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from .test_empty_trashcan import GmpEmptyTrashcanTestMixin +from .test_restore_from_trashcan import GmpRestoreFromTrashcanTestMixin diff --git a/tests/protocols/gmpv208/testcmds/test_empty_trashcan.py b/tests/protocols/gmpv208/entities/trashcan/test_empty_trashcan.py similarity index 95% rename from tests/protocols/gmpv208/testcmds/test_empty_trashcan.py rename to tests/protocols/gmpv208/entities/trashcan/test_empty_trashcan.py index 7b8280c93..0d583c98d 100644 --- a/tests/protocols/gmpv208/testcmds/test_empty_trashcan.py +++ b/tests/protocols/gmpv208/entities/trashcan/test_empty_trashcan.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -class GmpEmptyTrashcanCommandTestCase: +class GmpEmptyTrashcanTestMixin: def test_empty_trashcan(self): self.gmp.empty_trashcan() diff --git a/tests/protocols/gmpv208/testcmds/test_restore_from_trashcan.py b/tests/protocols/gmpv208/entities/trashcan/test_restore_from_trashcan.py similarity index 89% rename from tests/protocols/gmpv208/testcmds/test_restore_from_trashcan.py rename to tests/protocols/gmpv208/entities/trashcan/test_restore_from_trashcan.py index f7411424a..fea1c9f24 100644 --- a/tests/protocols/gmpv208/testcmds/test_restore_from_trashcan.py +++ b/tests/protocols/gmpv208/entities/trashcan/test_restore_from_trashcan.py @@ -19,13 +19,13 @@ from gvm.errors import GvmError -class GmpRestoreTestCase: - def test_restore(self): +class GmpRestoreFromTrashcanTestMixin: + def test_restore_from_trashcan(self): self.gmp.restore_from_trashcan('a1') self.connection.send.has_been_called_with('') - def test_missing_id(self): + def test_restore_from_trashcan_missing_id(self): with self.assertRaises(GvmError): self.gmp.restore_from_trashcan(None) diff --git a/tests/protocols/gmpv208/test_new_gmpv208.py b/tests/protocols/gmpv208/test_new_gmpv208.py index 4453b322a..f233489a9 100644 --- a/tests/protocols/gmpv208/test_new_gmpv208.py +++ b/tests/protocols/gmpv208/test_new_gmpv208.py @@ -24,12 +24,6 @@ class Gmpv208HelpTestCase(GmpHelpTestCase, Gmpv208TestCase): pass -class Gmpv208EmptyTrashcanCommandTestCase( - GmpEmptyTrashcanCommandTestCase, Gmpv208TestCase -): - pass - - class Gmpv208GetSystemReportsTestCase( GmpGetSystemReportsTestCase, Gmpv208TestCase ): @@ -42,9 +36,5 @@ class Gmpv208GetVersionCommandTestCase( pass -class Gmpv208RestoreTestCase(GmpRestoreTestCase, Gmpv208TestCase): - pass - - class Gmpv208v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv208TestCase): pass diff --git a/tests/protocols/gmpv208/testcmds/__init__.py b/tests/protocols/gmpv208/testcmds/__init__.py index db627508b..dc9e4e448 100644 --- a/tests/protocols/gmpv208/testcmds/__init__.py +++ b/tests/protocols/gmpv208/testcmds/__init__.py @@ -20,9 +20,7 @@ from .test_protocol_version import GmpProtocolVersionTestCase -from .test_empty_trashcan import GmpEmptyTrashcanCommandTestCase from .test_get_system_reports import GmpGetSystemReportsTestCase from .test_get_version import GmpGetVersionCommandTestCase from .test_help import GmpHelpTestCase -from .test_restore_from_trashcan import GmpRestoreTestCase from .test_with_statement import GmpWithStatementTestCase diff --git a/tests/protocols/gmpv214/entities/test_trashcan.py b/tests/protocols/gmpv214/entities/test_trashcan.py new file mode 100644 index 000000000..cde54de7e --- /dev/null +++ b/tests/protocols/gmpv214/entities/test_trashcan.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ...gmpv214 import Gmpv214TestCase +from ...gmpv208.entities.trashcan import ( + GmpEmptyTrashcanTestMixin, + GmpRestoreFromTrashcanTestMixin, +) + + +class Gmpv214EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv214TestCase): + pass + + +class Gmpv214RestoreFromTrashcanTestCase( + GmpRestoreFromTrashcanTestMixin, Gmpv214TestCase +): + pass diff --git a/tests/protocols/gmpv214/test_v208_from_gmpv214.py b/tests/protocols/gmpv214/test_v208_from_gmpv214.py index 570e88cf0..0684356eb 100644 --- a/tests/protocols/gmpv214/test_v208_from_gmpv214.py +++ b/tests/protocols/gmpv214/test_v208_from_gmpv214.py @@ -24,12 +24,6 @@ class Gmpv214HelpTestCase(GmpHelpTestCase, Gmpv214TestCase): pass -class Gmpv214EmptyTrashcanCommandTestCase( - GmpEmptyTrashcanCommandTestCase, Gmpv214TestCase -): - pass - - class Gmpv214GetSystemReportsTestCase( GmpGetSystemReportsTestCase, Gmpv214TestCase ): @@ -42,9 +36,5 @@ class Gmpv214GetVersionCommandTestCase( pass -class Gmpv214RestoreTestCase(GmpRestoreTestCase, Gmpv214TestCase): - pass - - class Gmpv214v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv214TestCase): pass From 404ba620dfb6836e98449fc0c1ea24cbc7f7c131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:21:19 +0200 Subject: [PATCH 07/15] Introduce system dir, non entity call will move here, detached Versions calls to VersionsMixin --- gvm/protocols/gmpv208/__init__.py | 15 +++----- gvm/protocols/gmpv208/gmpv208.py | 9 ----- gvm/protocols/gmpv208/system/__init__.py | 17 +++++++++ gvm/protocols/gmpv208/system/version.py | 44 ++++++++++++++++++++++++ gvm/protocols/gmpv214/__init__.py | 14 ++------ gvm/protocols/gmpv214/system/__init__.py | 17 +++++++++ gvm/protocols/gmpv214/system/version.py | 36 +++++++++++++++++++ 7 files changed, 121 insertions(+), 31 deletions(-) create mode 100644 gvm/protocols/gmpv208/system/__init__.py create mode 100644 gvm/protocols/gmpv208/system/version.py create mode 100644 gvm/protocols/gmpv214/system/__init__.py create mode 100644 gvm/protocols/gmpv214/system/version.py diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index ae4a982d2..425020a0c 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -139,9 +139,10 @@ get_user_auth_type_from_string, ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin -from gvm.connections import GvmConnection -PROTOCOL_VERSION = (20, 8) +from gvm.protocols.gmpv208.system.version import VersionMixin + +from gvm.connections import GvmConnection class Gmp( @@ -178,6 +179,7 @@ class Gmp( SecInfoMixin, UserSettingsMixin, UsersMixin, + VersionMixin, VulnerabilitiesMixin, ): """Python interface for Greenbone Management Protocol @@ -210,12 +212,3 @@ def __init__( # Is authenticated on gvmd self._authenticated = False - - @staticmethod - def get_protocol_version() -> tuple: - """Determine the Greenbone Management Protocol version. - - Returns: - tuple: Implemented version of the Greenbone Management Protocol - """ - return PROTOCOL_VERSION diff --git a/gvm/protocols/gmpv208/gmpv208.py b/gvm/protocols/gmpv208/gmpv208.py index b09d8af18..ac898c453 100644 --- a/gvm/protocols/gmpv208/gmpv208.py +++ b/gvm/protocols/gmpv208/gmpv208.py @@ -39,8 +39,6 @@ ) from gvm.xml import XmlCommand -PROTOCOL_VERSION = (20, 8) - logger = logging.getLogger(__name__) @@ -97,13 +95,6 @@ def get_system_reports( return self._send_xml_command(cmd) - def get_version(self) -> Any: - """Get the Greenbone Manager Protocol version used by the remote gvmd - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("get_version")) - def help( self, *, format: Optional[str] = None, help_type: Optional[str] = None ) -> Any: diff --git a/gvm/protocols/gmpv208/system/__init__.py b/gvm/protocols/gmpv208/system/__init__.py new file mode 100644 index 000000000..bf0aeeb09 --- /dev/null +++ b/gvm/protocols/gmpv208/system/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . diff --git a/gvm/protocols/gmpv208/system/version.py b/gvm/protocols/gmpv208/system/version.py new file mode 100644 index 000000000..913472058 --- /dev/null +++ b/gvm/protocols/gmpv208/system/version.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from typing import Any + +from gvm.xml import XmlCommand + +PROTOCOL_VERSION = (20, 8) + + +class VersionMixin: + def get_version(self) -> Any: + """Get the Greenbone Vulnerability Manager Protocol version used + by the remote gvmd. + + Returns: + The response. See :py:meth:`send_command` for details. + """ + return self._send_xml_command(XmlCommand("get_version")) + + @staticmethod + def get_protocol_version() -> tuple: + """Determine the Greenbone Management Protocol (gmp) version used + by python-gvm version. + + Returns: + tuple: Implemented version of the Greenbone Management Protocol + """ + return PROTOCOL_VERSION diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index 919cc6ba4..d2686ab1e 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -145,9 +145,9 @@ ) from gvm.protocols.gmpv214.entities.users import UsersMixin -from gvm.connections import GvmConnection +from gvm.protocols.gmpv214.system.version import VersionMixin -PROTOCOL_VERSION = (21, 4) +from gvm.connections import GvmConnection class Gmp( @@ -184,6 +184,7 @@ class Gmp( SecInfoMixin, UserSettingsMixin, UsersMixin, + VersionMixin, VulnerabilitiesMixin, ): def __init__( @@ -196,12 +197,3 @@ def __init__( # Is authenticated on gvmd self._authenticated = False - - @staticmethod - def get_protocol_version() -> tuple: - """Determine the Greenbone Management Protocol version. - - Returns: - tuple: Implemented version of the Greenbone Management Protocol - """ - return PROTOCOL_VERSION diff --git a/gvm/protocols/gmpv214/system/__init__.py b/gvm/protocols/gmpv214/system/__init__.py new file mode 100644 index 000000000..bf0aeeb09 --- /dev/null +++ b/gvm/protocols/gmpv214/system/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . diff --git a/gvm/protocols/gmpv214/system/version.py b/gvm/protocols/gmpv214/system/version.py new file mode 100644 index 000000000..45abdef6d --- /dev/null +++ b/gvm/protocols/gmpv214/system/version.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +from gvm.protocols.gmpv208.system.version import ( + VersionMixin as Gmp208VersionMixin, +) + +PROTOCOL_VERSION = (21, 4) + + +class VersionMixin(Gmp208VersionMixin): + @staticmethod + def get_protocol_version() -> tuple: + """Determine the Greenbone Management Protocol (gmp) version used + by python-gvm version. + + Returns: + tuple: Implemented version of the Greenbone Management Protocol + """ + return PROTOCOL_VERSION From 3602d21bef8ace749e6071b6f3075b1624a4e30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:24:58 +0200 Subject: [PATCH 08/15] Moved versions tests, reactivated tests for protocol version --- tests/protocols/gmpv208/system/__init__.py | 17 ++++++++++ .../protocols/gmpv208/system/test_versions.py | 30 ++++++++++++++++++ .../gmpv208/system/versions/__init__.py | 20 ++++++++++++ .../versions/test_get_protocol_version.py} | 4 +-- .../versions}/test_get_version.py | 2 +- tests/protocols/gmpv208/test_new_gmpv208.py | 6 ---- tests/protocols/gmpv208/testcmds/__init__.py | 3 -- tests/protocols/gmpv214/system/__init__.py | 17 ++++++++++ .../protocols/gmpv214/system/test_versions.py | 31 +++++++++++++++++++ .../gmpv214/system/versions/__init__.py | 19 ++++++++++++ .../versions/test_get_protocol_version.py | 22 +++++++++++++ .../gmpv214/test_v208_from_gmpv214.py | 6 ---- 12 files changed, 159 insertions(+), 18 deletions(-) create mode 100644 tests/protocols/gmpv208/system/__init__.py create mode 100644 tests/protocols/gmpv208/system/test_versions.py create mode 100644 tests/protocols/gmpv208/system/versions/__init__.py rename tests/protocols/gmpv208/{testcmds/test_protocol_version.py => system/versions/test_get_protocol_version.py} (88%) rename tests/protocols/gmpv208/{testcmds => system/versions}/test_get_version.py (96%) create mode 100644 tests/protocols/gmpv214/system/__init__.py create mode 100644 tests/protocols/gmpv214/system/test_versions.py create mode 100644 tests/protocols/gmpv214/system/versions/__init__.py create mode 100644 tests/protocols/gmpv214/system/versions/test_get_protocol_version.py diff --git a/tests/protocols/gmpv208/system/__init__.py b/tests/protocols/gmpv208/system/__init__.py new file mode 100644 index 000000000..bf0aeeb09 --- /dev/null +++ b/tests/protocols/gmpv208/system/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . diff --git a/tests/protocols/gmpv208/system/test_versions.py b/tests/protocols/gmpv208/system/test_versions.py new file mode 100644 index 000000000..7dc4ce5a4 --- /dev/null +++ b/tests/protocols/gmpv208/system/test_versions.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ...gmpv208 import Gmpv208TestCase +from .versions import GmpGetVersionTestCase, GmpGetProtocolVersionTestCase + + +class Gmpv208GetVersionCommandTestCase(GmpGetVersionTestCase, Gmpv208TestCase): + pass + + +class Gmpv208GmpGetProtocolVersionTestCase( + GmpGetProtocolVersionTestCase, Gmpv208TestCase +): + pass diff --git a/tests/protocols/gmpv208/system/versions/__init__.py b/tests/protocols/gmpv208/system/versions/__init__.py new file mode 100644 index 000000000..06eee474f --- /dev/null +++ b/tests/protocols/gmpv208/system/versions/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from .test_get_protocol_version import GmpGetProtocolVersionTestCase +from .test_get_version import GmpGetVersionTestCase diff --git a/tests/protocols/gmpv208/testcmds/test_protocol_version.py b/tests/protocols/gmpv208/system/versions/test_get_protocol_version.py similarity index 88% rename from tests/protocols/gmpv208/testcmds/test_protocol_version.py rename to tests/protocols/gmpv208/system/versions/test_get_protocol_version.py index d6c935b08..656ac3b12 100644 --- a/tests/protocols/gmpv208/testcmds/test_protocol_version.py +++ b/tests/protocols/gmpv208/system/versions/test_get_protocol_version.py @@ -17,6 +17,6 @@ # along with this program. If not, see . -class GmpProtocolVersionTestCase: +class GmpGetProtocolVersionTestCase: def test_protocol_version(self): - self.assertEqual(self.gmp.get_protocol_version(), (8,)) + self.assertEqual(self.gmp.get_protocol_version(), (20, 8)) diff --git a/tests/protocols/gmpv208/testcmds/test_get_version.py b/tests/protocols/gmpv208/system/versions/test_get_version.py similarity index 96% rename from tests/protocols/gmpv208/testcmds/test_get_version.py rename to tests/protocols/gmpv208/system/versions/test_get_version.py index 85f4899c5..854babdec 100644 --- a/tests/protocols/gmpv208/testcmds/test_get_version.py +++ b/tests/protocols/gmpv208/system/versions/test_get_version.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -class GmpGetVersionCommandTestCase: +class GmpGetVersionTestCase: def test_get_version(self): self.gmp.get_version() diff --git a/tests/protocols/gmpv208/test_new_gmpv208.py b/tests/protocols/gmpv208/test_new_gmpv208.py index f233489a9..1e5cd51f2 100644 --- a/tests/protocols/gmpv208/test_new_gmpv208.py +++ b/tests/protocols/gmpv208/test_new_gmpv208.py @@ -30,11 +30,5 @@ class Gmpv208GetSystemReportsTestCase( pass -class Gmpv208GetVersionCommandTestCase( - GmpGetVersionCommandTestCase, Gmpv208TestCase -): - pass - - class Gmpv208v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv208TestCase): pass diff --git a/tests/protocols/gmpv208/testcmds/__init__.py b/tests/protocols/gmpv208/testcmds/__init__.py index dc9e4e448..618438dca 100644 --- a/tests/protocols/gmpv208/testcmds/__init__.py +++ b/tests/protocols/gmpv208/testcmds/__init__.py @@ -18,9 +18,6 @@ # pylint: disable=no-member -from .test_protocol_version import GmpProtocolVersionTestCase - from .test_get_system_reports import GmpGetSystemReportsTestCase -from .test_get_version import GmpGetVersionCommandTestCase from .test_help import GmpHelpTestCase from .test_with_statement import GmpWithStatementTestCase diff --git a/tests/protocols/gmpv214/system/__init__.py b/tests/protocols/gmpv214/system/__init__.py new file mode 100644 index 000000000..bf0aeeb09 --- /dev/null +++ b/tests/protocols/gmpv214/system/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . diff --git a/tests/protocols/gmpv214/system/test_versions.py b/tests/protocols/gmpv214/system/test_versions.py new file mode 100644 index 000000000..52becbd89 --- /dev/null +++ b/tests/protocols/gmpv214/system/test_versions.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from ...gmpv214 import Gmpv214TestCase +from ...gmpv208.system.versions import GmpGetVersionTestCase +from .versions import GmpGetProtocolVersionTestCase + + +class Gmpv214GetVersionCommandTestCase(GmpGetVersionTestCase, Gmpv214TestCase): + pass + + +class Gmpv214GmpGetProtocolVersionTestCase( + GmpGetProtocolVersionTestCase, Gmpv214TestCase +): + pass diff --git a/tests/protocols/gmpv214/system/versions/__init__.py b/tests/protocols/gmpv214/system/versions/__init__.py new file mode 100644 index 000000000..b4383b69e --- /dev/null +++ b/tests/protocols/gmpv214/system/versions/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from .test_get_protocol_version import GmpGetProtocolVersionTestCase diff --git a/tests/protocols/gmpv214/system/versions/test_get_protocol_version.py b/tests/protocols/gmpv214/system/versions/test_get_protocol_version.py new file mode 100644 index 000000000..1a2617ae9 --- /dev/null +++ b/tests/protocols/gmpv214/system/versions/test_get_protocol_version.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2019-2021 Greenbone Networks GmbH +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +class GmpGetProtocolVersionTestCase: + def test_protocol_version(self): + self.assertEqual(self.gmp.get_protocol_version(), (21, 4)) diff --git a/tests/protocols/gmpv214/test_v208_from_gmpv214.py b/tests/protocols/gmpv214/test_v208_from_gmpv214.py index 0684356eb..20cffad1c 100644 --- a/tests/protocols/gmpv214/test_v208_from_gmpv214.py +++ b/tests/protocols/gmpv214/test_v208_from_gmpv214.py @@ -30,11 +30,5 @@ class Gmpv214GetSystemReportsTestCase( pass -class Gmpv214GetVersionCommandTestCase( - GmpGetVersionCommandTestCase, Gmpv214TestCase -): - pass - - class Gmpv214v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv214TestCase): pass From f51db8d1a0caa501f581ae0e4becea0d2443372d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:33:10 +0200 Subject: [PATCH 09/15] Moved trashcan: entities->system --- gvm/protocols/gmpv208/__init__.py | 2 +- gvm/protocols/gmpv208/{entities => system}/trashcan.py | 0 gvm/protocols/gmpv214/__init__.py | 2 +- tests/protocols/gmpv208/{entities => system}/test_trashcan.py | 0 .../protocols/gmpv208/{entities => system}/trashcan/__init__.py | 0 .../{entities => system}/trashcan/test_empty_trashcan.py | 0 .../{entities => system}/trashcan/test_restore_from_trashcan.py | 0 tests/protocols/gmpv214/{entities => system}/test_trashcan.py | 2 +- 8 files changed, 3 insertions(+), 3 deletions(-) rename gvm/protocols/gmpv208/{entities => system}/trashcan.py (100%) rename tests/protocols/gmpv208/{entities => system}/test_trashcan.py (100%) rename tests/protocols/gmpv208/{entities => system}/trashcan/__init__.py (100%) rename tests/protocols/gmpv208/{entities => system}/trashcan/test_empty_trashcan.py (100%) rename tests/protocols/gmpv208/{entities => system}/trashcan/test_restore_from_trashcan.py (100%) rename tests/protocols/gmpv214/{entities => system}/test_trashcan.py (96%) diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index 425020a0c..c796843f8 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -131,7 +131,6 @@ get_ticket_status_from_string, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin -from gvm.protocols.gmpv208.entities.trashcan import TrashcanMixin from gvm.protocols.gmpv208.entities.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, @@ -140,6 +139,7 @@ ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin +from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin from gvm.protocols.gmpv208.system.version import VersionMixin from gvm.connections import GvmConnection diff --git a/gvm/protocols/gmpv208/entities/trashcan.py b/gvm/protocols/gmpv208/system/trashcan.py similarity index 100% rename from gvm/protocols/gmpv208/entities/trashcan.py rename to gvm/protocols/gmpv208/system/trashcan.py diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index d2686ab1e..26d305769 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -119,7 +119,6 @@ get_ticket_status_from_string, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin -from gvm.protocols.gmpv208.entities.trashcan import TrashcanMixin from gvm.protocols.gmpv208.entities.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, @@ -127,6 +126,7 @@ ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin +from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin from gvm.protocols.gmpv208.gmpv208 import GmpV208Mixin diff --git a/tests/protocols/gmpv208/entities/test_trashcan.py b/tests/protocols/gmpv208/system/test_trashcan.py similarity index 100% rename from tests/protocols/gmpv208/entities/test_trashcan.py rename to tests/protocols/gmpv208/system/test_trashcan.py diff --git a/tests/protocols/gmpv208/entities/trashcan/__init__.py b/tests/protocols/gmpv208/system/trashcan/__init__.py similarity index 100% rename from tests/protocols/gmpv208/entities/trashcan/__init__.py rename to tests/protocols/gmpv208/system/trashcan/__init__.py diff --git a/tests/protocols/gmpv208/entities/trashcan/test_empty_trashcan.py b/tests/protocols/gmpv208/system/trashcan/test_empty_trashcan.py similarity index 100% rename from tests/protocols/gmpv208/entities/trashcan/test_empty_trashcan.py rename to tests/protocols/gmpv208/system/trashcan/test_empty_trashcan.py diff --git a/tests/protocols/gmpv208/entities/trashcan/test_restore_from_trashcan.py b/tests/protocols/gmpv208/system/trashcan/test_restore_from_trashcan.py similarity index 100% rename from tests/protocols/gmpv208/entities/trashcan/test_restore_from_trashcan.py rename to tests/protocols/gmpv208/system/trashcan/test_restore_from_trashcan.py diff --git a/tests/protocols/gmpv214/entities/test_trashcan.py b/tests/protocols/gmpv214/system/test_trashcan.py similarity index 96% rename from tests/protocols/gmpv214/entities/test_trashcan.py rename to tests/protocols/gmpv214/system/test_trashcan.py index cde54de7e..0c7fbae45 100644 --- a/tests/protocols/gmpv214/entities/test_trashcan.py +++ b/tests/protocols/gmpv214/system/test_trashcan.py @@ -17,7 +17,7 @@ # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase -from ...gmpv208.entities.trashcan import ( +from ...gmpv208.system.trashcan import ( GmpEmptyTrashcanTestMixin, GmpRestoreFromTrashcanTestMixin, ) From 851406bb12f71b747b3786bd56eb7f2d735ec15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:37:13 +0200 Subject: [PATCH 10/15] Moved feed: feeds->feed | entities->system --- gvm/protocols/gmpv208/__init__.py | 12 ++++++------ .../gmpv208/{entities/feeds.py => system/feed.py} | 2 +- gvm/protocols/gmpv214/__init__.py | 12 ++++++------ .../{entities/feeds => system/feed}/__init__.py | 0 .../{entities/feeds => system/feed}/test_get_feed.py | 0 .../feeds => system/feed}/test_get_feeds.py | 0 .../feeds => system/feed}/test_sync_cert.py | 0 .../feeds => system/feed}/test_sync_feed.py | 0 .../feeds => system/feed}/test_sync_scap.py | 0 .../{entities/test_feeds.py => system/test_feed.py} | 2 +- .../{entities/test_feeds.py => system/test_feed.py} | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) rename gvm/protocols/gmpv208/{entities/feeds.py => system/feed.py} (99%) rename tests/protocols/gmpv208/{entities/feeds => system/feed}/__init__.py (100%) rename tests/protocols/gmpv208/{entities/feeds => system/feed}/test_get_feed.py (100%) rename tests/protocols/gmpv208/{entities/feeds => system/feed}/test_get_feeds.py (100%) rename tests/protocols/gmpv208/{entities/feeds => system/feed}/test_sync_cert.py (100%) rename tests/protocols/gmpv208/{entities/feeds => system/feed}/test_sync_feed.py (100%) rename tests/protocols/gmpv208/{entities/feeds => system/feed}/test_sync_scap.py (100%) rename tests/protocols/gmpv208/{entities/test_feeds.py => system/test_feed.py} (98%) rename tests/protocols/gmpv214/{entities/test_feeds.py => system/test_feed.py} (97%) diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index c796843f8..d0f488bc1 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -61,11 +61,6 @@ EntityType, get_entity_type_from_string, ) -from gvm.protocols.gmpv208.entities.feeds import ( - FeedType, - FeedsMixin, - get_feed_type_from_string, -) from gvm.protocols.gmpv208.entities.filter import ( FiltersMixin, FilterType, @@ -139,6 +134,11 @@ ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin +from gvm.protocols.gmpv208.system.feed import ( + FeedType, + FeedMixin, + get_feed_type_from_string, +) from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin from gvm.protocols.gmpv208.system.version import VersionMixin @@ -152,7 +152,7 @@ class Gmp( AuditsMixin, AuthenticationMixin, CredentialsMixin, - FeedsMixin, + FeedMixin, FiltersMixin, GroupsMixin, HostsMixin, diff --git a/gvm/protocols/gmpv208/entities/feeds.py b/gvm/protocols/gmpv208/system/feed.py similarity index 99% rename from gvm/protocols/gmpv208/entities/feeds.py rename to gvm/protocols/gmpv208/system/feed.py index 8b5756a44..a2732a068 100644 --- a/gvm/protocols/gmpv208/entities/feeds.py +++ b/gvm/protocols/gmpv208/system/feed.py @@ -48,7 +48,7 @@ def get_feed_type_from_string(feed_type: Optional[str]) -> Optional[FeedType]: ) from None -class FeedsMixin: +class FeedMixin: def get_feeds(self) -> Any: """Request the list of feeds diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index 26d305769..34d113646 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -61,11 +61,6 @@ EntityType, get_entity_type_from_string, ) -from gvm.protocols.gmpv208.entities.feeds import ( - FeedType, - FeedsMixin, - get_feed_type_from_string, -) from gvm.protocols.gmpv208.entities.filter import ( FiltersMixin, FilterType, @@ -126,6 +121,11 @@ ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin +from gvm.protocols.gmpv208.system.feed import ( + FeedType, + FeedMixin, + get_feed_type_from_string, +) from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin from gvm.protocols.gmpv208.gmpv208 import GmpV208Mixin @@ -157,7 +157,7 @@ class Gmp( AuditsMixin, AuthenticationMixin, CredentialsMixin, - FeedsMixin, + FeedMixin, FiltersMixin, GroupsMixin, HostsMixin, diff --git a/tests/protocols/gmpv208/entities/feeds/__init__.py b/tests/protocols/gmpv208/system/feed/__init__.py similarity index 100% rename from tests/protocols/gmpv208/entities/feeds/__init__.py rename to tests/protocols/gmpv208/system/feed/__init__.py diff --git a/tests/protocols/gmpv208/entities/feeds/test_get_feed.py b/tests/protocols/gmpv208/system/feed/test_get_feed.py similarity index 100% rename from tests/protocols/gmpv208/entities/feeds/test_get_feed.py rename to tests/protocols/gmpv208/system/feed/test_get_feed.py diff --git a/tests/protocols/gmpv208/entities/feeds/test_get_feeds.py b/tests/protocols/gmpv208/system/feed/test_get_feeds.py similarity index 100% rename from tests/protocols/gmpv208/entities/feeds/test_get_feeds.py rename to tests/protocols/gmpv208/system/feed/test_get_feeds.py diff --git a/tests/protocols/gmpv208/entities/feeds/test_sync_cert.py b/tests/protocols/gmpv208/system/feed/test_sync_cert.py similarity index 100% rename from tests/protocols/gmpv208/entities/feeds/test_sync_cert.py rename to tests/protocols/gmpv208/system/feed/test_sync_cert.py diff --git a/tests/protocols/gmpv208/entities/feeds/test_sync_feed.py b/tests/protocols/gmpv208/system/feed/test_sync_feed.py similarity index 100% rename from tests/protocols/gmpv208/entities/feeds/test_sync_feed.py rename to tests/protocols/gmpv208/system/feed/test_sync_feed.py diff --git a/tests/protocols/gmpv208/entities/feeds/test_sync_scap.py b/tests/protocols/gmpv208/system/feed/test_sync_scap.py similarity index 100% rename from tests/protocols/gmpv208/entities/feeds/test_sync_scap.py rename to tests/protocols/gmpv208/system/feed/test_sync_scap.py diff --git a/tests/protocols/gmpv208/entities/test_feeds.py b/tests/protocols/gmpv208/system/test_feed.py similarity index 98% rename from tests/protocols/gmpv208/entities/test_feeds.py rename to tests/protocols/gmpv208/system/test_feed.py index dcc8a96d7..5851e05f8 100644 --- a/tests/protocols/gmpv208/entities/test_feeds.py +++ b/tests/protocols/gmpv208/system/test_feed.py @@ -17,7 +17,7 @@ # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase -from .feeds import ( +from .feed import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, GmpSyncCertTestMixin, diff --git a/tests/protocols/gmpv214/entities/test_feeds.py b/tests/protocols/gmpv214/system/test_feed.py similarity index 97% rename from tests/protocols/gmpv214/entities/test_feeds.py rename to tests/protocols/gmpv214/system/test_feed.py index c56064f05..1657a1d81 100644 --- a/tests/protocols/gmpv214/entities/test_feeds.py +++ b/tests/protocols/gmpv214/system/test_feed.py @@ -17,7 +17,7 @@ # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase -from ...gmpv208.entities.feeds import ( +from ...gmpv208.system.feed import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, GmpSyncCertTestMixin, From 81b143d1f46d6ffd6b43089f7717773959cddfcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:39:35 +0200 Subject: [PATCH 11/15] Moved authentication: entities->system --- gvm/protocols/gmpv208/__init__.py | 2 +- gvm/protocols/gmpv208/{entities => system}/authentication.py | 0 gvm/protocols/gmpv214/__init__.py | 2 +- .../gmpv208/{entities => system}/authentication/__init__.py | 0 .../{entities => system}/authentication/test_authenticate.py | 0 .../{entities => system}/authentication/test_describe_auth.py | 0 .../{entities => system}/authentication/test_modify_auth.py | 0 .../gmpv208/{entities => system}/test_authentication.py | 0 .../gmpv214/{entities => system}/test_authentication.py | 2 +- 9 files changed, 3 insertions(+), 3 deletions(-) rename gvm/protocols/gmpv208/{entities => system}/authentication.py (100%) rename tests/protocols/gmpv208/{entities => system}/authentication/__init__.py (100%) rename tests/protocols/gmpv208/{entities => system}/authentication/test_authenticate.py (100%) rename tests/protocols/gmpv208/{entities => system}/authentication/test_describe_auth.py (100%) rename tests/protocols/gmpv208/{entities => system}/authentication/test_modify_auth.py (100%) rename tests/protocols/gmpv208/{entities => system}/test_authentication.py (100%) rename tests/protocols/gmpv214/{entities => system}/test_authentication.py (95%) diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index d0f488bc1..7991106d2 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -45,7 +45,6 @@ get_alert_method_from_string, ) from gvm.protocols.gmpv208.entities.audits import AuditsMixin -from gvm.protocols.gmpv208.entities.authentication import AuthenticationMixin from gvm.protocols.gmpv208.entities.credentials import ( CredentialFormat, CredentialsMixin, @@ -134,6 +133,7 @@ ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin +from gvm.protocols.gmpv208.system.authentication import AuthenticationMixin from gvm.protocols.gmpv208.system.feed import ( FeedType, FeedMixin, diff --git a/gvm/protocols/gmpv208/entities/authentication.py b/gvm/protocols/gmpv208/system/authentication.py similarity index 100% rename from gvm/protocols/gmpv208/entities/authentication.py rename to gvm/protocols/gmpv208/system/authentication.py diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index 34d113646..98a2e1599 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -45,7 +45,6 @@ get_alert_method_from_string, ) from gvm.protocols.gmpv208.entities.audits import AuditsMixin -from gvm.protocols.gmpv208.entities.authentication import AuthenticationMixin from gvm.protocols.gmpv208.entities.credentials import ( CredentialFormat, CredentialsMixin, @@ -121,6 +120,7 @@ ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin +from gvm.protocols.gmpv208.system.authentication import AuthenticationMixin from gvm.protocols.gmpv208.system.feed import ( FeedType, FeedMixin, diff --git a/tests/protocols/gmpv208/entities/authentication/__init__.py b/tests/protocols/gmpv208/system/authentication/__init__.py similarity index 100% rename from tests/protocols/gmpv208/entities/authentication/__init__.py rename to tests/protocols/gmpv208/system/authentication/__init__.py diff --git a/tests/protocols/gmpv208/entities/authentication/test_authenticate.py b/tests/protocols/gmpv208/system/authentication/test_authenticate.py similarity index 100% rename from tests/protocols/gmpv208/entities/authentication/test_authenticate.py rename to tests/protocols/gmpv208/system/authentication/test_authenticate.py diff --git a/tests/protocols/gmpv208/entities/authentication/test_describe_auth.py b/tests/protocols/gmpv208/system/authentication/test_describe_auth.py similarity index 100% rename from tests/protocols/gmpv208/entities/authentication/test_describe_auth.py rename to tests/protocols/gmpv208/system/authentication/test_describe_auth.py diff --git a/tests/protocols/gmpv208/entities/authentication/test_modify_auth.py b/tests/protocols/gmpv208/system/authentication/test_modify_auth.py similarity index 100% rename from tests/protocols/gmpv208/entities/authentication/test_modify_auth.py rename to tests/protocols/gmpv208/system/authentication/test_modify_auth.py diff --git a/tests/protocols/gmpv208/entities/test_authentication.py b/tests/protocols/gmpv208/system/test_authentication.py similarity index 100% rename from tests/protocols/gmpv208/entities/test_authentication.py rename to tests/protocols/gmpv208/system/test_authentication.py diff --git a/tests/protocols/gmpv214/entities/test_authentication.py b/tests/protocols/gmpv214/system/test_authentication.py similarity index 95% rename from tests/protocols/gmpv214/entities/test_authentication.py rename to tests/protocols/gmpv214/system/test_authentication.py index 26826eee3..f8dd0cb2c 100644 --- a/tests/protocols/gmpv214/entities/test_authentication.py +++ b/tests/protocols/gmpv214/system/test_authentication.py @@ -17,7 +17,7 @@ # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase -from ...gmpv208.entities.authentication import ( +from ...gmpv208.system.authentication import ( GmpAuthenticateTestMixin, GmpDescribeAuthTestMixin, GmpModifyAuthTestMixin, From e508e928416c41a1784ccad013b5ae3b76b8049c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:46:18 +0200 Subject: [PATCH 12/15] Moved settings: settings->user_settings | entities->system --- gvm/protocols/gmpv208/__init__.py | 2 +- .../{entities => system}/user_settings.py | 13 +++++----- gvm/protocols/gmpv214/__init__.py | 2 +- .../test_user_settings.py | 18 +++++++++----- .../user_settings/__init__.py | 6 ++--- .../user_settings/test_get_user_setting.py} | 8 +++---- .../user_settings/test_get_user_settings.py} | 6 ++--- .../test_modify_user_setting.py} | 24 +++++++++---------- .../test_user_settings.py | 20 ++++++++++------ 9 files changed, 56 insertions(+), 43 deletions(-) rename gvm/protocols/gmpv208/{entities => system}/user_settings.py (87%) rename tests/protocols/gmpv208/{entities => system}/test_user_settings.py (69%) rename tests/protocols/gmpv208/{entities => system}/user_settings/__init__.py (79%) rename tests/protocols/gmpv208/{entities/user_settings/test_get_setting.py => system/user_settings/test_get_user_setting.py} (86%) rename tests/protocols/gmpv208/{entities/user_settings/test_get_settings.py => system/user_settings/test_get_user_settings.py} (88%) rename tests/protocols/gmpv208/{entities/user_settings/test_modify_setting.py => system/user_settings/test_modify_user_setting.py} (71%) rename tests/protocols/gmpv214/{entities => system}/test_user_settings.py (66%) diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py index 7991106d2..23bbb1d0d 100644 --- a/gvm/protocols/gmpv208/__init__.py +++ b/gvm/protocols/gmpv208/__init__.py @@ -125,7 +125,6 @@ get_ticket_status_from_string, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin -from gvm.protocols.gmpv208.entities.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, UsersMixin, @@ -140,6 +139,7 @@ get_feed_type_from_string, ) from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin +from gvm.protocols.gmpv208.system.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.system.version import VersionMixin from gvm.connections import GvmConnection diff --git a/gvm/protocols/gmpv208/entities/user_settings.py b/gvm/protocols/gmpv208/system/user_settings.py similarity index 87% rename from gvm/protocols/gmpv208/entities/user_settings.py rename to gvm/protocols/gmpv208/system/user_settings.py index 53140e00f..4f09d8e79 100644 --- a/gvm/protocols/gmpv208/entities/user_settings.py +++ b/gvm/protocols/gmpv208/system/user_settings.py @@ -24,7 +24,7 @@ class UserSettingsMixin: - def get_settings(self, *, filter_string: Optional[str] = None) -> Any: + def get_user_settings(self, *, filter_string: Optional[str] = None) -> Any: """Request a list of user settings Arguments: @@ -40,7 +40,7 @@ def get_settings(self, *, filter_string: Optional[str] = None) -> Any: return self._send_xml_command(cmd) - def get_setting(self, setting_id: str) -> Any: + def get_user_setting(self, setting_id: str) -> Any: """Request a single user setting Arguments: @@ -53,13 +53,13 @@ def get_setting(self, setting_id: str) -> Any: if not setting_id: raise RequiredArgument( - function=self.get_setting.__name__, argument='setting_id' + function=self.get_user_setting.__name__, argument='setting_id' ) cmd.set_attribute("setting_id", setting_id) return self._send_xml_command(cmd) - def modify_setting( + def modify_user_setting( self, setting_id: Optional[str] = None, name: Optional[str] = None, @@ -78,13 +78,14 @@ def modify_setting( """ if not setting_id and not name: raise RequiredArgument( - function=self.modify_setting.__name__, + function=self.modify_user_setting.__name__, argument='setting_id or name argument', ) if value is None: raise RequiredArgument( - function=self.modify_setting.__name__, argument='value argument' + function=self.modify_user_setting.__name__, + argument='value argument', ) cmd = XmlCommand("modify_setting") diff --git a/gvm/protocols/gmpv214/__init__.py b/gvm/protocols/gmpv214/__init__.py index 98a2e1599..be79baaef 100644 --- a/gvm/protocols/gmpv214/__init__.py +++ b/gvm/protocols/gmpv214/__init__.py @@ -113,7 +113,6 @@ get_ticket_status_from_string, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin -from gvm.protocols.gmpv208.entities.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, get_user_auth_type_from_string, @@ -126,6 +125,7 @@ FeedMixin, get_feed_type_from_string, ) +from gvm.protocols.gmpv208.system.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin from gvm.protocols.gmpv208.gmpv208 import GmpV208Mixin diff --git a/tests/protocols/gmpv208/entities/test_user_settings.py b/tests/protocols/gmpv208/system/test_user_settings.py similarity index 69% rename from tests/protocols/gmpv208/entities/test_user_settings.py rename to tests/protocols/gmpv208/system/test_user_settings.py index b300beb51..c5dbc7c14 100644 --- a/tests/protocols/gmpv208/entities/test_user_settings.py +++ b/tests/protocols/gmpv208/system/test_user_settings.py @@ -18,19 +18,25 @@ from ...gmpv208 import Gmpv208TestCase from .user_settings import ( - GmpGetSettingTestMixin, - GmpGetSettingsTestMixin, - GmpModifySettingTestMixin, + GmpGetUserSettingTestMixin, + GmpGetUserSettingsTestMixin, + GmpModifyUserSettingTestMixin, ) -class Gmpv208GetSettingTestCase(GmpGetSettingTestMixin, Gmpv208TestCase): +class Gmpv208GetUserSettingTestCase( + GmpGetUserSettingTestMixin, Gmpv208TestCase +): pass -class Gmpv208GetSettingsTestCase(GmpGetSettingsTestMixin, Gmpv208TestCase): +class Gmpv208GetUserSettingsTestCase( + GmpGetUserSettingsTestMixin, Gmpv208TestCase +): pass -class Gmpv208ModifySettingTestCase(GmpModifySettingTestMixin, Gmpv208TestCase): +class Gmpv208ModifyUserSettingTestCase( + GmpModifyUserSettingTestMixin, Gmpv208TestCase +): pass diff --git a/tests/protocols/gmpv208/entities/user_settings/__init__.py b/tests/protocols/gmpv208/system/user_settings/__init__.py similarity index 79% rename from tests/protocols/gmpv208/entities/user_settings/__init__.py rename to tests/protocols/gmpv208/system/user_settings/__init__.py index 54c0357b5..847f8686e 100644 --- a/tests/protocols/gmpv208/entities/user_settings/__init__.py +++ b/tests/protocols/gmpv208/system/user_settings/__init__.py @@ -16,6 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from .test_get_setting import GmpGetSettingTestMixin -from .test_get_settings import GmpGetSettingsTestMixin -from .test_modify_setting import GmpModifySettingTestMixin +from .test_get_user_setting import GmpGetUserSettingTestMixin +from .test_get_user_settings import GmpGetUserSettingsTestMixin +from .test_modify_user_setting import GmpModifyUserSettingTestMixin diff --git a/tests/protocols/gmpv208/entities/user_settings/test_get_setting.py b/tests/protocols/gmpv208/system/user_settings/test_get_user_setting.py similarity index 86% rename from tests/protocols/gmpv208/entities/user_settings/test_get_setting.py rename to tests/protocols/gmpv208/system/user_settings/test_get_user_setting.py index f0361c0cd..e01f2e8c5 100644 --- a/tests/protocols/gmpv208/entities/user_settings/test_get_setting.py +++ b/tests/protocols/gmpv208/system/user_settings/test_get_user_setting.py @@ -19,9 +19,9 @@ from gvm.errors import RequiredArgument -class GmpGetSettingTestMixin: +class GmpGetUserSettingTestMixin: def test_get_setting_simple(self): - self.gmp.get_setting('id') + self.gmp.get_user_setting('id') self.connection.send.has_been_called_with( '' @@ -29,7 +29,7 @@ def test_get_setting_simple(self): def test_get_setting_missing_setting_id(self): with self.assertRaises(RequiredArgument): - self.gmp.get_setting(setting_id=None) + self.gmp.get_user_setting(setting_id=None) with self.assertRaises(RequiredArgument): - self.gmp.get_setting('') + self.gmp.get_user_setting('') diff --git a/tests/protocols/gmpv208/entities/user_settings/test_get_settings.py b/tests/protocols/gmpv208/system/user_settings/test_get_user_settings.py similarity index 88% rename from tests/protocols/gmpv208/entities/user_settings/test_get_settings.py rename to tests/protocols/gmpv208/system/user_settings/test_get_user_settings.py index 2a937a62e..c531ab1c8 100644 --- a/tests/protocols/gmpv208/entities/user_settings/test_get_settings.py +++ b/tests/protocols/gmpv208/system/user_settings/test_get_user_settings.py @@ -17,14 +17,14 @@ # along with this program. If not, see . -class GmpGetSettingsTestMixin: +class GmpGetUserSettingsTestMixin: def test_get_settings(self): - self.gmp.get_settings() + self.gmp.get_user_settings() self.connection.send.has_been_called_with('') def test_get_settings_with_filter_string(self): - self.gmp.get_settings(filter_string="foo=bar") + self.gmp.get_user_settings(filter_string="foo=bar") self.connection.send.has_been_called_with( '' diff --git a/tests/protocols/gmpv208/entities/user_settings/test_modify_setting.py b/tests/protocols/gmpv208/system/user_settings/test_modify_user_setting.py similarity index 71% rename from tests/protocols/gmpv208/entities/user_settings/test_modify_setting.py rename to tests/protocols/gmpv208/system/user_settings/test_modify_user_setting.py index 7751bdfbc..052f0a29d 100644 --- a/tests/protocols/gmpv208/entities/user_settings/test_modify_setting.py +++ b/tests/protocols/gmpv208/system/user_settings/test_modify_user_setting.py @@ -19,9 +19,9 @@ from gvm.errors import RequiredArgument -class GmpModifySettingTestMixin: - def test_modify_setting(self): - self.gmp.modify_setting(setting_id='s1', value='bar') +class GmpModifyUserSettingTestMixin: + def test_modify_user_setting(self): + self.gmp.modify_user_setting(setting_id='s1', value='bar') self.connection.send.has_been_called_with( '' @@ -29,7 +29,7 @@ def test_modify_setting(self): '' ) - self.gmp.modify_setting(name='s1', value='bar') + self.gmp.modify_user_setting(name='s1', value='bar') self.connection.send.has_been_called_with( '' @@ -38,7 +38,7 @@ def test_modify_setting(self): '' ) - self.gmp.modify_setting(setting_id='s1', value='') + self.gmp.modify_user_setting(setting_id='s1', value='') self.connection.send.has_been_called_with( '' @@ -46,20 +46,20 @@ def test_modify_setting(self): '' ) - def test_modify_setting_missing_setting_id(self): + def test_modify_user_setting_missing_setting_id(self): with self.assertRaises(RequiredArgument): - self.gmp.modify_setting(setting_id=None) + self.gmp.modify_user_setting(setting_id=None) with self.assertRaises(RequiredArgument): - self.gmp.modify_setting(setting_id='') + self.gmp.modify_user_setting(setting_id='') def test_modify_setting_missing_name(self): with self.assertRaises(RequiredArgument): - self.gmp.modify_setting(name=None) + self.gmp.modify_user_setting(name=None) with self.assertRaises(RequiredArgument): - self.gmp.modify_setting(name='') + self.gmp.modify_user_setting(name='') - def test_modify_setting_missing_value(self): + def test_modify_user_setting_missing_value(self): with self.assertRaises(RequiredArgument): - self.gmp.modify_setting(setting_id='s1', value=None) + self.gmp.modify_user_setting(setting_id='s1', value=None) diff --git a/tests/protocols/gmpv214/entities/test_user_settings.py b/tests/protocols/gmpv214/system/test_user_settings.py similarity index 66% rename from tests/protocols/gmpv214/entities/test_user_settings.py rename to tests/protocols/gmpv214/system/test_user_settings.py index 3140a64c7..b131cf9f8 100644 --- a/tests/protocols/gmpv214/entities/test_user_settings.py +++ b/tests/protocols/gmpv214/system/test_user_settings.py @@ -17,20 +17,26 @@ # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase -from ...gmpv208.entities.user_settings import ( - GmpGetSettingTestMixin, - GmpGetSettingsTestMixin, - GmpModifySettingTestMixin, +from ...gmpv208.system.user_settings import ( + GmpGetUserSettingTestMixin, + GmpGetUserSettingsTestMixin, + GmpModifyUserSettingTestMixin, ) -class Gmpv214GetSettingTestCase(GmpGetSettingTestMixin, Gmpv214TestCase): +class Gmpv214GetUserSettingTestCase( + GmpGetUserSettingTestMixin, Gmpv214TestCase +): pass -class Gmpv214GetSettingsTestCase(GmpGetSettingsTestMixin, Gmpv214TestCase): +class Gmpv214GetUserSettingsTestCase( + GmpGetUserSettingsTestMixin, Gmpv214TestCase +): pass -class Gmpv214ModifySettingTestCase(GmpModifySettingTestMixin, Gmpv214TestCase): +class Gmpv214ModifyUserSettingTestCase( + GmpModifyUserSettingTestMixin, Gmpv214TestCase +): pass From ef974675214bd443eb52425e8bbbdad1f152914e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Thu, 20 May 2021 22:47:33 +0200 Subject: [PATCH 13/15] Added Changelog entries --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b40a80e17..28eecb16d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Calendar Versioning](https://calver.org)html). * Introduced new explicit API calls for SecInfo: `get_nvt()`, `get_nvt_list()`, `get_cpe()`, `get_cpe_list()`, `get_cve()`, `get_cve_list()`, `get_cert_bund_advisory()`, `get_cert_bund_advisory_list()`, `get_dnf_cert_advisory()`, `get_dnf_cert_advisory_list()`, `get_oval_definition()`, `get_oval_definition_list()`. [#456](https://github.com/greenbone/python-gvm/pull/456) ### Changed +* API changes: `get_setting(s)` -> `get_user_setting(s)`, `modify_setting` -> `modify_user_setting`. [#472](https://github.com/greenbone/python-gvm/pull/472) +* Detached the Trashcan API calls from the GMP class into a new `TrashcanMixin`. [#472](https://github.com/greenbone/python-gvm/pull/472) +* Detached the Authentication API calls from the GMP class into a new `AuthenticationMixin`. [#472](https://github.com/greenbone/python-gvm/pull/472) +* Detached the Version API calls from the GMP class into a new `VersionMixin`. [#472](https://github.com/greenbone/python-gvm/pull/472) * Changed `filter` to `filter_string` in getter functions. [#470](https://github.com/greenbone/python-gvm/pull/470) [#471](https://github.com/greenbone/python-gvm/pull/471) * Detached the Preferences API calls from the GMP class into a new `PreferencesMixin`. [#471](https://github.com/greenbone/python-gvm/pull/471) * Detached the Settings API calls from the GMP class into a new `UserSettingsMixin`. [#471](https://github.com/greenbone/python-gvm/pull/471) @@ -26,7 +30,7 @@ and this project adheres to [Calendar Versioning](https://calver.org)html). * Detached the Schedules API calls from the GMP class into a new `SchedulesMixin`. [#469](https://github.com/greenbone/python-gvm/pull/469) * Detached the Filters API calls from the GMP class into a new `FiltersMixin`. [#469](https://github.com/greenbone/python-gvm/pull/469) * Detached the Tags API calls from the GMP class into a new `TagsMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) -* Detached the Feeds API calls from the GMP class into a new `FeedsMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) +* Detached the Feeds API calls from the GMP class into a new `FeedMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) [#472](https://github.com/greenbone/python-gvm/pull/472) * Detached the Aggregates API calls from the GMP class into a new `AggregatesMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) * Detached the EntityType from the GMP types class into a new `entites` file. [#467](https://github.com/greenbone/python-gvm/pull/467) * Detached the Users API calls from the GMP class into a new `UsersMixin`. [#467](https://github.com/greenbone/python-gvm/pull/467) From 1602aa76d1ee65fbc58dd494c4b5a186afc30023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Fri, 21 May 2021 09:49:34 +0200 Subject: [PATCH 14/15] Drop the sync feed functions --- gvm/protocols/gmpv208/system/feed.py | 24 ------------------- .../protocols/gmpv208/system/feed/__init__.py | 3 --- .../gmpv208/system/feed/test_sync_cert.py | 24 ------------------- .../gmpv208/system/feed/test_sync_feed.py | 24 ------------------- .../gmpv208/system/feed/test_sync_scap.py | 24 ------------------- tests/protocols/gmpv208/system/test_feed.py | 15 ------------ tests/protocols/gmpv214/system/test_feed.py | 15 ------------ 7 files changed, 129 deletions(-) delete mode 100644 tests/protocols/gmpv208/system/feed/test_sync_cert.py delete mode 100644 tests/protocols/gmpv208/system/feed/test_sync_feed.py delete mode 100644 tests/protocols/gmpv208/system/feed/test_sync_scap.py diff --git a/gvm/protocols/gmpv208/system/feed.py b/gvm/protocols/gmpv208/system/feed.py index a2732a068..b921f9b08 100644 --- a/gvm/protocols/gmpv208/system/feed.py +++ b/gvm/protocols/gmpv208/system/feed.py @@ -82,27 +82,3 @@ def get_feed(self, feed_type: Optional[FeedType]) -> Any: cmd.set_attribute("type", feed_type.value) return self._send_xml_command(cmd) - - def sync_feed(self) -> Any: - """Request a synchronization with the NVT feed service - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("sync_feed")) - - def sync_cert(self) -> Any: - """Request a synchronization with the CERT feed service - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("sync_cert")) - - def sync_scap(self) -> Any: - """Request a synchronization with the SCAP feed service - - Returns: - The response. See :py:meth:`send_command` for details. - """ - return self._send_xml_command(XmlCommand("sync_scap")) diff --git a/tests/protocols/gmpv208/system/feed/__init__.py b/tests/protocols/gmpv208/system/feed/__init__.py index 30640d44b..93a2f4412 100644 --- a/tests/protocols/gmpv208/system/feed/__init__.py +++ b/tests/protocols/gmpv208/system/feed/__init__.py @@ -18,6 +18,3 @@ from .test_get_feed import GmpGetFeedTestMixin from .test_get_feeds import GmpGetFeedsTestMixin -from .test_sync_feed import GmpSyncFeedTestMixin -from .test_sync_cert import GmpSyncCertTestMixin -from .test_sync_scap import GmpSyncScapTestMixin diff --git a/tests/protocols/gmpv208/system/feed/test_sync_cert.py b/tests/protocols/gmpv208/system/feed/test_sync_cert.py deleted file mode 100644 index 2e1e388d7..000000000 --- a/tests/protocols/gmpv208/system/feed/test_sync_cert.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2018-2021 Greenbone Networks GmbH -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -class GmpSyncCertTestMixin: - def test_sync_cert(self): - self.gmp.sync_cert() - - self.connection.send.has_been_called_with('') diff --git a/tests/protocols/gmpv208/system/feed/test_sync_feed.py b/tests/protocols/gmpv208/system/feed/test_sync_feed.py deleted file mode 100644 index f002fe71c..000000000 --- a/tests/protocols/gmpv208/system/feed/test_sync_feed.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2018-2021 Greenbone Networks GmbH -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -class GmpSyncFeedTestMixin: - def test_sync_feed(self): - self.gmp.sync_feed() - - self.connection.send.has_been_called_with('') diff --git a/tests/protocols/gmpv208/system/feed/test_sync_scap.py b/tests/protocols/gmpv208/system/feed/test_sync_scap.py deleted file mode 100644 index 639575e2a..000000000 --- a/tests/protocols/gmpv208/system/feed/test_sync_scap.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2018-2021 Greenbone Networks GmbH -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -class GmpSyncScapTestMixin: - def test_sync_scap(self): - self.gmp.sync_scap() - - self.connection.send.has_been_called_with('') diff --git a/tests/protocols/gmpv208/system/test_feed.py b/tests/protocols/gmpv208/system/test_feed.py index 5851e05f8..750206029 100644 --- a/tests/protocols/gmpv208/system/test_feed.py +++ b/tests/protocols/gmpv208/system/test_feed.py @@ -20,9 +20,6 @@ from .feed import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, - GmpSyncCertTestMixin, - GmpSyncFeedTestMixin, - GmpSyncScapTestMixin, ) @@ -32,15 +29,3 @@ class Gmpv208GetFeedTestCase(GmpGetFeedTestMixin, Gmpv208TestCase): class Gmpv208GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv208TestCase): pass - - -class Gmpv208SyncCertTestMixin(GmpSyncCertTestMixin, Gmpv208TestCase): - pass - - -class Gmpv208SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv208TestCase): - pass - - -class Gmpv208SyncScapTestMixin(GmpSyncScapTestMixin, Gmpv208TestCase): - pass diff --git a/tests/protocols/gmpv214/system/test_feed.py b/tests/protocols/gmpv214/system/test_feed.py index 1657a1d81..5ebbe2fbe 100644 --- a/tests/protocols/gmpv214/system/test_feed.py +++ b/tests/protocols/gmpv214/system/test_feed.py @@ -20,9 +20,6 @@ from ...gmpv208.system.feed import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, - GmpSyncCertTestMixin, - GmpSyncFeedTestMixin, - GmpSyncScapTestMixin, ) @@ -32,15 +29,3 @@ class Gmpv214GetFeedTestCase(GmpGetFeedTestMixin, Gmpv214TestCase): class Gmpv214GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv214TestCase): pass - - -class Gmpv214SyncCertTestMixin(GmpSyncCertTestMixin, Gmpv214TestCase): - pass - - -class Gmpv214SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv214TestCase): - pass - - -class Gmpv214SyncScapTestMixin(GmpSyncScapTestMixin, Gmpv214TestCase): - pass From 9332cb21aa7b37bfc9585d8f8699b44efe9bfdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaspar=20L=C3=B6chte?= Date: Fri, 21 May 2021 09:50:30 +0200 Subject: [PATCH 15/15] Added CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28eecb16d..58636818a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ and this project adheres to [Calendar Versioning](https://calver.org)html). ### Deprecated ### Removed +* Removed `sync_feed`, `sync_scap`, and `sync_cert` calls. [#472](https://github.com/greenbone/python-gvm/pull/472) * Removed `TimeUnit`. It was used for schedules before iCal and is not required anymore. [#469](https://github.com/greenbone/python-gvm/pull/469) * Removed `Gmpv214Mixin`. [#467](https://github.com/greenbone/python-gvm/pull/467) * Remove support of delete host/operating system by a report . [#459](https://github.com/greenbone/python-gvm/pull/459)