diff --git a/CHANGELOG.md b/CHANGELOG.md
index b40a80e17..58636818a 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)
@@ -57,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)
diff --git a/gvm/protocols/gmpv208/__init__.py b/gvm/protocols/gmpv208/__init__.py
index 534beb859..23bbb1d0d 100644
--- a/gvm/protocols/gmpv208/__init__.py
+++ b/gvm/protocols/gmpv208/__init__.py
@@ -60,11 +60,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,
@@ -130,16 +125,24 @@
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,
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.authentication import AuthenticationMixin
+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.user_settings import UserSettingsMixin
+from gvm.protocols.gmpv208.system.version import VersionMixin
+
+from gvm.connections import GvmConnection
class Gmp(
@@ -147,8 +150,9 @@ class Gmp(
AggregatesMixin,
AlertsMixin,
AuditsMixin,
+ AuthenticationMixin,
CredentialsMixin,
- FeedsMixin,
+ FeedMixin,
FiltersMixin,
GroupsMixin,
HostsMixin,
@@ -168,14 +172,36 @@ class Gmp(
TasksMixin,
TicketsMixin,
TLSCertificateMixin,
+ TrashcanMixin,
ScanConfigsMixin,
ScannersMixin,
SchedulesMixin,
SecInfoMixin,
UserSettingsMixin,
UsersMixin,
+ VersionMixin,
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,
@@ -186,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 e8f74b92c..ac898c453 100644
--- a/gvm/protocols/gmpv208/gmpv208.py
+++ b/gvm/protocols/gmpv208/gmpv208.py
@@ -30,114 +30,20 @@
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
-PROTOCOL_VERSION = (20, 8)
-
logger = logging.getLogger(__name__)
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 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,
*,
@@ -189,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:
@@ -230,67 +129,3 @@ def help(
cmd.set_attribute("format", format)
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 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
-
- 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/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/authentication.py b/gvm/protocols/gmpv208/system/authentication.py
new file mode 100644
index 000000000..54d66d9d7
--- /dev/null
+++ b/gvm/protocols/gmpv208/system/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/entities/feeds.py b/gvm/protocols/gmpv208/system/feed.py
similarity index 90%
rename from gvm/protocols/gmpv208/entities/feeds.py
rename to gvm/protocols/gmpv208/system/feed.py
index 390afdc07..b921f9b08 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
@@ -82,11 +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"))
diff --git a/gvm/protocols/gmpv208/system/trashcan.py b/gvm/protocols/gmpv208/system/trashcan.py
new file mode 100644
index 000000000..0d2d43c0f
--- /dev/null
+++ b/gvm/protocols/gmpv208/system/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/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/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 ae646d1ee..be79baaef 100644
--- a/gvm/protocols/gmpv214/__init__.py
+++ b/gvm/protocols/gmpv214/__init__.py
@@ -60,11 +60,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,
@@ -118,13 +113,20 @@
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,
)
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,
+ 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
@@ -143,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(
@@ -153,8 +155,9 @@ class Gmp(
AggregatesMixin,
AlertsMixin,
AuditsMixin,
+ AuthenticationMixin,
CredentialsMixin,
- FeedsMixin,
+ FeedMixin,
FiltersMixin,
GroupsMixin,
HostsMixin,
@@ -174,12 +177,14 @@ class Gmp(
TasksMixin,
TicketsMixin,
TLSCertificateMixin,
+ TrashcanMixin,
ScanConfigsMixin,
ScannersMixin,
SchedulesMixin,
SecInfoMixin,
UserSettingsMixin,
UsersMixin,
+ VersionMixin,
VulnerabilitiesMixin,
):
def __init__(
@@ -192,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
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/entities/user_settings/__init__.py b/tests/protocols/gmpv208/system/authentication/__init__.py
similarity index 81%
rename from tests/protocols/gmpv208/entities/user_settings/__init__.py
rename to tests/protocols/gmpv208/system/authentication/__init__.py
index 54c0357b5..b95b49d89 100644
--- a/tests/protocols/gmpv208/entities/user_settings/__init__.py
+++ b/tests/protocols/gmpv208/system/authentication/__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_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/system/authentication/test_authenticate.py
similarity index 98%
rename from tests/protocols/gmpv208/testcmds/test_authenticate.py
rename to tests/protocols/gmpv208/system/authentication/test_authenticate.py
index 304068d1f..d446789d7 100644
--- a/tests/protocols/gmpv208/testcmds/test_authenticate.py
+++ b/tests/protocols/gmpv208/system/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/system/authentication/test_describe_auth.py
similarity index 95%
rename from tests/protocols/gmpv208/testcmds/test_describe_auth.py
rename to tests/protocols/gmpv208/system/authentication/test_describe_auth.py
index 8d47679a9..7a3099f7f 100644
--- a/tests/protocols/gmpv208/testcmds/test_describe_auth.py
+++ b/tests/protocols/gmpv208/system/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/system/authentication/test_modify_auth.py
similarity index 98%
rename from tests/protocols/gmpv208/testcmds/test_modify_auth.py
rename to tests/protocols/gmpv208/system/authentication/test_modify_auth.py
index e1c4a15d2..2e163dc61 100644
--- a/tests/protocols/gmpv208/testcmds/test_modify_auth.py
+++ b/tests/protocols/gmpv208/system/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/feeds/__init__.py b/tests/protocols/gmpv208/system/feed/__init__.py
similarity index 94%
rename from tests/protocols/gmpv208/entities/feeds/__init__.py
rename to tests/protocols/gmpv208/system/feed/__init__.py
index 4f27dca09..93a2f4412 100644
--- a/tests/protocols/gmpv208/entities/feeds/__init__.py
+++ b/tests/protocols/gmpv208/system/feed/__init__.py
@@ -18,4 +18,3 @@
from .test_get_feed import GmpGetFeedTestMixin
from .test_get_feeds import GmpGetFeedsTestMixin
-from .test_sync_feed import GmpSyncFeedTestMixin
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/system/test_authentication.py b/tests/protocols/gmpv208/system/test_authentication.py
new file mode 100644
index 000000000..f29c62494
--- /dev/null
+++ b/tests/protocols/gmpv208/system/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/entities/test_feeds.py b/tests/protocols/gmpv208/system/test_feed.py
similarity index 88%
rename from tests/protocols/gmpv208/entities/test_feeds.py
rename to tests/protocols/gmpv208/system/test_feed.py
index 4a10a4576..750206029 100644
--- a/tests/protocols/gmpv208/entities/test_feeds.py
+++ b/tests/protocols/gmpv208/system/test_feed.py
@@ -17,10 +17,9 @@
# along with this program. If not, see .
from ...gmpv208 import Gmpv208TestCase
-from .feeds import (
+from .feed import (
GmpGetFeedsTestMixin,
GmpGetFeedTestMixin,
- GmpSyncFeedTestMixin,
)
@@ -30,7 +29,3 @@ class Gmpv208GetFeedTestCase(GmpGetFeedTestMixin, Gmpv208TestCase):
class Gmpv208GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv208TestCase):
pass
-
-
-class Gmpv208SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv208TestCase):
- pass
diff --git a/tests/protocols/gmpv208/entities/test_user_settings.py b/tests/protocols/gmpv208/system/test_trashcan.py
similarity index 70%
rename from tests/protocols/gmpv208/entities/test_user_settings.py
rename to tests/protocols/gmpv208/system/test_trashcan.py
index b300beb51..4b2e89c57 100644
--- a/tests/protocols/gmpv208/entities/test_user_settings.py
+++ b/tests/protocols/gmpv208/system/test_trashcan.py
@@ -17,20 +17,17 @@
# along with this program. If not, see .
from ...gmpv208 import Gmpv208TestCase
-from .user_settings import (
- GmpGetSettingTestMixin,
- GmpGetSettingsTestMixin,
- GmpModifySettingTestMixin,
+from .trashcan import (
+ GmpEmptyTrashcanTestMixin,
+ GmpRestoreFromTrashcanTestMixin,
)
-class Gmpv208GetSettingTestCase(GmpGetSettingTestMixin, Gmpv208TestCase):
+class Gmpv208EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv208TestCase):
pass
-class Gmpv208GetSettingsTestCase(GmpGetSettingsTestMixin, Gmpv208TestCase):
- pass
-
-
-class Gmpv208ModifySettingTestCase(GmpModifySettingTestMixin, Gmpv208TestCase):
+class Gmpv208RestoreFromTrashcanTestCase(
+ GmpRestoreFromTrashcanTestMixin, Gmpv208TestCase
+):
pass
diff --git a/tests/protocols/gmpv208/system/test_user_settings.py b/tests/protocols/gmpv208/system/test_user_settings.py
new file mode 100644
index 000000000..c5dbc7c14
--- /dev/null
+++ b/tests/protocols/gmpv208/system/test_user_settings.py
@@ -0,0 +1,42 @@
+# -*- 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 .user_settings import (
+ GmpGetUserSettingTestMixin,
+ GmpGetUserSettingsTestMixin,
+ GmpModifyUserSettingTestMixin,
+)
+
+
+class Gmpv208GetUserSettingTestCase(
+ GmpGetUserSettingTestMixin, Gmpv208TestCase
+):
+ pass
+
+
+class Gmpv208GetUserSettingsTestCase(
+ GmpGetUserSettingsTestMixin, Gmpv208TestCase
+):
+ pass
+
+
+class Gmpv208ModifyUserSettingTestCase(
+ GmpModifyUserSettingTestMixin, Gmpv208TestCase
+):
+ pass
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/trashcan/__init__.py b/tests/protocols/gmpv208/system/trashcan/__init__.py
new file mode 100644
index 000000000..c174afe91
--- /dev/null
+++ b/tests/protocols/gmpv208/system/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/system/trashcan/test_empty_trashcan.py
similarity index 95%
rename from tests/protocols/gmpv208/testcmds/test_empty_trashcan.py
rename to tests/protocols/gmpv208/system/trashcan/test_empty_trashcan.py
index 7b8280c93..0d583c98d 100644
--- a/tests/protocols/gmpv208/testcmds/test_empty_trashcan.py
+++ b/tests/protocols/gmpv208/system/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.py b/tests/protocols/gmpv208/system/trashcan/test_restore_from_trashcan.py
similarity index 77%
rename from tests/protocols/gmpv208/testcmds/test_restore.py
rename to tests/protocols/gmpv208/system/trashcan/test_restore_from_trashcan.py
index fd8cddc25..fea1c9f24 100644
--- a/tests/protocols/gmpv208/testcmds/test_restore.py
+++ b/tests/protocols/gmpv208/system/trashcan/test_restore_from_trashcan.py
@@ -19,15 +19,15 @@
from gvm.errors import GvmError
-class GmpRestoreTestCase:
- def test_restore(self):
- self.gmp.restore('a1')
+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(None)
+ self.gmp.restore_from_trashcan(None)
with self.assertRaises(GvmError):
- self.gmp.restore('')
+ self.gmp.restore_from_trashcan('')
diff --git a/tests/protocols/gmpv208/system/user_settings/__init__.py b/tests/protocols/gmpv208/system/user_settings/__init__.py
new file mode 100644
index 000000000..847f8686e
--- /dev/null
+++ b/tests/protocols/gmpv208/system/user_settings/__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_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/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 f5fbce557..1e5cd51f2 100644
--- a/tests/protocols/gmpv208/test_new_gmpv208.py
+++ b/tests/protocols/gmpv208/test_new_gmpv208.py
@@ -20,57 +20,15 @@
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
-):
- pass
-
-
class Gmpv208GetSystemReportsTestCase(
GmpGetSystemReportsTestCase, Gmpv208TestCase
):
pass
-class Gmpv208GetVersionCommandTestCase(
- GmpGetVersionCommandTestCase, Gmpv208TestCase
-):
- pass
-
-
-class Gmpv208ModifyAuthTestCase(GmpModifyAuthTestCase, Gmpv208TestCase):
- pass
-
-
-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 db9c9fd17..618438dca 100644
--- a/tests/protocols/gmpv208/testcmds/__init__.py
+++ b/tests/protocols/gmpv208/testcmds/__init__.py
@@ -18,15 +18,6 @@
# 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 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_sync_cert.py b/tests/protocols/gmpv208/testcmds/test_sync_cert.py
deleted file mode 100644
index 0844c61d1..000000000
--- a/tests/protocols/gmpv208/testcmds/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 GmpSyncCertCommandTestCase:
- def test_sync_cert(self):
- self.gmp.sync_cert()
-
- self.connection.send.has_been_called_with('')
diff --git a/tests/protocols/gmpv208/testcmds/test_sync_scap.py b/tests/protocols/gmpv208/testcmds/test_sync_scap.py
deleted file mode 100644
index 7e0c8a9c1..000000000
--- a/tests/protocols/gmpv208/testcmds/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 GmpSyncScapCommandTestCase:
- def test_sync_scap(self):
- self.gmp.sync_scap()
-
- self.connection.send.has_been_called_with('')
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_authentication.py b/tests/protocols/gmpv214/system/test_authentication.py
new file mode 100644
index 000000000..f8dd0cb2c
--- /dev/null
+++ b/tests/protocols/gmpv214/system/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.system.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/entities/test_feeds.py b/tests/protocols/gmpv214/system/test_feed.py
similarity index 87%
rename from tests/protocols/gmpv214/entities/test_feeds.py
rename to tests/protocols/gmpv214/system/test_feed.py
index f3967a407..5ebbe2fbe 100644
--- a/tests/protocols/gmpv214/entities/test_feeds.py
+++ b/tests/protocols/gmpv214/system/test_feed.py
@@ -17,10 +17,9 @@
# along with this program. If not, see .
from ...gmpv214 import Gmpv214TestCase
-from ...gmpv208.entities.feeds import (
+from ...gmpv208.system.feed import (
GmpGetFeedsTestMixin,
GmpGetFeedTestMixin,
- GmpSyncFeedTestMixin,
)
@@ -30,7 +29,3 @@ class Gmpv214GetFeedTestCase(GmpGetFeedTestMixin, Gmpv214TestCase):
class Gmpv214GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv214TestCase):
pass
-
-
-class Gmpv214SyncFeedTestMixin(GmpSyncFeedTestMixin, Gmpv214TestCase):
- pass
diff --git a/tests/protocols/gmpv214/entities/test_user_settings.py b/tests/protocols/gmpv214/system/test_trashcan.py
similarity index 69%
rename from tests/protocols/gmpv214/entities/test_user_settings.py
rename to tests/protocols/gmpv214/system/test_trashcan.py
index 3140a64c7..0c7fbae45 100644
--- a/tests/protocols/gmpv214/entities/test_user_settings.py
+++ b/tests/protocols/gmpv214/system/test_trashcan.py
@@ -17,20 +17,17 @@
# along with this program. If not, see .
from ...gmpv214 import Gmpv214TestCase
-from ...gmpv208.entities.user_settings import (
- GmpGetSettingTestMixin,
- GmpGetSettingsTestMixin,
- GmpModifySettingTestMixin,
+from ...gmpv208.system.trashcan import (
+ GmpEmptyTrashcanTestMixin,
+ GmpRestoreFromTrashcanTestMixin,
)
-class Gmpv214GetSettingTestCase(GmpGetSettingTestMixin, Gmpv214TestCase):
+class Gmpv214EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv214TestCase):
pass
-class Gmpv214GetSettingsTestCase(GmpGetSettingsTestMixin, Gmpv214TestCase):
- pass
-
-
-class Gmpv214ModifySettingTestCase(GmpModifySettingTestMixin, Gmpv214TestCase):
+class Gmpv214RestoreFromTrashcanTestCase(
+ GmpRestoreFromTrashcanTestMixin, Gmpv214TestCase
+):
pass
diff --git a/tests/protocols/gmpv214/system/test_user_settings.py b/tests/protocols/gmpv214/system/test_user_settings.py
new file mode 100644
index 000000000..b131cf9f8
--- /dev/null
+++ b/tests/protocols/gmpv214/system/test_user_settings.py
@@ -0,0 +1,42 @@
+# -*- 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.user_settings import (
+ GmpGetUserSettingTestMixin,
+ GmpGetUserSettingsTestMixin,
+ GmpModifyUserSettingTestMixin,
+)
+
+
+class Gmpv214GetUserSettingTestCase(
+ GmpGetUserSettingTestMixin, Gmpv214TestCase
+):
+ pass
+
+
+class Gmpv214GetUserSettingsTestCase(
+ GmpGetUserSettingsTestMixin, Gmpv214TestCase
+):
+ pass
+
+
+class Gmpv214ModifyUserSettingTestCase(
+ GmpModifyUserSettingTestMixin, Gmpv214TestCase
+):
+ pass
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/gmpv208/entities/feeds/test_sync_feed.py b/tests/protocols/gmpv214/system/versions/test_get_protocol_version.py
similarity index 77%
rename from tests/protocols/gmpv208/entities/feeds/test_sync_feed.py
rename to tests/protocols/gmpv214/system/versions/test_get_protocol_version.py
index f002fe71c..1a2617ae9 100644
--- a/tests/protocols/gmpv208/entities/feeds/test_sync_feed.py
+++ b/tests/protocols/gmpv214/system/versions/test_get_protocol_version.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2018-2021 Greenbone Networks GmbH
+# Copyright (C) 2019-2021 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
@@ -17,8 +17,6 @@
# 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('')
+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 0edae8910..20cffad1c 100644
--- a/tests/protocols/gmpv214/test_v208_from_gmpv214.py
+++ b/tests/protocols/gmpv214/test_v208_from_gmpv214.py
@@ -20,57 +20,15 @@
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
-):
- pass
-
-
class Gmpv214GetSystemReportsTestCase(
GmpGetSystemReportsTestCase, Gmpv214TestCase
):
pass
-class Gmpv214GetVersionCommandTestCase(
- GmpGetVersionCommandTestCase, Gmpv214TestCase
-):
- pass
-
-
-class Gmpv214ModifyAuthTestCase(GmpModifyAuthTestCase, Gmpv214TestCase):
- pass
-
-
-class Gmpv214RestoreTestCase(GmpRestoreTestCase, Gmpv214TestCase):
- pass
-
-
-class Gmpv214SyncCertCommandTestCase(
- GmpSyncCertCommandTestCase, Gmpv214TestCase
-):
- pass
-
-
-class Gmpv214SyncScapCommandTestCase(
- GmpSyncScapCommandTestCase, Gmpv214TestCase
-):
- pass
-
-
class Gmpv214v7WithStatementTestCase(GmpWithStatementTestCase, Gmpv214TestCase):
pass