diff --git a/src/reports/reportPullAPI.js b/src/reports/reportPullAPI.js index b8ff33b..6eee65b 100644 --- a/src/reports/reportPullAPI.js +++ b/src/reports/reportPullAPI.js @@ -92,8 +92,7 @@ export default class ReportPullAPI extends Report { if (group) { alerts = this.alerts.filter(i => i.group === group); } else if (hash) { - const mid = md5(hash); - alerts = this.alerts.filter(i => i.alert.hash === mid); + alerts = this.alerts.filter(i => i.alert.hash === hash); } else { alerts = this.alerts; } @@ -121,7 +120,6 @@ export default class ReportPullAPI extends Report { }); this.alerts = this.alerts.slice(-this.maxAlertsAmount); } - } }; } \ No newline at end of file diff --git a/tests/1_config.js b/tests/1_config.js index c5864ce..144b0a4 100644 --- a/tests/1_config.js +++ b/tests/1_config.js @@ -77,7 +77,8 @@ describe("Core functions", function() { "volume", "groupsFile", "persistStatus", - "rpki" + "rpki", + "rest" ]); expect(config.connectors[0]).to.have diff --git a/tests/2_alerting.js b/tests/2_alerting.js index 1b96071..81bbef0 100644 --- a/tests/2_alerting.js +++ b/tests/2_alerting.js @@ -40,6 +40,7 @@ const cacheCloneDirectory = "tests/.cache_clone/"; const asyncTimeout = 120000; global.EXTERNAL_VERSION_FOR_TEST = "0.0.1"; global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml"; +const axios = require("axios"); const worker = require("../index"); const pubSub = worker.pubSub; @@ -564,6 +565,19 @@ describe("Alerting", function () { }); pubSub.publish("test-type", "fade-off"); }).timeout(asyncTimeout); + + it("pull API alerting", function (done) { + + axios({ + url: "http://localhost:8011/alerts/8e402e65f393ba4812df5da0db7605e9", + responseType: "json", + method: "GET" + }) + .then(a => { + expect(a.data.data[0].hash).to.equal("8e402e65f393ba4812df5da0db7605e9"); + done(); + }) + }).timeout(asyncTimeout); }); describe("Status storage", function () { diff --git a/tests/3_uptimemonitor.js b/tests/3_uptimemonitor.js index b6c8b44..9a4efef 100644 --- a/tests/3_uptimemonitor.js +++ b/tests/3_uptimemonitor.js @@ -49,21 +49,17 @@ describe("Uptime Monitor", function() { expect(config.processMonitors[0]).to .containSubset({ params: { - useStatusCodes: true, - host: null, - port: 8011 + useStatusCodes: true } }); }); it("API format and header", function (done) { - const port = config.processMonitors[0].params.port; - axios({ method: 'get', responseType: 'json', - url: `http://localhost:${port}/status` + url: `http://localhost:8011/status` }) .then(data => { expect(data.status).to.equal(200); diff --git a/tests/config.test.yml b/tests/config.test.yml index 7ff2224..06ac72d 100644 --- a/tests/config.test.yml +++ b/tests/config.test.yml @@ -61,6 +61,21 @@ reports: persistAlertData: false alertDataDirectory: alertdata/ + - file: reportPullAPI + channels: + - hijack + - newprefix + - visibility + - path + - misconfiguration + - rpki + params: + maxAlertsAmount: 100 + +rest: + host: null + port: 8011 + # The file containing the monitored prefixes. Please see monitored_prefixes_test.yml for an example # This is an array (use new lines and dashes!) @@ -85,8 +100,6 @@ processMonitors: - file: uptimeApi params: useStatusCodes: true - host: null - port: 8011 rpki: vrpProvider: ntt diff --git a/tests/neighbor_tests/config.test.yml b/tests/neighbor_tests/config.test.yml index 2e91910..804da74 100644 --- a/tests/neighbor_tests/config.test.yml +++ b/tests/neighbor_tests/config.test.yml @@ -87,13 +87,6 @@ volume: volumetests/ groupsFile: groups.test.yml -processMonitors: - - file: uptimeApi - params: - useStatusCodes: true - host: null - port: 8011 - rpki: vrpProvider: ntt preCacheROAs: true