Skip to content

Commit 9d81b73

Browse files
authored
Change: Remove hardcoded ignore_pagination from get_reports (#821)
1 parent 6dddf66 commit 9d81b73

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

gvm/protocols/gmpv208/entities/reports.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def get_reports(
107107
filter_id: Optional[str] = None,
108108
note_details: Optional[bool] = None,
109109
override_details: Optional[bool] = None,
110+
ignore_pagination: Optional[bool] = None,
110111
details: Optional[bool] = None,
111112
) -> Any:
112113
"""Request a list of reports
@@ -117,6 +118,8 @@ def get_reports(
117118
note_details: If notes are included, whether to include note details
118119
override_details: If overrides are included, whether to include
119120
override details
121+
ignore_pagination: Whether to ignore the filter terms "first" and
122+
"rows".
120123
details: Whether to exclude results
121124
122125
Returns:
@@ -139,7 +142,8 @@ def get_reports(
139142
if details is not None:
140143
cmd.set_attribute("details", to_bool(details))
141144

142-
cmd.set_attribute("ignore_pagination", "1")
145+
if ignore_pagination is not None:
146+
cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination))
143147

144148
return self._send_xml_command(cmd)
145149

tests/protocols/gmpv208/entities/reports/test_get_reports.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ class GmpGetReportsTestMixin:
2121
def test_get_reports(self):
2222
self.gmp.get_reports()
2323

24-
self.connection.send.has_been_called_with(
25-
'<get_reports ignore_pagination="1"/>'
26-
)
24+
self.connection.send.has_been_called_with("<get_reports/>")
2725

2826
def test_get_reports_with_filter_string(self):
29-
self.gmp.get_reports(filter_string="name=foo")
27+
self.gmp.get_reports(filter_string="name=foo", ignore_pagination=1)
3028

3129
self.connection.send.has_been_called_with(
3230
'<get_reports report_filter="name=foo" ignore_pagination="1"/>'
@@ -36,47 +34,43 @@ def test_get_reports_with_filter_id(self):
3634
self.gmp.get_reports(filter_id="f1")
3735

3836
self.connection.send.has_been_called_with(
39-
'<get_reports report_filt_id="f1" ignore_pagination="1"/>'
37+
'<get_reports report_filt_id="f1"/>'
4038
)
4139

4240
def test_get_reports_without_note_details(self):
4341
self.gmp.get_reports(note_details=False)
4442

4543
self.connection.send.has_been_called_with(
46-
'<get_reports note_details="0" ignore_pagination="1"/>'
44+
'<get_reports note_details="0"/>'
4745
)
4846

4947
def test_get_reports_with_note_details(self):
50-
self.gmp.get_reports(note_details=True)
48+
self.gmp.get_reports(note_details=True, ignore_pagination=False)
5149

5250
self.connection.send.has_been_called_with(
53-
'<get_reports note_details="1" ignore_pagination="1"/>'
51+
'<get_reports note_details="1" ignore_pagination="0"/>'
5452
)
5553

5654
def test_get_reports_without_override_details(self):
5755
self.gmp.get_reports(override_details=False)
5856

5957
self.connection.send.has_been_called_with(
60-
'<get_reports override_details="0" ignore_pagination="1"/>'
58+
'<get_reports override_details="0"/>'
6159
)
6260

6361
def test_get_reports_with_override_details(self):
6462
self.gmp.get_reports(override_details=True)
6563

6664
self.connection.send.has_been_called_with(
67-
'<get_reports override_details="1" ignore_pagination="1"/>'
65+
'<get_reports override_details="1"/>'
6866
)
6967

7068
def test_get_reports_with_details(self):
7169
self.gmp.get_reports(details=True)
7270

73-
self.connection.send.has_been_called_with(
74-
'<get_reports details="1" ignore_pagination="1"/>'
75-
)
71+
self.connection.send.has_been_called_with('<get_reports details="1"/>')
7672

7773
def test_get_reports_without_details(self):
7874
self.gmp.get_reports(details=False)
7975

80-
self.connection.send.has_been_called_with(
81-
'<get_reports details="0" ignore_pagination="1"/>'
82-
)
76+
self.connection.send.has_been_called_with('<get_reports details="0"/>')

0 commit comments

Comments
 (0)