-
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.
- Loading branch information
Showing
13 changed files
with
196 additions
and
6 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
x-pack/test/reporting_api_integration/reporting_without_security.config.ts
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,45 @@ | ||
/* | ||
* 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 { esTestConfig, kbnTestConfig } from '@kbn/test'; | ||
import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; | ||
import { format as formatUrl } from 'url'; | ||
import { ReportingAPIProvider } from './services'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const apiConfig = await readConfigFile(require.resolve('../api_integration/config')); | ||
|
||
return { | ||
servers: apiConfig.get('servers'), | ||
junit: { reportName: 'X-Pack Reporting Without Security API Integration Tests' }, | ||
testFiles: [require.resolve('./reporting_without_security')], | ||
services: { | ||
...apiConfig.get('services'), | ||
reportingAPI: ReportingAPIProvider, | ||
}, | ||
esArchiver: apiConfig.get('esArchiver'), | ||
esTestCluster: { | ||
...apiConfig.get('esTestCluster'), | ||
serverArgs: [ | ||
...apiConfig.get('esTestCluster.serverArgs'), | ||
'node.name=UnsecuredClusterNode01', | ||
'xpack.security.enabled=false', | ||
], | ||
}, | ||
kbnTestServer: { | ||
...apiConfig.get('kbnTestServer'), | ||
serverArgs: [ | ||
`--elasticsearch.hosts=${formatUrl(esTestConfig.getUrlParts())}`, | ||
`--logging.json=false`, | ||
`--server.maxPayloadBytes=1679958`, | ||
`--server.port=${kbnTestConfig.getPort()}`, | ||
`--xpack.reporting.capture.maxAttempts=1`, | ||
`--xpack.reporting.csv.maxSizeBytes=2850`, | ||
`--xpack.security.enabled=false`, | ||
], | ||
}, | ||
}; | ||
} |
15 changes: 15 additions & 0 deletions
15
x-pack/test/reporting_api_integration/reporting_without_security/index.ts
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,15 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function ({ loadTestFile }: FtrProviderContext) { | ||
describe('Reporting APIs', function () { | ||
this.tags('ciGroup2'); | ||
loadTestFile(require.resolve('./job_apis')); | ||
}); | ||
} |
126 changes: 126 additions & 0 deletions
126
x-pack/test/reporting_api_integration/reporting_without_security/job_apis.ts
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,126 @@ | ||
/* | ||
* 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 { forOwn } from 'lodash'; | ||
import { JOB_PARAMS_RISON } from '../fixtures'; | ||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function ({ getService }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const supertestNoAuth = getService('supertestWithoutAuth'); | ||
const reportingAPI = getService('reportingAPI'); | ||
|
||
describe('Job Listing APIs, Without Security', () => { | ||
before(async () => { | ||
await esArchiver.load('reporting/logs'); | ||
await esArchiver.load('logstash_functional'); | ||
}); | ||
|
||
after(async () => { | ||
await esArchiver.unload('reporting/logs'); | ||
await esArchiver.unload('logstash_functional'); | ||
}); | ||
|
||
afterEach(async () => { | ||
await reportingAPI.deleteAllReports(); | ||
}); | ||
|
||
it('Posted CSV job is visible in the job count', async () => { | ||
const { status: resStatus, text: resText } = await supertestNoAuth | ||
.post(`/api/reporting/generate/csv`) | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ jobParams: JOB_PARAMS_RISON }); | ||
|
||
expect(resStatus).to.be(200); | ||
|
||
const { job: resJob } = JSON.parse(resText); | ||
const expectedResJob: Record<string, any> = { | ||
attempts: 0, | ||
created_by: false, | ||
jobtype: 'csv', | ||
max_attempts: 1, | ||
priority: 10, | ||
status: 'pending', | ||
timeout: 120000, | ||
browser_type: 'chromium', // TODO: remove this field from the API response | ||
// TODO: remove the payload field from the api respones | ||
}; | ||
forOwn(expectedResJob, (value: any, key: string) => { | ||
expect(resJob[key]).to.eql(value, key); | ||
}); | ||
|
||
// call the job count api | ||
const { text: countText } = await supertestNoAuth | ||
.get(`/api/reporting/jobs/count`) | ||
.set('kbn-xsrf', 'xxx'); | ||
|
||
const countResult = JSON.parse(countText); | ||
expect(countResult).to.be(1); | ||
}); | ||
|
||
it('Posted CSV job is visible in the status check', async () => { | ||
const { status: resStatus, text: resText } = await supertestNoAuth | ||
.post(`/api/reporting/generate/csv`) | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ jobParams: JOB_PARAMS_RISON }); | ||
|
||
expect(resStatus).to.be(200); | ||
|
||
const { job: resJob } = JSON.parse(resText); | ||
// call the single job listing api (status check) | ||
const { text: listText } = await supertestNoAuth | ||
.get(`/api/reporting/jobs/list?page=0&ids=${resJob.id}`) | ||
.set('kbn-xsrf', 'xxx'); | ||
|
||
const listingJobs = JSON.parse(listText); | ||
const expectedListJob: Record<string, any> = { | ||
attempts: 0, | ||
created_by: false, | ||
jobtype: 'csv', | ||
timeout: 120000, | ||
browser_type: 'chromium', | ||
}; | ||
forOwn(expectedListJob, (value: any, key: string) => { | ||
expect(listingJobs[0]._source[key]).to.eql(value, key); | ||
}); | ||
|
||
expect(listingJobs.length).to.be(1); | ||
expect(listingJobs[0]._id).to.be(resJob.id); | ||
}); | ||
|
||
it('Posted CSV job is visible in the first page of jobs listing', async () => { | ||
const { status: resStatus, text: resText } = await supertestNoAuth | ||
.post(`/api/reporting/generate/csv`) | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ jobParams: JOB_PARAMS_RISON }); | ||
|
||
expect(resStatus).to.be(200); | ||
|
||
const { job: resJob } = JSON.parse(resText); | ||
// call the ALL job listing api | ||
const { text: listText } = await supertestNoAuth | ||
.get(`/api/reporting/jobs/list?page=0`) | ||
.set('kbn-xsrf', 'xxx'); | ||
|
||
const listingJobs = JSON.parse(listText); | ||
const expectedListJob: Record<string, any> = { | ||
attempts: 0, | ||
created_by: false, | ||
jobtype: 'csv', | ||
timeout: 120000, | ||
browser_type: 'chromium', | ||
}; | ||
forOwn(expectedListJob, (value: any, key: string) => { | ||
expect(listingJobs[0]._source[key]).to.eql(value, key); | ||
}); | ||
|
||
expect(listingJobs.length).to.be(1); | ||
expect(listingJobs[0]._id).to.be(resJob.id); | ||
}); | ||
}); | ||
} |
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