-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This PR removes the flaky listModules and getModule Jest tests and adds them as functional API tests.
- Loading branch information
Showing
3 changed files
with
71 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
import { USER } from '../../../functional/services/machine_learning/security_common'; | ||
|
||
const COMMON_HEADERS = { | ||
'kbn-xsrf': 'some-xsrf-token', | ||
}; | ||
|
||
const moduleIds = [ | ||
'apache_ecs', | ||
'apm_jsbase', | ||
'apm_nodejs', | ||
'apm_transaction', | ||
'auditbeat_process_docker_ecs', | ||
'auditbeat_process_hosts_ecs', | ||
'logs_ui_analysis', | ||
'logs_ui_categories', | ||
'metricbeat_system_ecs', | ||
'nginx_ecs', | ||
'sample_data_ecommerce', | ||
'sample_data_weblogs', | ||
'siem_auditbeat', | ||
'siem_auditbeat_auth', | ||
'siem_packetbeat', | ||
'siem_winlogbeat', | ||
'siem_winlogbeat_auth', | ||
'uptime_heartbeat', | ||
]; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default ({ getService }: FtrProviderContext) => { | ||
const supertest = getService('supertestWithoutAuth'); | ||
const mlSecurity = getService('mlSecurity'); | ||
|
||
async function executeGetModuleRequest(module: string, user: USER, rspCode: number) { | ||
const { body } = await supertest | ||
.get(`/api/ml/modules/get_module/${module}`) | ||
.auth(user, mlSecurity.getPasswordForUser(user)) | ||
.set(COMMON_HEADERS) | ||
.expect(rspCode); | ||
|
||
return body; | ||
} | ||
|
||
describe('get_module', function() { | ||
it('lists all modules', async () => { | ||
const rspBody = await executeGetModuleRequest('', USER.ML_POWERUSER, 200); | ||
expect(rspBody).to.be.an(Array); | ||
|
||
const responseModuleIds = rspBody.map((module: { id: string }) => module.id); | ||
expect(responseModuleIds).to.eql(moduleIds); | ||
}); | ||
|
||
for (const moduleId of moduleIds) { | ||
it(`loads module ${moduleId}`, async () => { | ||
const rspBody = await executeGetModuleRequest(moduleId, USER.ML_POWERUSER, 200); | ||
expect(rspBody).to.be.an(Object); | ||
|
||
expect(rspBody.id).to.eql(moduleId); | ||
}); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters