Skip to content

Commit

Permalink
Merge pull request #163 from bjoernricks/report-arguments
Browse files Browse the repository at this point in the history
Report arguments
  • Loading branch information
bjoernricks authored Oct 10, 2019
2 parents afab5f3 + 43a8670 commit f78cba2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]

### Added
* Added ignore_pagination and details arguments for get_report [PR 163](https://github.com/greenbone/python-gvm/pull/163)
* Introducing Gmpv9 [PR 157](https://github.com/greenbone/python-gvm/pull/157)
* Added new `create_audit` method, to create a task with the `usage_type` `audit` [PR 157](https://github.com/greenbone/python-gvm/pull/157)
* Added new `create_policy` method, to create a config with the `usage_type` `policy` [PR 157](https://github.com/greenbone/python-gvm/pull/157)
Expand Down
13 changes: 12 additions & 1 deletion gvm/protocols/gmpv7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,9 @@ def get_report(
filter: Optional[str] = None,
filter_id: Optional[str] = None,
delta_report_id: Optional[str] = None,
report_format_id: Optional[str] = None
report_format_id: Optional[str] = None,
ignore_pagination: Optional[bool] = None,
details: Optional[bool] = None
) -> Any:
"""Request a single report
Expand All @@ -3417,6 +3419,9 @@ def get_report(
filter_id: UUID of filter to use to filter results in the report
delta_report_id: UUID of an existing report to compare report to.
report_format_id: UUID of report format to use
ignore_pagination: Whether to ignore the filter terms "first" and
"rows".
details: Request addititional report information details
Returns:
The response. See :py:meth:`send_command` for details.
Expand All @@ -3435,6 +3440,12 @@ def get_report(
if report_format_id:
cmd.set_attribute("format_id", report_format_id)

if ignore_pagination is not None:
cmd.set_attribute("ignore_pagination", _to_bool(ignore_pagination))

if details is not None:
cmd.set_attribute("details", _to_bool(details))

return self._send_xml_command(cmd)

def get_report_formats(
Expand Down
26 changes: 26 additions & 0 deletions tests/protocols/gmpv7/test_get_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ def test_get_report_with_delta_report_id(self):
'<get_reports report_id="r1" delta_report_id="r2"/>'
)

def test_get_report_with_ignore_pagination(self):
self.gmp.get_report(report_id='r1', ignore_pagination=True)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" ignore_pagination="1"/>'
)

self.gmp.get_report(report_id='r1', ignore_pagination=False)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" ignore_pagination="0"/>'
)

def test_get_report_with_details(self):
self.gmp.get_report(report_id='r1', details=True)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" details="1"/>'
)

self.gmp.get_report(report_id='r1', details=False)

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" details="0"/>'
)


if __name__ == '__main__':
unittest.main()

0 comments on commit f78cba2

Please sign in to comment.