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

Adjust task icons to work for audits and remove audit icons #2070

Merged
merged 12 commits into from
Mar 27, 2020
2 changes: 0 additions & 2 deletions gsa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,6 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/pages/audits/details.js
${GSA_SRC_DIR}/src/web/pages/audits/detailspage.js
${GSA_SRC_DIR}/src/web/pages/audits/dialog.js
${GSA_SRC_DIR}/src/web/pages/audits/icons/resumeicon.js
${GSA_SRC_DIR}/src/web/pages/audits/icons/starticon.js
${GSA_SRC_DIR}/src/web/pages/audits/listpage.js
${GSA_SRC_DIR}/src/web/pages/audits/row.js
${GSA_SRC_DIR}/src/web/pages/audits/table.js
Expand Down
27 changes: 11 additions & 16 deletions gsa/public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,8 @@
"Attach report": "Bericht anhängen",
"Audit": "Audit",
"Audit List": "Auditliste",
"Audit is already active": "Audit ist bereits aktiv",
"Audit is alterable": "Audit ist änderbar",
"Audit is configured to run on sensor {{name}}": "Audit ist konfiguriert auf dem Sensor {{name}} ausgeführt zu werden",
"Audit is not stopped": "Audit ist nicht gestoppt",
"Audit is scheduled": "Audit ist durch Zeitplan gesteuert",
"Audit made visible for: {{observers}}": "Audit sichtbar gemacht für: {{observers}}",
"Audit: {{name}}": "Audit: {{name}}",
"Audits": "Audits",
Expand Down Expand Up @@ -419,7 +416,6 @@
"DFN-CERT Advisories by Severity Class (Total: {{count}})": "DFN-CERT-Advisories nach Schweregradklasse (Gesamt: {{count}})",
"DFN-CERT Advisory": "DFN-CERT-Advisory",
"DFN-CERT Advisory: {{title}}": "DFN-CERT-Advisory: {{title}}",
"DN": "DN",
"Daily": "Täglich",
"Dashboard": "Dashboard",
"Dashboard Title": "Dashboardtitel",
Expand Down Expand Up @@ -873,7 +869,7 @@
"Latest": "Neueste",
"Latest Identifiers": "Neueste Identifikatoren",
"Latest Severity": "Neuester Schweregrad",
"License: GNU General Public License version 2 or any later version": "Lizenz: GNU General Public License Version 2 oder jede neuere Version",
"License: GNU Affero General Public License version 2 or any later version": "Lizenz: GNU Affero General Public License Version 2 oder jede neuere Version",
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
"List": "Liste",
"List Export File Name": "Dateiname für Listen-Export",
"List Items": "Ressourcen anzeigen",
Expand Down Expand Up @@ -1075,8 +1071,6 @@
"None available": "Nicht verfügbar",
"None.": "Keine.",
"None. Result was an open port.": "Keine. Das Ergebnis war ein offener Port.",
"Not Valid After": "Nicht gültig nach",
"Not Valid Before": "Nicht gültig vor",
"Not a valid PGP file": "Keine gültige PGP-Datei",
"Not finished yet": "Noch nicht beendet",
"Note": "Notiz",
Expand Down Expand Up @@ -1188,11 +1182,9 @@
"Permission to edit settings denied": "Keine Berechtigung, Einstellungen zu bearbeiten",
"Permission to edit {{entity}} denied": "Keine Berechtigung, {{entity}} zu bearbeiten",
"Permission to move {{entity}} to trashcan denied": "Keine Berechtigung, {{entity}} in den Papierkorb zu verschieben",
"Permission to resume audit denied": "Keine Berechtigung, Audit fortzusetzen",
"Permission to resume task denied": "Keine Berechtigung, Aufgabe fortzusetzen",
"Permission to start Audit denied": "Keine Berechtigung, Audit zu starten",
"Permission to start Task denied": "Keine Berechtigung, Aufgabe zu starten",
"Permission to stop Task denied": "Keine Berechtigung, Aufgabe zu stoppen",
"Permission to resume {{usageType}} denied": "Keine Berechtigung, {{usageType}} fortzusetzen",
"Permission to start {{usageType}} denied": "Keine Berechtigung, {{usageType}} zu starten",
"Permission to stop {{usageType}} denied": "Keine Berechtigung, {{usageType}} zu stoppen",
"Permission to verify {{entity}} denied": "Keine Berechtigung, {{entity}} zu verifizeren",
"Permission: {{name}}": "Berechtigung: {{name}}",
"Permissions": "Berechtigungen",
Expand Down Expand Up @@ -1615,12 +1607,8 @@
"Task List": "Aufgabenliste",
"Task Name": "Name der Aufgabe",
"Task Wizard": "Aufgaben-Wizard",
"Task is a container": "Aufgabe ist eine Container-Aufgabe",
"Task is already active": "Aufgabe ist bereits aktiv",
"Task is alterable": "Aufgabe ist änderbar",
"Task is configured to run on sensor {{name}}": "Aufgabe ist konfiguriert, um auf dem Sensor {{name}} ausgeführt zu werden",
"Task is not stopped": "Aufgabe ist nicht gestoppt",
"Task is scheduled": "Aufgabe ist durch Zeitplan gesteuert",
"Task made visible for:\n{{user}}\n{{role}}\n{{group}}": "Aufgabe sichtbar gemacht für:\n{{user}}\n{{role}}\n{{group}}",
"Task run status changed to": "Status der Aufgabe hat sich geändert zu",
"Task run status changed to {{status}}": "Aufgaben-Status geändert zu {{status}}",
Expand Down Expand Up @@ -1687,6 +1675,7 @@
"This is an Alterable Audit. Reports may not relate to current Policy or Target!": "Dies ist ein änderbares Audit. Berichte könnten sich nicht auf die aktuelle Richtlinie oder das aktuelle Ziel beziehen!",
"This is an Alterable Task. Reports may not relate to current Scan Config or Target!": "Dies ist eine änderbare Aufgabe. Berichte könnten sich nicht auf die aktuelle Scan-Konfiguration oder das aktuelle Ziel beziehen!",
"This setting is not alterable once task has been run at least once.": "Diese Einstellung ist nicht änderbar sobald die Aufgabe mindestens einmal ausgeführt wurde.",
"This setting is not alterable once the audit has been run at least once.": "Diese Einstellung ist nicht änderbar sobald das audit mindestens einmal ausgeführt wurde.",
"This web application uses cookies to store session information. The cookies are not stored on the server side hard disk and not submitted anywhere. They are lost when the session is closed or expired. The cookies are stored temporarily in your browser as well where you can examine the content.": "Diese Web-Anwendung nutzt Cookies, um Sitzungsinformationen zu speichern. Die Cookies werden nicht auf der serverseitigen Festplatte gespeichert und nirgendwohin übermittelt. Sie gehen verloren, wenn die Sitzung beendet wird oder ausläuft. Die Cookies werden außerdem temporär in Ihrem Browser gespeichert, wo Sie den Inhalt einsehen können.",
"This wizard can help you by creating a new scan task and automatically starting it.": "Dieser Wizard hilft Ihnen, indem er eine neue Scanaufgabe erstellt und diese automatisch startet.",
"This wizard will modify an existing task for you. The difference to the Edit Task dialog is that you can enter values for associated objects directly here. The objects will then be created for you automatically and assigned to the selected task.": "Dieser Wizard wird für Sie eine existierende Aufgabe bearbeiten. Der Unterschied zum \"Aufgabe bearbeiten\"-Dialog ist, dass Sie Werte von zugehörigen Objekten hier direkt eintragen können. Diese Objekte werden dann für Sie erstellt und automatisch der ausgewählten Aufgabe zugeordnet.",
Expand Down Expand Up @@ -1853,6 +1842,7 @@
"Zoom in": "Einzoomen",
"Zoom out": "Auszoomen",
"at": "um",
"audit": "Audit",
"changed": "verändert",
"day(s)": "Tag(e)",
"days": "Tage",
Expand Down Expand Up @@ -1883,6 +1873,7 @@
"reports": "Berichte",
"result(s) NVT(s)": "Ergebnis-NVT(s)",
"result(s) more than previous scan": "Ergebnis(se) mehr als im vorherigen Scan",
"task": "Aufgabe",
"to": "für",
"undefined": "undefiniert",
"until {{- enddate}}": "bis {{- enddate}}",
Expand Down Expand Up @@ -1953,5 +1944,9 @@
"{{title}} {{filtered}} of {{all}}": "{{title}} {{filtered}} von {{all}}",
"{{type}} owned by {{owner}}": "{{type}} gehört {{owner}}",
"{{type}}:unnamed": "{{type}}:unbenannt",
"{{usageType}} is a container": "{{usageType}} ist Container-{{usageType}}",
"{{usageType}} is already active": "{{usageType}} ist bereits aktiv",
"{{usageType}} is not stopped": "{{usageType}} ist nicht gestoppt",
"{{usageType}} is scheduled": "{{usageType}} ist durch Zeitplan gesteuert",
"{{value}}: {{count}} (severity: {{severity}})": "{{value}}: {{count}} (Schweregrad: {{severity}})"
}
180 changes: 177 additions & 3 deletions gsa/src/web/pages/audits/__tests__/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Audit, {AUDIT_STATUS} from 'gmp/models/audit';
setLocale('en');

