Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get reports with details by default #333

Merged
merged 9 commits into from
Nov 14, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
* Moved tests for `SeverityLevel` Enum and `get_severity_level_from_string()` [#327](https://github.com/greenbone/python-gvm/pull/327)
* In `get_report()` the `details` parameter is `True` on default now. [#333](https://github.com/greenbone/python-gvm/pull/333)

### Deprecated
### Removed
Expand Down
8 changes: 4 additions & 4 deletions gvm/protocols/gmpv7/gmpv7.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018 - 2019 Greenbone Networks GmbH
# Copyright (C) 2018 - 2020 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
Expand Down Expand Up @@ -3733,7 +3733,7 @@ def get_report(
delta_report_id: Optional[str] = None,
report_format_id: Optional[Union[str, ReportFormatType]] = None,
ignore_pagination: Optional[bool] = None,
details: Optional[bool] = None
details: Optional[bool] = True
) -> Any:
"""Request a single report

Expand All @@ -3747,6 +3747,7 @@ def get_report(
ignore_pagination: Whether to ignore the filter terms "first" and
"rows".
details: Request additional report information details
defaults to True

Returns:
The response. See :py:meth:`send_command` for details.
Expand Down Expand Up @@ -3774,8 +3775,7 @@ def get_report(
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))
cmd.set_attribute("details", _to_bool(details))

return self._send_xml_command(cmd)

Expand Down
16 changes: 8 additions & 8 deletions tests/protocols/gmpv7/testcmds/test_get_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Greenbone Networks GmbH
# Copyright (C) 2018-2020 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
Expand Down Expand Up @@ -37,21 +37,21 @@ def test_get_report_with_filter(self):
self.gmp.get_report(report_id='r1', filter='name=foo')

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

def test_get_report_with_filter_id(self):
self.gmp.get_report(report_id='r1', filter_id='f1')

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

def test_get_report_with_report_format_id(self):
self.gmp.get_report(report_id='r1', report_format_id='bar')

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

def test_get_report_with_report_format_type(self):
Expand All @@ -61,7 +61,7 @@ def test_get_report_with_report_format_type(self):
report_format_id = get_report_format_id_from_string('txt').value

self.connection.send.has_been_called_with(
'<get_reports report_id="r1" format_id="{}"/>'.format(
'<get_reports report_id="r1" format_id="{}" details="1"/>'.format(
report_format_id
)
)
Expand All @@ -70,20 +70,20 @@ def test_get_report_with_delta_report_id(self):
self.gmp.get_report(report_id='r1', delta_report_id='r2')

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

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"/>'
'<get_reports report_id="r1" ignore_pagination="1" details="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"/>'
'<get_reports report_id="r1" ignore_pagination="0" details="1"/>'
)

def test_get_report_with_details(self):
Expand Down