From 71f3db24be3ec5a9b80fc3efbf0ba09c78d10370 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Mon, 26 Aug 2019 21:07:58 +0200 Subject: [PATCH 1/5] Add parseTrend() function to ScanConfig model --- gsa/src/gmp/models/scanconfig.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gsa/src/gmp/models/scanconfig.js b/gsa/src/gmp/models/scanconfig.js index f1d4695882..c9664af2e7 100644 --- a/gsa/src/gmp/models/scanconfig.js +++ b/gsa/src/gmp/models/scanconfig.js @@ -55,6 +55,8 @@ export const openVasScanConfigsFilter = config => export const ospScanConfigsFilter = config => config.scan_config_type === OSP_SCAN_CONFIG_TYPE; +const parseTrend = trend => parseInt(trend); + class ScanConfig extends Model { static entityType = 'scanconfig'; @@ -85,7 +87,7 @@ class ScanConfig extends Model { if (isDefined(ret.family_count)) { families.count = parse_count(ret.family_count.__text); - families.trend = ret.family_count.growing; + families.trend = parseTrend(ret.family_count.growing); delete ret.family_count; } else { @@ -97,7 +99,7 @@ class ScanConfig extends Model { if (isDefined(ret.nvt_count)) { ret.nvts = { count: parse_count(ret.nvt_count.__text), - trend: ret.nvt_count.growing, + trend: parseTrend(ret.nvt_count.growing), }; delete ret.nvt_count; From aef4f67f2313edad57c48fda2e71df763d5b5f80 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Mon, 26 Aug 2019 21:10:56 +0200 Subject: [PATCH 2/5] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d925f2eee..4c71ed6237 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added +- Added parseTrend() function to ScanConfig model [#1583](https://github.com/greenbone/gsa/pull/1583) - Added DetailsPage and more funtionalities to TLS Certificate assets [#1578](https://github.com/greenbone/gsa/pull/1578) - Added Explicit Compliance [#1495](https://github.com/greenbone/gsa/pull/1495) - Added tasktrendgroup component for tasks filter dialog [#1511](https://github.com/greenbone/gsa/pull/1511) From 78c6dba2427f8d776eaa627e2331c525107d56dc Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Mon, 26 Aug 2019 21:28:05 +0200 Subject: [PATCH 3/5] Adjust ScanConfig model tests --- gsa/src/gmp/models/__tests__/scanconfig.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gsa/src/gmp/models/__tests__/scanconfig.js b/gsa/src/gmp/models/__tests__/scanconfig.js index 3ec14ea5f6..0ccc50c2e8 100644 --- a/gsa/src/gmp/models/__tests__/scanconfig.js +++ b/gsa/src/gmp/models/__tests__/scanconfig.js @@ -119,7 +119,7 @@ describe('ScanConfig model tests', () => { const scanConfig = new ScanConfig(elem); expect(scanConfig.families.count).toEqual(42); - expect(scanConfig.families.trend).toEqual('1'); + expect(scanConfig.families.trend).toEqual(1); expect(scanConfig.family_count).toBeUndefined(); }); @@ -134,7 +134,7 @@ describe('ScanConfig model tests', () => { }; const res = { count: 42, - trend: '1', + trend: 1, known: 21, max: 1337, }; From a9d23fbfae5d1cbe77f21b8a46050e74cc0193d2 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Tue, 27 Aug 2019 14:07:46 +0200 Subject: [PATCH 4/5] Use SCANCONFIG_TREND_DYNAMIC constant in ScanConfig model tests --- gsa/src/gmp/models/__tests__/scanconfig.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gsa/src/gmp/models/__tests__/scanconfig.js b/gsa/src/gmp/models/__tests__/scanconfig.js index 0ccc50c2e8..71621c2395 100644 --- a/gsa/src/gmp/models/__tests__/scanconfig.js +++ b/gsa/src/gmp/models/__tests__/scanconfig.js @@ -24,6 +24,7 @@ import ScanConfig, { filterEmptyScanConfig, openVasScanConfigsFilter, ospScanConfigsFilter, + SCANCONFIG_TREND_DYNAMIC, } from 'gmp/models/scanconfig'; import {testModel} from 'gmp/models/testing'; @@ -119,7 +120,7 @@ describe('ScanConfig model tests', () => { const scanConfig = new ScanConfig(elem); expect(scanConfig.families.count).toEqual(42); - expect(scanConfig.families.trend).toEqual(1); + expect(scanConfig.families.trend).toEqual(SCANCONFIG_TREND_DYNAMIC); expect(scanConfig.family_count).toBeUndefined(); }); @@ -134,7 +135,7 @@ describe('ScanConfig model tests', () => { }; const res = { count: 42, - trend: 1, + trend: SCANCONFIG_TREND_DYNAMIC, known: 21, max: 1337, }; From a0d45a75961f2da4b9a0d28b120c9c351f0dbe68 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Tue, 27 Aug 2019 14:23:58 +0200 Subject: [PATCH 5/5] Simplify parseTrend() --- gsa/src/gmp/models/scanconfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsa/src/gmp/models/scanconfig.js b/gsa/src/gmp/models/scanconfig.js index c9664af2e7..f872d45e90 100644 --- a/gsa/src/gmp/models/scanconfig.js +++ b/gsa/src/gmp/models/scanconfig.js @@ -55,7 +55,7 @@ export const openVasScanConfigsFilter = config => export const ospScanConfigsFilter = config => config.scan_config_type === OSP_SCAN_CONFIG_TYPE; -const parseTrend = trend => parseInt(trend); +const parseTrend = parseInt; class ScanConfig extends Model { static entityType = 'scanconfig';