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

Add: Add pages for new Report Config type #3960

Merged
merged 2 commits into from
Feb 20, 2024
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
16 changes: 15 additions & 1 deletion public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"Alerts Filter": "Benachrichtigungen-Filter",
"Alerts List": "Benachrichtigungsliste",
"Alerts using this Filter": "Benachrichtigungen, die diesen Filter verwenden",
"Alerts using this Report Config": "Benachrichtigungen, die diese Berichtkonfiguration verwenden",
"Alerts using this Report Format": "Benachrichtigungen, die dieses Berichtformat verwenden",
"Alive Test": "Erreichbarkeitstest",
"All": "Alle",
Expand Down Expand Up @@ -308,6 +309,7 @@
"Closed CVEs": "Geschlossene CVEs",
"Comment": "Kommentar",
"Community": "Community",
"Configurable": "Konfigurierbar",
"Complete": "Vollständig",
"Complexity": "Komplexität",
"Compliance Audits": "Compliance Audits",
Expand Down Expand Up @@ -514,6 +516,8 @@
"Edit Policy {{name}}": "Richtlinie {{name}} bearbeiten",
"Edit Port List {{name}}": "Portliste {{name}} bearbeiten",
"Edit RADIUS Authentication": "RADIUS-Authentifizierung bearbeiten",
"Edit Report Config": "Berichtkonfiguration bearbeiten",
"Edit Report Config {{name}}": "Berichtkonfiguration {{name}} bearbeiten",
"Edit Report Format {{name}}": "Berichtformat {{name}} bearbeiten",
"Edit Role {{name}}": "Rolle {{name}} bearbeiten",
"Edit Scan Config Family": "Scan-Konfiguration-Familie bearbeiten",
Expand Down Expand Up @@ -613,6 +617,7 @@
"Export Policy as XML": "Richtlinie als XML exportieren",
"Export Port List": "Portliste exportieren",
"Export PortList as XML": "Portliste als XML exportieren",
"Export Report Config": "Berichtkonfiguration exportieren",
"Export Result as XML": "Ergebnis als XML exportieren",
"Export Role": "Rolle exportieren",
"Export Role as XML": "Rolle als XML exportieren",
Expand Down Expand Up @@ -741,6 +746,7 @@
"Help: RADIUS Authentication": "Hilfe: RADIUS-Authentifizierung",
"Help: Reading Reports": "Hilfe: Berichte lesen",
"Help: Remediation Tickets": "Hilfe: Remediation-Tickets",
"Help: Report Configs": "Hilfe: Berichtkonfigurationen",
"Help: Report Formats": "Hilfe: Berichtformate",
"Help: Reports": "Hilfe: Berichte",
"Help: Results": "Hilfe: Ergebnisse",
Expand Down Expand Up @@ -972,6 +978,7 @@
"New Port List": "Neue Portliste",
"New Port Range": "Neuer Portbereich",
"New Quick Task": "Neue Schnell-Aufgabe",
"New Report Config": "Neue Berichtkonfiguration",
"New Role": "Neue Rolle",
"New Scan Config": "Neue Scan-Konfiguration",
"New Scanner": "Neuer Scanner",
Expand Down Expand Up @@ -1118,6 +1125,7 @@
"Page Not Found.": "Seite nicht gefunden.",
"Pagination": "Seitenadressierung",
"Parameters": "Parameter",
"Parameter Details": "Parameter-Details",
"Partial": "Partiell",
"Partition": "Partition",
"Passphrase": "Passphrase",
Expand Down Expand Up @@ -1242,8 +1250,14 @@
"Report Content": "Berichtinhalt",
"Report Details": "Bericht Details",
"Report Export File Name": "Dateiname für Bericht-Export",
"Report Config": "Berichtkonfiguration",
"Report Config: {{name}}": "Berichtkonfiguration: {{name}}",
"Report Configs": "Berichtkonfigurationen",
"Report Configs Filter": "Berichtkonfigurations-Filter",
"Report Configs List": "Berichtkonfigurationsliste",
"Report Configs using this Report Format": "Berichtkonfigurationen, die dieses Berichtformat verwenden",
"Report Format": "Berichtformat",
"Report Format: {{name}}": "Berichtformate: {{name}}",
"Report Format: {{name}}": "Berichtformat: {{name}}",
"Report Formats": "Berichtformate",
"Report Formats Filter": "Berichtformate-Filter",
"Report Formats List": "Berichtformatliste",
Expand Down
2 changes: 2 additions & 0 deletions src/gmp/capabilities/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const types = {
policies: 'config',
portlist: 'port_list',
portlists: 'port_list',
reportconfig: 'report_config',
reportconfigs: 'report_config',
reportformat: 'report_format',
reportformats: 'report_format',
scanconfig: 'config',
Expand Down
152 changes: 152 additions & 0 deletions src/gmp/commands/__tests__/reportconfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/* Copyright (C) 2024 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
createHttp,
createEntityResponse,
createActionResultResponse,
} from '../testing';
import {ReportConfigCommand} from '../reportconfigs';

describe('ReportConfigCommand tests', () => {
test('should return single report config', () => {
const response = createEntityResponse('report_config', {
_id: 'foo',
});

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigCommand(fakeHttp);
return cmd.get({id: 'foo'}).then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('get', {
args: {
cmd: 'get_report_config',
report_config_id: 'foo',
},
});
const {data} = resp;
expect(data.id).toEqual('foo');
});
});

test('should create report config', () => {
const response = createActionResultResponse();

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigCommand(fakeHttp);
return cmd
.create({
name: 'foo',
comment: 'bar',
report_format_id: 'baz',
params: {
'param 1': 'value 1',
'param 2': 'value 2',
'param 3': ['report-format-1', 'report-format-2'],
},
params_using_default: {
'param 1': false,
'param 2': true,
'param 3': false,
},
})
.then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('post', {
data: {
cmd: 'create_report_config',
name: 'foo',
comment: 'bar',
report_format_id: 'baz',
'param:param 1': 'value 1',
'param:param 2': 'value 2',
'param:param 3': 'report-format-1,report-format-2',
'param_using_default:param 2': 1,
},
});
const {data} = resp;
expect(data.id).toEqual('foo');
});
});

test('should save report config', () => {
const response = createActionResultResponse();

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigCommand(fakeHttp);
return cmd
.save({
name: 'foo',
comment: 'bar',
report_format_id: 'should-be-ignored-in-save',
params: {
'param 1': 'value A',
'param 2': 'value B',
'param 3': ['report-format-A', 'report-format-B'],
},
params_using_default: {
'param 1': true,
'param 2': false,
'param 3': false,
},
})
.then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('post', {
data: {
cmd: 'save_report_config',
name: 'foo',
comment: 'bar',
'param:param 1': 'value A',
'param:param 2': 'value B',
'param:param 3': 'report-format-A,report-format-B',
'param_using_default:param 1': 1,
},
});
const {data} = resp;
expect(data.id).toEqual('foo');
});
});

test('should delete report config', () => {
const response = createActionResultResponse();

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigCommand(fakeHttp);
return cmd
.delete({
id: 'foo',
})
.then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('post', {
data: {
cmd: 'delete_report_config',
report_config_id: 'foo',
},
});
});
});
});
102 changes: 102 additions & 0 deletions src/gmp/commands/__tests__/reportconfigs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/* Copyright (C) 2024 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {createHttp, createEntitiesResponse} from '../testing';
import {ReportConfigsCommand} from '../reportconfigs';
import {ALL_FILTER} from 'gmp/models/filter';

describe('ReportConfigsCommand tests', () => {
test('should return all report configs', () => {
const response = createEntitiesResponse('report_config', [
{
_id: '1',
},
{
_id: '2',
},
]);

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigsCommand(fakeHttp);
return cmd.getAll().then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('get', {
args: {
cmd: 'get_report_configs',
filter: ALL_FILTER.toFilterString(),
},
});
const {data} = resp;
expect(data.length).toEqual(2);
});
});

test('should return report configs', () => {
const response = createEntitiesResponse('report_config', [
{
_id: '1',
},
{
_id: '2',
},
]);

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigsCommand(fakeHttp);
return cmd.get().then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('get', {
args: {
cmd: 'get_report_configs',
},
});
const {data} = resp;
expect(data.length).toEqual(2);
});
});

test('should return filtered report configs', () => {
const response = createEntitiesResponse('report_config', [
{
_id: '1',
},
{
_id: '2',
},
]);

const fakeHttp = createHttp(response);

expect.hasAssertions();

const cmd = new ReportConfigsCommand(fakeHttp);
return cmd.get({filter: 'test filter'}).then(resp => {
expect(fakeHttp.request).toHaveBeenCalledWith('get', {
args: {
cmd: 'get_report_configs',
filter: 'test filter',
},
});
const {data} = resp;
expect(data.length).toEqual(2);
});
});
});
Loading
Loading