Skip to content

Commit fa824d3

Browse files
committed
change: split report export list and single retrieval
1 parent 5af78b2 commit fa824d3

6 files changed

Lines changed: 57 additions & 18 deletions

File tree

‎gvm/protocols/gmp/_gmpnext.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,22 +1812,32 @@ def export_scan_report(
18121812

18131813
def get_report_exports(
18141814
self,
1815-
*,
1816-
report_export_id: EntityID | None = None,
18171815
) -> T:
18181816
"""Request report exports.
18191817
1820-
If report_export_id is provided, only the matching report export is
1821-
requested. Otherwise, the command requests a list of report exports.
1818+
The command requests a list of report exports.
1819+
1820+
Returns:
1821+
A request for the get_report_exports GMP command.
1822+
"""
1823+
return self._send_request_and_transform_response(
1824+
ReportExports.get_report_exports()
1825+
)
1826+
1827+
def get_report_export(
1828+
self,
1829+
report_export_id: EntityID | None = None,
1830+
) -> T:
1831+
"""Request a single report export.
18221832
18231833
Args:
1824-
report_export_id: UUID of an optional report export.
1834+
report_export_id: UUID of the report export.
18251835
18261836
Returns:
18271837
A request for the get_report_exports GMP command.
18281838
"""
18291839
return self._send_request_and_transform_response(
1830-
ReportExports.get_report_exports(
1840+
ReportExports.get_report_export(
18311841
report_export_id=report_export_id,
18321842
)
18331843
)

‎gvm/protocols/gmp/requests/next/_report_exports.py‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,27 @@ class ReportExports:
77
@classmethod
88
def get_report_exports(
99
cls,
10-
*,
11-
report_export_id: EntityID | None = None,
1210
) -> Request:
1311
"""Request report exports.
1412
15-
If report_export_id is provided, only the matching report export is
16-
requested. Otherwise, the command requests a list of report exports.
13+
The command requests a list of report exports.
14+
15+
Returns:
16+
A request for the get_report_exports GMP command.
17+
"""
18+
cmd = XmlCommand("get_report_exports")
19+
20+
return cmd
21+
22+
@classmethod
23+
def get_report_export(
24+
cls,
25+
report_export_id: EntityID | None = None,
26+
) -> Request:
27+
"""Request a single report export.
1728
1829
Args:
19-
report_export_id: UUID of an optional report export.
30+
report_export_id: UUID of the report export.
2031
2132
Returns:
2233
A request for the get_report_exports GMP command.

‎tests/protocols/gmpnext/entities/report_exports/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
#
33
# SPDX-License-Identifier: GPL-3.0-or-later
44

5+
from .test_get_report_export import GmpGetReportExportTestMixin
56
from .test_get_report_exports import GmpGetReportExportsTestMixin
67

78
__all__ = [
9+
"GmpGetReportExportTestMixin",
810
"GmpGetReportExportsTestMixin",
911
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-FileCopyrightText: 2026 Greenbone AG
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
#
5+
6+
7+
class GmpGetReportExportTestMixin:
8+
def test_get_report_export_without_id(self):
9+
self.gmp.get_report_export()
10+
11+
self.connection.send.has_been_called_with(b"<get_report_exports/>")
12+
13+
def test_get_report_export_with_id(self):
14+
self.gmp.get_report_export(report_export_id="e1")
15+
16+
self.connection.send.has_been_called_with(
17+
b'<get_report_exports report_export_id="e1"/>'
18+
)

‎tests/protocols/gmpnext/entities/report_exports/test_get_report_exports.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ def test_get_report_exports(self):
99
self.gmp.get_report_exports()
1010

1111
self.connection.send.has_been_called_with(b"<get_report_exports/>")
12-
13-
def test_get_report_exports_with_id(self):
14-
self.gmp.get_report_exports(report_export_id="e1")
15-
16-
self.connection.send.has_been_called_with(
17-
b'<get_report_exports report_export_id="e1"/>'
18-
)

‎tests/protocols/gmpnext/entities/test_report_exports.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
from ...gmpnext import GMPTestCase
77
from .report_exports import (
88
GmpGetReportExportsTestMixin,
9+
GmpGetReportExportTestMixin,
910
)
1011

1112

1213
class GmpGmpGetReportExportsTestCase(GmpGetReportExportsTestMixin, GMPTestCase):
1314
pass
15+
16+
17+
class GmpGmpGetReportExportTestCase(GmpGetReportExportTestMixin, GMPTestCase):
18+
pass

0 commit comments

Comments
 (0)