forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reporting Test Serverless structure: api_integration #7
Merged
rshen91
merged 1 commit into
rshen91:e2e-svl-reporting
from
tsullivan:e2e-svl-reporting
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 0 additions & 22 deletions
22
x-pack/test_serverless/api_integration/services/reporting_api.ts
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
x-pack/test_serverless/api_integration/services/svl_reporting.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,99 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
const DATA_ANALYST_PASSWORD = 'data_analyst-password'; | ||
const DATA_ANALYST_ROLE = 'data_analyst_role'; | ||
const DATA_ANALYST_USERNAME = 'data_analyst'; | ||
const REPORTING_ROLE = 'reporting_user_role'; | ||
const REPORTING_USER_PASSWORD = 'reporting_user-password'; | ||
const REPORTING_USER_USERNAME = 'reporting_user'; | ||
|
||
export function SvlReportingServiceProvider({ getService }: FtrProviderContext) { | ||
const security = getService('security'); | ||
|
||
return { | ||
DATA_ANALYST_PASSWORD, | ||
DATA_ANALYST_USERNAME, | ||
REPORTING_USER_PASSWORD, | ||
REPORTING_USER_USERNAME, | ||
|
||
/** | ||
* Define a role that DOES NOT grant privileges to create any type of report. | ||
*/ | ||
async createDataAnalystRole() { | ||
await security.role.create(DATA_ANALYST_ROLE, { | ||
metadata: {}, | ||
elasticsearch: { | ||
cluster: [], | ||
indices: [ | ||
{ | ||
names: ['ecommerce'], | ||
privileges: ['read', 'view_index_metadata'], | ||
allow_restricted_indices: false, | ||
}, | ||
], | ||
run_as: [], | ||
}, | ||
kibana: [ | ||
{ | ||
base: ['read'], | ||
feature: {}, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}); | ||
}, | ||
|
||
async createDataAnalystUser() { | ||
await security.user.create(DATA_ANALYST_USERNAME, { | ||
password: DATA_ANALYST_PASSWORD, | ||
roles: [DATA_ANALYST_ROLE], | ||
full_name: 'Data Analyst User', | ||
}); | ||
}, | ||
|
||
/** | ||
* Define a role that DOES grant privileges to create certain types of reports. | ||
*/ | ||
async createReportingRole() { | ||
await security.role.create(REPORTING_ROLE, { | ||
metadata: {}, | ||
elasticsearch: { | ||
cluster: [], | ||
indices: [ | ||
{ | ||
names: ['ecommerce'], | ||
privileges: ['read', 'view_index_metadata'], | ||
allow_restricted_indices: false, | ||
}, | ||
], | ||
run_as: [], | ||
}, | ||
kibana: [ | ||
{ | ||
base: [], | ||
feature: { discover: ['minimal_read', 'generate_report'] }, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}); | ||
}, | ||
|
||
async createReportingUser( | ||
username = REPORTING_USER_USERNAME, | ||
password = REPORTING_USER_PASSWORD | ||
) { | ||
await security.user.create(username, { | ||
password, | ||
roles: [REPORTING_ROLE], | ||
full_name: 'Reporting User', | ||
}); | ||
}, | ||
}; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
x-pack/test_serverless/api_integration/test_suites/common/reporting/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,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export default ({ loadTestFile }: FtrProviderContext) => { | ||
describe('Reporting', function () { | ||
loadTestFile(require.resolve('./management')); | ||
}); | ||
}; |
66 changes: 66 additions & 0 deletions
66
x-pack/test_serverless/api_integration/test_suites/common/reporting/management.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,66 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common/src/constants'; | ||
import { INTERNAL_ROUTES } from '@kbn/reporting-plugin/common/constants'; | ||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
// the archived data holds a report created by test_user | ||
const TEST_USERNAME = 'test_user'; | ||
const TEST_USER_PASSWORD = 'changeme'; | ||
const API_HEADER: [string, string] = ['kbn-xsrf', 'reporting']; | ||
const INTERNAL_HEADER: [string, string] = [X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'Kibana']; | ||
|
||
export default ({ getService }: FtrProviderContext) => { | ||
const esArchiver = getService('esArchiver'); | ||
const reportingAPI = getService('svlReportingAPI'); | ||
const supertest = getService('supertestWithoutAuth'); | ||
|
||
describe('Reporting Management', function () { | ||
before(async () => { | ||
// NOTE: unused, since we only need test_user for this suite | ||
await reportingAPI.createReportingRole(); | ||
await reportingAPI.createReportingUser(); | ||
await reportingAPI.createReportingUser(TEST_USERNAME, TEST_USER_PASSWORD); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await esArchiver.load('x-pack/test/functional/es_archives/reporting/archived_reports'); | ||
}); | ||
|
||
after(async () => { | ||
await esArchiver.unload('x-pack/test/functional/es_archives/reporting/archived_reports'); | ||
}); | ||
|
||
describe('Deletion', () => { | ||
const DELETE_REPORT_ID = 'krazcyw4156m0763b503j7f9'; | ||
|
||
it(`user can delete a report they've created`, async () => { | ||
const response = await supertest | ||
.delete(`${INTERNAL_ROUTES.JOBS.DELETE_PREFIX}/${DELETE_REPORT_ID}`) | ||
.auth(TEST_USERNAME, TEST_USER_PASSWORD) | ||
.set(...API_HEADER) | ||
.set(...INTERNAL_HEADER); | ||
|
||
expect(response.status).to.be(200); | ||
expect(response.body).to.eql({ deleted: true }); | ||
}); | ||
|
||
it(`user can not delete a report they haven't created`, async () => { | ||
const response = await supertest | ||
.delete(`${INTERNAL_ROUTES.JOBS.DELETE_PREFIX}/${DELETE_REPORT_ID}`) | ||
.auth(reportingAPI.REPORTING_USER_USERNAME, reportingAPI.REPORTING_USER_PASSWORD) | ||
.set(...API_HEADER) | ||
.set(...INTERNAL_HEADER); | ||
|
||
expect(response.status).to.be(404); | ||
expect(response.body.message).to.be('Not Found'); | ||
}); | ||
}); | ||
}); | ||
}; |
45 changes: 0 additions & 45 deletions
45
x-pack/test_serverless/api_integration/test_suites/reporting/config.ts
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
x-pack/test_serverless/api_integration/test_suites/reporting/index.ts
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
x-pack/test_serverless/api_integration/test_suites/reporting/management.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By design, the only serverless test suites are:
observability
,search
,security
andcommon
. Reporting tests should go undercommon
.