Skip to content

[APM] Run API tests as restricted user#70050

Merged
dgieselaar merged 6 commits intoelastic:masterfrom
dgieselaar:tests-as-apm-user
Jun 29, 2020
Merged

[APM] Run API tests as restricted user#70050
dgieselaar merged 6 commits intoelastic:masterfrom
dgieselaar:tests-as-apm-user

Conversation

@dgieselaar
Copy link
Copy Markdown
Contributor

Run API tests as a user that has the apm_user role and the kibana_admin role. These are (roughly) the minimum requirements for using APM.

Run API tests as a user that has the apm_user role and the kibana_admin role. These are (roughly) the minimum requirements for using APM.
@dgieselaar dgieselaar added Team:APM - DEPRECATED Use Team:obs-ux-infra_services. release_note:skip Skip the PR/issue when compiling release notes v7.9.0 labels Jun 26, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/apm-ui (Team:apm)

Copy link
Copy Markdown
Contributor

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!! Thanks for doing this.
This will help us so much - next steps: apm dataset and api tests for all the endpoints!

@dgieselaar
Copy link
Copy Markdown
Contributor Author

@sqren made some changes, instead of having one apm_user that can do everything, we now run tests with two users, one with read privileges to APM and one with all.

@dgieselaar dgieselaar requested a review from sorenlouv June 27, 2020 12:42
Comment on lines +44 to +77
case ApmUser.APM_WRITE_USER:
await security.role.create(ApmUser.APM_WRITE_USER, {
elasticsearch: {
cluster: [],
indices: [
{
names: ['observability-annotations'],
privileges: [
'read',
'view_index_metadata',
'index',
'manage',
'create_index',
'create_doc',
],
},
],
},
kibana: [
{
base: [],
feature: {
apm: ['all'],
},
spaces: ['*'],
},
],
});

await security.user.create(ApmUser.APM_WRITE_USER, {
full_name: ApmUser.APM_WRITE_USER,
password: APM_TEST_PASSWORD,
roles: ['apm_user', ApmUser.APM_WRITE_USER],
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be more clear to have separate functions: createApmReadUser, createApmReadWriteUser.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make it more declarative. I need to add another user, one that is permitted to index annotations.

],
});

await security.user.create(ApmUser.APM_WRITE_USER, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it could be confusing with identical names for the user and role?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't think so. Do you see a scenario in our test where they could be confused?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, probably fine 👍

elasticsearch: {
cluster: [],
indices: [
{ names: ['observability-annotations'], privileges: ['read', 'view_index_metadata'] },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't the plan to make this part of the apm_user?

Copy link
Copy Markdown
Contributor Author

@dgieselaar dgieselaar Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but didn't want to block on the ES PR. If the ES PR gets merged first, I will update this before merging.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dgieselaar dgieselaar requested a review from a team June 29, 2020 11:34
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dgieselaar dgieselaar merged commit dbdc3cd into elastic:master Jun 29, 2020
@dgieselaar dgieselaar deleted the tests-as-apm-user branch June 29, 2020 14:17
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Jun 29, 2020
Bamieh pushed a commit to Bamieh/kibana that referenced this pull request Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:skip Skip the PR/issue when compiling release notes Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v7.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants