2018-09-10 08:32:49 +00:00
|
|
|
const chai = require('chai');
|
|
|
|
const needle = require('needle');
|
2018-09-03 09:46:55 +00:00
|
|
|
|
2018-09-10 08:42:05 +00:00
|
|
|
const { version, revision } = require('../../package.json');
|
2018-09-11 10:26:48 +00:00
|
|
|
|
2018-12-04 08:38:18 +00:00
|
|
|
const kibanaServer = process.env.KIBANA_IP || 'localhost';
|
|
|
|
|
2018-09-03 09:46:55 +00:00
|
|
|
chai.should();
|
|
|
|
|
2018-09-10 08:32:49 +00:00
|
|
|
const headers = {
|
|
|
|
headers: { 'kbn-xsrf': 'kibana', 'Content-Type': 'application/json' }
|
|
|
|
};
|
2018-09-03 09:46:55 +00:00
|
|
|
|
|
|
|
describe('wazuh-elastic', () => {
|
2018-09-10 08:32:49 +00:00
|
|
|
describe('Checking index patterns', () => {
|
2018-10-01 07:56:50 +00:00
|
|
|
it('GET /elastic/index-patterns', async () => {
|
2018-11-02 17:23:00 +00:00
|
|
|
const res = await needle(
|
|
|
|
'get',
|
2018-12-04 08:38:18 +00:00
|
|
|
`${kibanaServer}:5601/elastic/index-patterns`,
|
2018-11-02 17:23:00 +00:00
|
|
|
{},
|
|
|
|
headers
|
|
|
|
);
|
2018-09-10 08:32:49 +00:00
|
|
|
res.body.data.should.be.a('array');
|
|
|
|
res.body.data.length.should.be.gt(0);
|
|
|
|
res.body.data[0].should.be.a('object');
|
|
|
|
res.body.data[0].id.should.be.a('string');
|
|
|
|
res.body.data[0].title.should.be.a('string');
|
|
|
|
});
|
2018-09-03 09:46:55 +00:00
|
|
|
|
2018-10-01 07:56:50 +00:00
|
|
|
it('GET /elastic/known-fields/{pattern}', async () => {
|
2018-09-10 08:32:49 +00:00
|
|
|
const res = await needle(
|
|
|
|
'get',
|
2018-12-04 08:38:18 +00:00
|
|
|
`${kibanaServer}:5601/elastic/known-fields/wazuh-alerts-3.x-*`,
|
2018-09-10 08:32:49 +00:00
|
|
|
{},
|
|
|
|
headers
|
|
|
|
);
|
|
|
|
res.body.acknowledge.should.be.eql(true);
|
|
|
|
res.body.output.should.be.a('object');
|
2018-12-04 08:38:18 +00:00
|
|
|
//res.body.output._index.should.be.eql('.kibana');
|
2018-09-10 08:32:49 +00:00
|
|
|
res.body.output._type.should.be.eql('doc');
|
|
|
|
res.body.output._id.should.be.eql('index-pattern:wazuh-alerts-3.x-*');
|
|
|
|
});
|
|
|
|
});
|
2018-09-03 09:46:55 +00:00
|
|
|
|
2018-09-10 08:32:49 +00:00
|
|
|
describe('Checking visualization composers', () => {
|
2018-10-01 07:56:50 +00:00
|
|
|
it('GET /elastic/visualizations/{tab}/{pattern}', async () => {
|
2018-09-10 08:32:49 +00:00
|
|
|
const res = await needle(
|
|
|
|
'get',
|
2018-12-04 08:38:18 +00:00
|
|
|
`${kibanaServer}:5601/elastic/visualizations/overview-general/wazuh-alerts-3.x-*`,
|
2018-09-10 08:32:49 +00:00
|
|
|
{},
|
|
|
|
headers
|
|
|
|
);
|
|
|
|
res.body.acknowledge.should.be.eql(true);
|
|
|
|
res.body.raw.should.be.a('array');
|
|
|
|
res.body.raw.length.should.be.eql(15);
|
|
|
|
res.body.raw[0].attributes.should.be.a('object');
|
|
|
|
res.body.raw[0].type.should.be.eql('visualization');
|
|
|
|
res.body.raw[0].id.should.be.a('string');
|
|
|
|
});
|
2018-09-03 09:46:55 +00:00
|
|
|
|
2018-10-01 07:56:50 +00:00
|
|
|
it('POST /elastic/visualizations/{tab}/{pattern}', async () => {
|
2018-09-10 08:32:49 +00:00
|
|
|
const res = await needle(
|
|
|
|
'post',
|
2018-12-04 08:38:18 +00:00
|
|
|
`${kibanaServer}:5601/elastic/visualizations/cluster-monitoring/wazuh-alerts-3.x-*`,
|
2018-09-10 08:32:49 +00:00
|
|
|
{ nodes: { items: [], name: 'node01' } },
|
|
|
|
headers
|
|
|
|
);
|
|
|
|
res.body.acknowledge.should.be.eql(true);
|
|
|
|
res.body.raw.should.be.a('array');
|
|
|
|
res.body.raw.length.should.be.eql(4);
|
|
|
|
res.body.raw[0].attributes.should.be.a('object');
|
|
|
|
res.body.raw[0].type.should.be.eql('visualization');
|
|
|
|
res.body.raw[0].id.should.be.a('string');
|
|
|
|
});
|
|
|
|
});
|
2018-09-03 09:46:55 +00:00
|
|
|
|
2018-09-10 08:32:49 +00:00
|
|
|
describe('Checking template and index pattern existance', () => {
|
2018-10-01 07:56:50 +00:00
|
|
|
it('GET /elastic/template/{pattern}', async () => {
|
2018-09-10 08:32:49 +00:00
|
|
|
const res = await needle(
|
|
|
|
'get',
|
2018-12-04 08:38:18 +00:00
|
|
|
`${kibanaServer}:5601/elastic/template/wazuh-alerts-3.x-*`,
|
2018-09-10 08:32:49 +00:00
|
|
|
{},
|
|
|
|
headers
|
|
|
|
);
|
|
|
|
res.body.statusCode.should.be.eql(200);
|
|
|
|
res.body.status.should.be.eql(true);
|
|
|
|
res.body.data.should.be.eql('Template found for wazuh-alerts-3.x-*');
|
|
|
|
});
|
2018-09-03 09:46:55 +00:00
|
|
|
|
2018-10-01 07:56:50 +00:00
|
|
|
it('GET /elastic/index-patterns/{pattern}', async () => {
|
2018-09-10 08:32:49 +00:00
|
|
|
const res = await needle(
|
|
|
|
'get',
|
2018-12-04 08:38:18 +00:00
|
|
|
`${kibanaServer}:5601/elastic/index-patterns/wazuh-alerts-3.x-*`,
|
2018-09-10 08:32:49 +00:00
|
|
|
{},
|
|
|
|
headers
|
|
|
|
);
|
|
|
|
res.body.statusCode.should.be.eql(200);
|
|
|
|
res.body.status.should.be.eql(true);
|
|
|
|
res.body.data.should.be.eql('Index pattern found');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|