Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gvm/protocols/gmp/_gmpnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,3 +1844,21 @@ def get_report_export(
report_export_id=report_export_id,
)
)

def download_report_export(
self,
report_export_id: EntityID,
) -> T:
"""Request a download report export.

Args:
report_export_id: UUID of the report export.

Returns:
A request for the download_report_export GMP command.
"""
return self._send_request_and_transform_response(
ReportExports.download_report_export(
report_export_id=report_export_id,
)
)
30 changes: 30 additions & 0 deletions gvm/protocols/gmp/requests/next/_report_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,33 @@ def get_report_export(
)

return cmd

@classmethod
def download_report_export(
cls,
report_export_id: EntityID,
) -> Request:
"""Request a download report export.

Args:
report_export_id: UUID of the report export.

Returns:
A request for the download_report_export GMP command.

Raises:
RequiredArgument: If report_export_id is not provided.
"""
if not report_export_id:
raise RequiredArgument(
function=cls.get_report_export.__name__,
argument="report_export_id",
)

cmd = XmlCommand("download_report_export")
cmd.set_attribute(
"report_export_id",
str(report_export_id),
)

return cmd
2 changes: 2 additions & 0 deletions tests/protocols/gmpnext/entities/report_exports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

from .test_download_report_export import GmpDownloadReportExportTestMixin
from .test_get_report_export import GmpGetReportExportTestMixin
from .test_get_report_exports import GmpGetReportExportsTestMixin

__all__ = [
"GmpDownloadReportExportTestMixin",
"GmpGetReportExportTestMixin",
"GmpGetReportExportsTestMixin",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2026 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
from gvm.errors import RequiredArgument


class GmpDownloadReportExportTestMixin:
def test_download_report_export_without_id(self):
with self.assertRaises(RequiredArgument):
self.gmp.download_report_export(None)

with self.assertRaises(RequiredArgument):
self.gmp.download_report_export("")

def test_download_report_export_with_id(self):
self.gmp.download_report_export(report_export_id="e1")

self.connection.send.has_been_called_with(
b'<download_report_export report_export_id="e1"/>'
)
7 changes: 7 additions & 0 deletions tests/protocols/gmpnext/entities/test_report_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from ...gmpnext import GMPTestCase
from .report_exports import (
GmpDownloadReportExportTestMixin,
GmpGetReportExportsTestMixin,
GmpGetReportExportTestMixin,
)
Expand All @@ -16,3 +17,9 @@ class GmpGmpGetReportExportsTestCase(GmpGetReportExportsTestMixin, GMPTestCase):

class GmpGmpGetReportExportTestCase(GmpGetReportExportTestMixin, GMPTestCase):
pass


class GmpGmpDownloadReportExportTestCase(
GmpDownloadReportExportTestMixin, GMPTestCase
):
pass