mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
added monitorRPKI tests
This commit is contained in:
@@ -382,6 +382,44 @@ export default class ConnectorTest extends Connector{
|
||||
}
|
||||
];
|
||||
break;
|
||||
|
||||
case "rpki":
|
||||
updates = [
|
||||
{
|
||||
data: {
|
||||
announcements: [{
|
||||
prefixes: ["82.112.100.0/24"], // Valid
|
||||
next_hop: "124.0.0.3"
|
||||
}],
|
||||
peer: "124.0.0.4",
|
||||
path: [1, 2, 3, 4321, 2914]
|
||||
},
|
||||
type: "ris_message"
|
||||
},
|
||||
{
|
||||
data: {
|
||||
announcements: [{
|
||||
prefixes: ["8.8.8.8/22"], // Not covered
|
||||
next_hop: "124.0.0.3"
|
||||
}],
|
||||
peer: "124.0.0.4",
|
||||
path: [1, 2, 3, 4321, 5060, 2914]
|
||||
},
|
||||
type: "ris_message"
|
||||
},
|
||||
{
|
||||
data: {
|
||||
announcements: [{
|
||||
prefixes: ["103.21.244.0/24"], // Invalid
|
||||
next_hop: "124.0.0.3"
|
||||
}],
|
||||
peer: "124.0.0.4",
|
||||
path: [1, 2, 3, 4321, 13335]
|
||||
},
|
||||
type: "ris_message"
|
||||
}
|
||||
];
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@@ -97,7 +97,7 @@ describe("Composition", function() {
|
||||
|
||||
it("loading monitors", function () {
|
||||
|
||||
expect(config.monitors.length).to.equal(6);
|
||||
expect(config.monitors.length).to.equal(7);
|
||||
|
||||
expect(config.monitors[0]).to
|
||||
.containSubset({
|
||||
@@ -144,6 +144,18 @@ describe("Composition", function() {
|
||||
}
|
||||
});
|
||||
|
||||
expect(config.monitors[5]).to
|
||||
.containSubset({
|
||||
"channel": "rpki-monitor",
|
||||
"name": "rpki-monitor",
|
||||
"params": {
|
||||
"thresholdMinPeers": 1,
|
||||
"preCacheROAs": false,
|
||||
"refreshVrpListMinutes": 15,
|
||||
"checkUncovered": true
|
||||
}
|
||||
});
|
||||
|
||||
expect(config.monitors[config.monitors.length - 1]).to
|
||||
.containSubset({
|
||||
"channel": "software-update",
|
||||
@@ -297,7 +309,7 @@ describe("Composition", function() {
|
||||
]
|
||||
});
|
||||
|
||||
expect(input.asns.map(i => i.asn.getValue())).to.eql([ 2914, 3333, 65000 ]);
|
||||
expect(input.asns.map(i => i.asn.getValue())).to.eql([ 2914, 3333, 13335, 65000 ]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -35,7 +35,7 @@ var chaiSubset = require('chai-subset');
|
||||
chai.use(chaiSubset);
|
||||
var expect = chai.expect;
|
||||
|
||||
let asyncTimeout = 20000;
|
||||
let asyncTimeout = 2000000;
|
||||
global.EXTERNAL_VERSION_FOR_TEST = "0.0.1";
|
||||
global.EXTERNAL_CONFIG_FILE = "tests/config.test.yml";
|
||||
|
||||
@@ -477,8 +477,6 @@ describe("Alerting", function () {
|
||||
|
||||
}).timeout(asyncTimeout);
|
||||
|
||||
|
||||
|
||||
it("asn monitoring reporting", function (done) {
|
||||
|
||||
pubSub.publish("test-type", "misconfiguration");
|
||||
@@ -529,6 +527,58 @@ describe("Alerting", function () {
|
||||
|
||||
}).timeout(asyncTimeout);
|
||||
|
||||
it("RPKI monitoring", function (done) {
|
||||
|
||||
pubSub.publish("test-type", "rpki");
|
||||
|
||||
const expectedData = {
|
||||
|
||||
|
||||
"a103_21_244_0_24AS13335": {
|
||||
id: "a103_21_244_0_24AS13335",
|
||||
origin: 'rpki-monitor',
|
||||
affected: '103.21.244.0/24',
|
||||
message: 'The route 103.21.244.0/24 announced by AS13335 is not RPKI valid. Accepted with AS path: [1,2,3,4321,13335]. Valid ROA: origin AS0 prefix 103.21.244.0/23 max length 23',
|
||||
},
|
||||
|
||||
"a8_8_8_8_22AS2914": {
|
||||
id: "a8_8_8_8_22AS2914",
|
||||
origin: 'rpki-monitor',
|
||||
affected: '8.8.8.8/22',
|
||||
message: 'The route 8.8.8.8/22 announced by AS2914 is not covered by a ROA.',
|
||||
}
|
||||
};
|
||||
|
||||
let rpkiTestCompleted = false;
|
||||
pubSub.subscribe("rpki-monitor", function (type, message) {
|
||||
|
||||
if (!rpkiTestCompleted) {
|
||||
message = JSON.parse(JSON.stringify(message));
|
||||
const id = message.id;
|
||||
|
||||
expect(Object.keys(expectedData).includes(id)).to.equal(true);
|
||||
expect(expectedData[id] != null).to.equal(true);
|
||||
|
||||
expect(message).to
|
||||
.containSubset(expectedData[id]);
|
||||
|
||||
expect(message).to.contain
|
||||
.keys([
|
||||
"latest",
|
||||
"earliest"
|
||||
]);
|
||||
|
||||
delete expectedData[id];
|
||||
if (Object.keys(expectedData).length === 0) {
|
||||
setTimeout(() => {
|
||||
rpkiTestCompleted = true;
|
||||
done();
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}).timeout(asyncTimeout);
|
||||
|
||||
it("fading alerting", function (done) {
|
||||
|
||||
|
@@ -37,6 +37,16 @@ monitors:
|
||||
params:
|
||||
thresholdMinPeers: 2
|
||||
|
||||
- file: monitorRPKI
|
||||
channel: rpki-monitor
|
||||
name: rpki-monitor
|
||||
params:
|
||||
thresholdMinPeers: 1
|
||||
preCacheROAs: false
|
||||
refreshVrpListMinutes: 15
|
||||
checkUncovered: true
|
||||
|
||||
|
||||
reports:
|
||||
- file: reportFile
|
||||
channels:
|
||||
@@ -45,14 +55,12 @@ reports:
|
||||
- visibility
|
||||
- path
|
||||
- misconfiguration
|
||||
- rpki-monitor
|
||||
params:
|
||||
persistAlertData: false
|
||||
alertDataDirectory: alertdata/
|
||||
|
||||
notificationIntervalSeconds: 1800 # Repeat the same alert (which keeps being triggered) after x seconds
|
||||
alertOnlyOnce: false
|
||||
fadeOffSeconds: 10
|
||||
checkFadeOffGroupsSeconds: 2
|
||||
|
||||
|
||||
# The file containing the monitored prefixes. Please see monitored_prefixes_test.yml for an example
|
||||
# This is an array (use new lines and dashes!)
|
||||
@@ -76,6 +84,11 @@ processMonitors:
|
||||
host: null
|
||||
port: 8011
|
||||
|
||||
|
||||
notificationIntervalSeconds: 1800 # Repeat the same alert (which keeps being triggered) after x seconds
|
||||
alertOnlyOnce: false
|
||||
fadeOffSeconds: 10
|
||||
checkFadeOffGroupsSeconds: 2
|
||||
pidFile: bgpalerter.pid
|
||||
multiProcess: false
|
||||
maxMessagesPerSecond: 6000
|
@@ -101,4 +101,6 @@ options:
|
||||
2914:
|
||||
group: default
|
||||
3333:
|
||||
group: default
|
||||
13335:
|
||||
group: default
|
Reference in New Issue
Block a user