From a8644420eadb939d043410c216c323142120d5c5 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Tue, 5 Sep 2023 18:06:29 +0200 Subject: [PATCH 1/2] Change: request edit_config_family_all alongside edit_config_family --- src/gmp/commands/scanconfigs.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gmp/commands/scanconfigs.js b/src/gmp/commands/scanconfigs.js index 2723a61228..75e00aee46 100644 --- a/src/gmp/commands/scanconfigs.js +++ b/src/gmp/commands/scanconfigs.js @@ -127,13 +127,21 @@ export class ScanConfigCommand extends EntityCommand { } editScanConfigFamilySettings({id, familyName}) { - return this.httpGet({ + const get = this.httpGet({ cmd: 'edit_config_family', id, family: familyName, - }).then(response => { + }); + const all = this.httpGet({ + cmd: 'edit_config_family_all', + id, + family: familyName, + }); + return Promise.all([get, all]).then(([response, response_all]) => { const {data} = response; + const data_all = response_all.data; const config_resp = data.get_config_family_response; + const config_resp_all = data_all.get_config_family_response; const settings = {}; const nvts = {}; @@ -142,7 +150,7 @@ export class ScanConfigCommand extends EntityCommand { nvts[oid] = true; }); - settings.nvts = map(config_resp.all.get_nvts_response.nvt, nvt => { + settings.nvts = map(config_resp_all.get_nvts_response.nvt, nvt => { nvt.oid = nvt._oid; delete nvt._oid; From ca6f6948e5e6265ba92e6e883e4a95cc0c957a88 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 30 Oct 2023 13:36:30 +0200 Subject: [PATCH 2/2] Adjust test for edit_config_family_all --- src/gmp/commands/__tests__/scanconfig.js | 40 +++++++++++++----------- src/gmp/commands/testing.js | 9 ++++++ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/gmp/commands/__tests__/scanconfig.js b/src/gmp/commands/__tests__/scanconfig.js index e93c6569a9..a15f59db9b 100644 --- a/src/gmp/commands/__tests__/scanconfig.js +++ b/src/gmp/commands/__tests__/scanconfig.js @@ -18,6 +18,7 @@ import { createEntityResponse, createHttp, + createHttpMany, createActionResultResponse, createResponse, } from '../testing'; @@ -296,27 +297,30 @@ describe('ScanConfigCommand tests', () => { }, ], }, - all: { - get_nvts_response: { - nvt: [ - { - _oid: 1, - cvss_base: 1.1, - }, - { - _oid: 2, - cvss_base: 2.2, - }, - { - _oid: 3, - cvss_base: 3.3, - }, - ], - }, + }, + }); + const responseAll = createResponse({ + get_config_family_response: { + get_nvts_response: { + nvt: [ + { + _oid: 1, + cvss_base: 1.1, + }, + { + _oid: 2, + cvss_base: 2.2, + }, + { + _oid: 3, + cvss_base: 3.3, + }, + ], }, }, }); - const fakeHttp = createHttp(response); + const responses = [response, responseAll]; + const fakeHttp = createHttpMany(responses); expect.hasAssertions(); diff --git a/src/gmp/commands/testing.js b/src/gmp/commands/testing.js index 5dda055abb..9b978655e6 100644 --- a/src/gmp/commands/testing.js +++ b/src/gmp/commands/testing.js @@ -72,4 +72,13 @@ export const createHttp = response => ({ request: jest.fn().mockReturnValue(Promise.resolve(response)), }); +export const createHttpMany = responses => { + let i = 0; + return { + request: jest + .fn() + .mockImplementation(() => Promise.resolve(responses[i++])), + }; +}; + // vim: set ts=2 sw=2 tw=80: