1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00
Files
nttgin-BGPalerter/tests/4_groups.js
Massimo Candela c44f5a9209 added support for external config manager and for user groups definition file (#489)
* refactoring to support external configuration module

* allow for external connectors

* refactored retrieval of roa flat data structure now delegated to rpk-validator lib

* introduced support for external user group config file

* increased test coverage

* external group file documentation

* improve documentation on generatePrefixListEveryDays (#482)

* add comments on test connectors (#497)
2021-03-02 04:42:14 +01:00

84 lines
3.1 KiB
JavaScript

/*
* BSD 3-Clause License
*
* Copyright (c) 2019, NTT Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const chai = require("chai");
const fs = require("fs");
const chaiSubset = require('chai-subset');
chai.use(chaiSubset);
const expect = chai.expect;
const volume = "volumetests/";
const asyncTimeout = 20000;
// Prepare test environment
if (!fs.existsSync(volume)) {
fs.mkdirSync(volume);
}
fs.copyFileSync("tests/config.test.yml", volume + "config.test.yml");
fs.copyFileSync("tests/prefixes.test.yml", volume + "prefixes.test.yml");
fs.copyFileSync("tests/groups.test.yml", volume + "groups.test.yml");
global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml";
const worker = require("../index");
describe("External groups file", function() {
it("load groups", function () {
const config = worker.config;
expect(config.groupsFile).to.equal("groups.test.yml");
expect(config.reports[0].params.userGroups).to
.containSubset({
test: [
"filename"
]
});
})
.timeout(asyncTimeout);
it("watch groups", function (done) {
fs.copyFileSync("tests/groups.test.after.yml", "volumetests/groups.test.yml");
setTimeout(() => {
const config = worker.config;
expect(config.reports[0].params.userGroups).to
.containSubset({
test: [
"filename-after"
]
});
done();
}, 10000);
})
.timeout(asyncTimeout);
});