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) {
|
if (group) {
|
||||||
alerts = this.alerts.filter(i => i.group === group);
|
alerts = this.alerts.filter(i => i.group === group);
|
||||||
} else if (hash) {
|
} else if (hash) {
|
||||||
const mid = md5(hash);
|
alerts = this.alerts.filter(i => i.alert.hash === hash);
|
||||||
alerts = this.alerts.filter(i => i.alert.hash === mid);
|
|
||||||
} else {
|
} else {
|
||||||
alerts = this.alerts;
|
alerts = this.alerts;
|
||||||
}
|
}
|
||||||
@@ -121,7 +120,6 @@ export default class ReportPullAPI extends Report {
|
|||||||
});
|
});
|
||||||
this.alerts = this.alerts.slice(-this.maxAlertsAmount);
|
this.alerts = this.alerts.slice(-this.maxAlertsAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@@ -77,7 +77,8 @@ describe("Core functions", function() {
|
|||||||
"volume",
|
"volume",
|
||||||
"groupsFile",
|
"groupsFile",
|
||||||
"persistStatus",
|
"persistStatus",
|
||||||
"rpki"
|
"rpki",
|
||||||
|
"rest"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(config.connectors[0]).to.have
|
expect(config.connectors[0]).to.have
|
||||||
|
@@ -40,6 +40,7 @@ const cacheCloneDirectory = "tests/.cache_clone/";
|
|||||||
const asyncTimeout = 120000;
|
const asyncTimeout = 120000;
|
||||||
global.EXTERNAL_VERSION_FOR_TEST = "0.0.1";
|
global.EXTERNAL_VERSION_FOR_TEST = "0.0.1";
|
||||||
global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml";
|
global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml";
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
const worker = require("../index");
|
const worker = require("../index");
|
||||||
const pubSub = worker.pubSub;
|
const pubSub = worker.pubSub;
|
||||||
@@ -564,6 +565,19 @@ describe("Alerting", function () {
|
|||||||
});
|
});
|
||||||
pubSub.publish("test-type", "fade-off");
|
pubSub.publish("test-type", "fade-off");
|
||||||
}).timeout(asyncTimeout);
|
}).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 () {
|
describe("Status storage", function () {
|
||||||
|
@@ -49,21 +49,17 @@ describe("Uptime Monitor", function() {
|
|||||||
expect(config.processMonitors[0]).to
|
expect(config.processMonitors[0]).to
|
||||||
.containSubset({
|
.containSubset({
|
||||||
params: {
|
params: {
|
||||||
useStatusCodes: true,
|
useStatusCodes: true
|
||||||
host: null,
|
|
||||||
port: 8011
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("API format and header", function (done) {
|
it("API format and header", function (done) {
|
||||||
|
|
||||||
const port = config.processMonitors[0].params.port;
|
|
||||||
|
|
||||||
axios({
|
axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
url: `http://localhost:${port}/status`
|
url: `http://localhost:8011/status`
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
expect(data.status).to.equal(200);
|
expect(data.status).to.equal(200);
|
||||||
|
@@ -61,6 +61,21 @@ reports:
|
|||||||
persistAlertData: false
|
persistAlertData: false
|
||||||
alertDataDirectory: alertdata/
|
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
|
# The file containing the monitored prefixes. Please see monitored_prefixes_test.yml for an example
|
||||||
# This is an array (use new lines and dashes!)
|
# This is an array (use new lines and dashes!)
|
||||||
@@ -85,8 +100,6 @@ processMonitors:
|
|||||||
- file: uptimeApi
|
- file: uptimeApi
|
||||||
params:
|
params:
|
||||||
useStatusCodes: true
|
useStatusCodes: true
|
||||||
host: null
|
|
||||||
port: 8011
|
|
||||||
|
|
||||||
rpki:
|
rpki:
|
||||||
vrpProvider: ntt
|
vrpProvider: ntt
|
||||||
|
@@ -87,13 +87,6 @@ volume: volumetests/
|
|||||||
|
|
||||||
groupsFile: groups.test.yml
|
groupsFile: groups.test.yml
|
||||||
|
|
||||||
processMonitors:
|
|
||||||
- file: uptimeApi
|
|
||||||
params:
|
|
||||||
useStatusCodes: true
|
|
||||||
host: null
|
|
||||||
port: 8011
|
|
||||||
|
|
||||||
rpki:
|
rpki:
|
||||||
vrpProvider: ntt
|
vrpProvider: ntt
|
||||||
preCacheROAs: true
|
preCacheROAs: true
|
||||||
|
Reference in New Issue
Block a user