Skip to content
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

Add test service to manage observability test users #110849

Merged

Conversation

weltenwort
Copy link
Member

@weltenwort weltenwort commented Sep 1, 2021

📝 Summary

This adds a functional test service to create, assign, restore and delete security roles for testing the observability app.

closes #110627

🎨 New APIs

The observability test service is available in function tests via

const observability = getService('observability');

observability.user.defineBasicObservabilityRole(observabilityFeatures)

Generates a role definition for use with setTestUserRole(roleDefinition) with commonly used combinations of index and feature privileges in test for the observability app.

observability.user.setTestUserRole(roleDefinition)

Creates an observability test role in the system using the given definition and assigns it to the global test user. It also performs a page refresh to apply the new permissions, but doesn't require a re-login. Suitable for use in a test's before clause. Must be reverted and deleted again after use, for example in an after clause.

observability.user.restoreDefaultTestUserRole()

Deletes the observability test role from the system and restores the test user's roles to the default. It also performs a page refresh to apply the new permissions, but doesn't require a re-login. Suitable for use in a test's after clause.

💡 Example usage

export default function ({ getService }: FtrProviderContext) {
  const observability = getService('observability');

  describe('my test suite that requires logs ui permissions', () => {
    before(async () => {
      await observability.users.setTestUserRole(
        // this grants access to the Kibana feature and the `logs-*,filebeat-*` indices
        observability.users.defineBasicObservabilityRole({
          logs: ['all'],
        })
      );
    });

    after(async () => {
      await observability.users.restoreDefaultTestUserRole();
    });

    // tests go here
  });
}

🕵️‍♀️ Review notes

  • This also converts the observability feature control tests to use the new service.
  • To only run the observability functional tests I apply the following patch:
only-obervability-tests
diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js
index 226cebb9afb..9117cfe1881 100644
--- a/x-pack/test/functional/config.js
+++ b/x-pack/test/functional/config.js
@@ -23,46 +23,46 @@ export default async function ({ readConfigFile }) {
   return {
     // list paths to the files that contain your plugins tests
     testFiles: [
-      resolve(__dirname, './apps/advanced_settings'),
-      resolve(__dirname, './apps/canvas'),
-      resolve(__dirname, './apps/graph'),
-      resolve(__dirname, './apps/monitoring'),
-      resolve(__dirname, './apps/watcher'),
-      resolve(__dirname, './apps/dashboard'),
-      resolve(__dirname, './apps/discover'),
-      resolve(__dirname, './apps/security'),
-      resolve(__dirname, './apps/spaces'),
-      resolve(__dirname, './apps/lens'),
-      resolve(__dirname, './apps/logstash'),
-      resolve(__dirname, './apps/grok_debugger'),
-      resolve(__dirname, './apps/infra'),
-      resolve(__dirname, './apps/ml'),
-      resolve(__dirname, './apps/rollup_job'),
-      resolve(__dirname, './apps/maps'),
-      resolve(__dirname, './apps/status_page'),
-      resolve(__dirname, './apps/timelion'),
-      resolve(__dirname, './apps/upgrade_assistant'),
-      resolve(__dirname, './apps/visualize'),
-      resolve(__dirname, './apps/uptime'),
-      resolve(__dirname, './apps/saved_objects_management'),
-      resolve(__dirname, './apps/dev_tools'),
-      resolve(__dirname, './apps/apm'),
-      resolve(__dirname, './apps/api_keys'),
-      resolve(__dirname, './apps/index_patterns'),
-      resolve(__dirname, './apps/index_management'),
-      resolve(__dirname, './apps/index_lifecycle_management'),
-      resolve(__dirname, './apps/ingest_pipelines'),
-      resolve(__dirname, './apps/snapshot_restore'),
-      resolve(__dirname, './apps/cross_cluster_replication'),
-      resolve(__dirname, './apps/remote_clusters'),
-      resolve(__dirname, './apps/transform'),
-      resolve(__dirname, './apps/reporting_management'),
-      resolve(__dirname, './apps/management'),
-      resolve(__dirname, './apps/reporting'),
+      // resolve(__dirname, './apps/advanced_settings'),
+      // resolve(__dirname, './apps/canvas'),
+      // resolve(__dirname, './apps/graph'),
+      // resolve(__dirname, './apps/monitoring'),
+      // resolve(__dirname, './apps/watcher'),
+      // resolve(__dirname, './apps/dashboard'),
+      // resolve(__dirname, './apps/discover'),
+      // resolve(__dirname, './apps/security'),
+      // resolve(__dirname, './apps/spaces'),
+      // resolve(__dirname, './apps/lens'),
+      // resolve(__dirname, './apps/logstash'),
+      // resolve(__dirname, './apps/grok_debugger'),
+      // resolve(__dirname, './apps/infra'),
+      // resolve(__dirname, './apps/ml'),
+      // resolve(__dirname, './apps/rollup_job'),
+      // resolve(__dirname, './apps/maps'),
+      // resolve(__dirname, './apps/status_page'),
+      // resolve(__dirname, './apps/timelion'),
+      // resolve(__dirname, './apps/upgrade_assistant'),
+      // resolve(__dirname, './apps/visualize'),
+      // resolve(__dirname, './apps/uptime'),
+      // resolve(__dirname, './apps/saved_objects_management'),
+      // resolve(__dirname, './apps/dev_tools'),
+      // resolve(__dirname, './apps/apm'),
+      // resolve(__dirname, './apps/api_keys'),
+      // resolve(__dirname, './apps/index_patterns'),
+      // resolve(__dirname, './apps/index_management'),
+      // resolve(__dirname, './apps/index_lifecycle_management'),
+      // resolve(__dirname, './apps/ingest_pipelines'),
+      // resolve(__dirname, './apps/snapshot_restore'),
+      // resolve(__dirname, './apps/cross_cluster_replication'),
+      // resolve(__dirname, './apps/remote_clusters'),
+      // resolve(__dirname, './apps/transform'),
+      // resolve(__dirname, './apps/reporting_management'),
+      // resolve(__dirname, './apps/management'),
+      // resolve(__dirname, './apps/reporting'),
       resolve(__dirname, './apps/observability'),
 
       // This license_management file must be last because it is destructive.
-      resolve(__dirname, './apps/license_management'),
+      // resolve(__dirname, './apps/license_management'),
     ],
 
     services,

@weltenwort weltenwort self-assigned this Sep 1, 2021
@weltenwort weltenwort added Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services test v7.15.0 v7.16.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed Theme: rac label obsolete labels Sep 1, 2021
@weltenwort weltenwort force-pushed the rac-add-observability-test-user-service branch from 4cd1cb1 to 54f5f36 Compare September 2, 2021 19:12
@brianseeders
Copy link
Contributor

@elasticmachine merge upstream

@weltenwort weltenwort marked this pull request as ready for review September 3, 2021 15:38
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@weltenwort weltenwort requested a review from a team September 3, 2021 15:38
@Kerry350 Kerry350 self-requested a review September 6, 2021 07:52
Copy link
Contributor

@Kerry350 Kerry350 left a comment

Choose a reason for hiding this comment

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

LGTM, this is much cleaner / nicer 🎉

@weltenwort
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

cc @weltenwort

@weltenwort weltenwort merged commit e145ccd into elastic:master Sep 6, 2021
@weltenwort weltenwort deleted the rac-add-observability-test-user-service branch September 6, 2021 14:18
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 6, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 6, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.15
7.x

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 6, 2021
kibanamachine added a commit that referenced this pull request Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services test Theme: rac label obsolete v7.15.0 v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAC] [Observability] Set up functional test service to provide preconfigured users
5 participants