mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
introduced tests for pull api
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
@@ -77,7 +77,8 @@ describe("Core functions", function() {
|
||||
"volume",
|
||||
"groupsFile",
|
||||
"persistStatus",
|
||||
"rpki"
|
||||
"rpki",
|
||||
"rest"
|
||||
]);
|
||||
|
||||
expect(config.connectors[0]).to.have
|
||||
|
@@ -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 () {
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user