const caps = new Capabilities(['everything']);
const wrongCaps = new Capabilities(['authenticate']);
const wrongCaps = new Capabilities(['get_task']);

describe('Audit Actions tests', () => {
// deactivate console.error for tests
Expand All @@ -45,6 +45,7 @@ describe('Audit Actions tests', () => {
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'everything'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down Expand Up @@ -83,6 +84,7 @@ describe('Audit Actions tests', () => {
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'everything'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down Expand Up @@ -150,8 +152,9 @@ describe('Audit Actions tests', () => {
status: AUDIT_STATUS.done,
alterable: '0',
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'authenticate'}]},
permissions: {permission: [{name: 'get_task'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down Expand Up @@ -186,7 +189,174 @@ describe('Audit Actions tests', () => {
expect(handleAuditStart).not.toHaveBeenCalledWith(audit);
expect(icons[0]).toHaveAttribute(
'title',
'Permission to start Audit denied',
'Permission to start audit denied',
);

fireEvent.click(icons[1]);
expect(handleAuditResume).not.toHaveBeenCalledWith(audit);
expect(icons[1]).toHaveAttribute('title', 'Audit is not stopped');

fireEvent.click(icons[2]);
expect(handleAuditDelete).not.toHaveBeenCalledWith(audit);
expect(icons[2]).toHaveAttribute(
'title',
'Permission to move Audit to trashcan denied',
);

fireEvent.click(icons[3]);
expect(handleAuditEdit).not.toHaveBeenCalledWith(audit);
expect(icons[3]).toHaveAttribute(
'title',
'Permission to edit Audit denied',
);

fireEvent.click(icons[4]);
expect(handleAuditClone).not.toHaveBeenCalledWith(audit);
expect(icons[4]).toHaveAttribute(
'title',
'Permission to clone Audit denied',
);

fireEvent.click(icons[5]);
expect(handleAuditDownload).toHaveBeenCalledWith(audit);
expect(icons[5]).toHaveAttribute('title', 'Export Audit');

fireEvent.click(icons[6]);
expect(handleReportDownload).toHaveBeenCalledWith(audit);
expect(icons[6]).toHaveAttribute(
'title',
'Download Greenbone Compliance Report',
);
});

test('should not call click handlers for stopped audit without permissions', () => {
const audit = Audit.fromElement({
status: AUDIT_STATUS.stopped,
alterable: '0',
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'get_task'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
const handleAuditDelete = jest.fn();
const handleAuditDownload = jest.fn();
const handleAuditEdit = jest.fn();
const handleAuditResume = jest.fn();
const handleAuditStart = jest.fn();
const handleAuditStop = jest.fn();
const handleReportDownload = jest.fn();

const {render} = rendererWith({capabilities: wrongCaps});
const {getAllByTestId} = render(
<Actions
entity={audit}
gcrFormatDefined={true}
links={true}
onAuditCloneClick={handleAuditClone}
onAuditDeleteClick={handleAuditDelete}
onAuditDownloadClick={handleAuditDownload}
onAuditEditClick={handleAuditEdit}
onAuditResumeClick={handleAuditResume}
onAuditStartClick={handleAuditStart}
onAuditStopClick={handleAuditStop}
onReportDownloadClick={handleReportDownload}
/>,
);

const icons = getAllByTestId('svg-icon');

fireEvent.click(icons[0]);
expect(handleAuditStart).not.toHaveBeenCalledWith(audit);
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
expect(icons[0]).toHaveAttribute(
'title',
'Permission to start audit denied',
);

fireEvent.click(icons[1]);
expect(handleAuditResume).not.toHaveBeenCalledWith(audit);
expect(icons[1]).toHaveAttribute(
'title',
'Permission to resume audit denied',
);

fireEvent.click(icons[2]);
expect(handleAuditDelete).not.toHaveBeenCalledWith(audit);
expect(icons[2]).toHaveAttribute(
'title',
'Permission to move Audit to trashcan denied',
);

fireEvent.click(icons[3]);
expect(handleAuditEdit).not.toHaveBeenCalledWith(audit);
expect(icons[3]).toHaveAttribute(
'title',
'Permission to edit Audit denied',
);

fireEvent.click(icons[4]);
expect(handleAuditClone).not.toHaveBeenCalledWith(audit);
expect(icons[4]).toHaveAttribute(
'title',
'Permission to clone Audit denied',
);

fireEvent.click(icons[5]);
expect(handleAuditDownload).toHaveBeenCalledWith(audit);
expect(icons[5]).toHaveAttribute('title', 'Export Audit');

fireEvent.click(icons[6]);
expect(handleReportDownload).toHaveBeenCalledWith(audit);
expect(icons[6]).toHaveAttribute(
'title',
'Download Greenbone Compliance Report',
);
});

test('should not call click handlers for running audit without permissions', () => {
const audit = Audit.fromElement({
status: AUDIT_STATUS.running,
alterable: '0',
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'get_task'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
const handleAuditDelete = jest.fn();
const handleAuditDownload = jest.fn();
const handleAuditEdit = jest.fn();
const handleAuditResume = jest.fn();
const handleAuditStart = jest.fn();
const handleAuditStop = jest.fn();
const handleReportDownload = jest.fn();

const {render} = rendererWith({capabilities: wrongCaps});
const {getAllByTestId} = render(
<Actions
entity={audit}
gcrFormatDefined={true}
links={true}
onAuditCloneClick={handleAuditClone}
onAuditDeleteClick={handleAuditDelete}
onAuditDownloadClick={handleAuditDownload}
onAuditEditClick={handleAuditEdit}
onAuditResumeClick={handleAuditResume}
onAuditStartClick={handleAuditStart}
onAuditStopClick={handleAuditStop}
onReportDownloadClick={handleReportDownload}
/>,
);

const icons = getAllByTestId('svg-icon');

fireEvent.click(icons[0]);
expect(handleAuditStop).not.toHaveBeenCalledWith(audit);
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
expect(icons[0]).toHaveAttribute(
'title',
'Permission to stop audit denied',
);

fireEvent.click(icons[1]);
Expand Down Expand Up @@ -233,6 +403,7 @@ describe('Audit Actions tests', () => {
in_use: true,
permissions: {permission: [{name: 'everything'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down Expand Up @@ -300,6 +471,7 @@ describe('Audit Actions tests', () => {
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'everything'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down Expand Up @@ -369,6 +541,7 @@ describe('Audit Actions tests', () => {
last_report: {report: {_id: 'id'}},
permissions: {permission: [{name: 'everything'}]},
target: {_id: 'id', name: 'target'},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down Expand Up @@ -419,6 +592,7 @@ describe('Audit Actions tests', () => {
name: 'schedule1',
permissions: {permission: [{name: 'everything'}]},
},
usage_type: 'audit',
});

const handleAuditClone = jest.fn();
Expand Down
Loading