From 5d9f89e25cc9647a0e3cd90be7d070a6dcc67aa6 Mon Sep 17 00:00:00 2001 From: Rashmi Kulkarni Date: Wed, 26 Aug 2020 17:21:16 -0700 Subject: [PATCH] using test_user with minimum privileges for canvas functional ui tests (#75917) * incorporating test_user wth specific roles for the canvas functional ui tests * additional checks - removed comments * changes to incorporate code comments * lint check * incorporate code reviews Co-authored-by: Elastic Machine --- .../functional/apps/canvas/custom_elements.ts | 6 +----- x-pack/test/functional/apps/canvas/expression.ts | 6 +----- x-pack/test/functional/apps/canvas/index.js | 15 ++++++++++++++- x-pack/test/functional/apps/canvas/smoke_test.js | 7 +------ x-pack/test/functional/config.js | 11 +++++++++++ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/x-pack/test/functional/apps/canvas/custom_elements.ts b/x-pack/test/functional/apps/canvas/custom_elements.ts index 33db56751285e..1a05560aaf931 100644 --- a/x-pack/test/functional/apps/canvas/custom_elements.ts +++ b/x-pack/test/functional/apps/canvas/custom_elements.ts @@ -12,24 +12,20 @@ export default function canvasCustomElementTest({ getService, getPageObjects, }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); const retry = getService('retry'); const PageObjects = getPageObjects(['canvas', 'common']); const find = getService('find'); + const esArchiver = getService('esArchiver'); describe('custom elements', function () { this.tags('skipFirefox'); before(async () => { - // init data - await esArchiver.loadIfNeeded('logstash_functional'); await esArchiver.load('canvas/default'); - // open canvas home await PageObjects.common.navigateToApp('canvas'); - // load test workpad await PageObjects.common.navigateToApp('canvas', { hash: '/workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31/page/1', diff --git a/x-pack/test/functional/apps/canvas/expression.ts b/x-pack/test/functional/apps/canvas/expression.ts index c184dca8366be..548321243d4fb 100644 --- a/x-pack/test/functional/apps/canvas/expression.ts +++ b/x-pack/test/functional/apps/canvas/expression.ts @@ -9,22 +9,18 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function canvasExpressionTest({ getService, getPageObjects }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); - // const browser = getService('browser'); const retry = getService('retry'); const PageObjects = getPageObjects(['canvas', 'common']); const find = getService('find'); + const esArchiver = getService('esArchiver'); describe('expression editor', function () { // there is an issue with FF not properly clicking on workpad elements this.tags('skipFirefox'); before(async () => { - // init data - await esArchiver.loadIfNeeded('logstash_functional'); await esArchiver.load('canvas/default'); - // load test workpad await PageObjects.common.navigateToApp('canvas', { hash: '/workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31/page/1', diff --git a/x-pack/test/functional/apps/canvas/index.js b/x-pack/test/functional/apps/canvas/index.js index d6ded9b20b1ad..7ee48beaabb2a 100644 --- a/x-pack/test/functional/apps/canvas/index.js +++ b/x-pack/test/functional/apps/canvas/index.js @@ -4,8 +4,21 @@ * you may not use this file except in compliance with the Elastic License. */ -export default function canvasApp({ loadTestFile }) { +export default function canvasApp({ loadTestFile, getService }) { + const security = getService('security'); + const esArchiver = getService('esArchiver'); + describe('Canvas app', function canvasAppTestSuite() { + before(async () => { + // init data + await security.testUser.setRoles(['test_logstash_reader', 'global_canvas_all']); + await esArchiver.loadIfNeeded('logstash_functional'); + }); + + after(async () => { + await security.testUser.restoreDefaults(); + }); + this.tags('ciGroup2'); // CI requires tags ヽ(゜Q。)ノ? loadTestFile(require.resolve('./smoke_test')); loadTestFile(require.resolve('./expression')); diff --git a/x-pack/test/functional/apps/canvas/smoke_test.js b/x-pack/test/functional/apps/canvas/smoke_test.js index 056713a5dacfa..596d34e7c1df5 100644 --- a/x-pack/test/functional/apps/canvas/smoke_test.js +++ b/x-pack/test/functional/apps/canvas/smoke_test.js @@ -8,11 +8,11 @@ import expect from '@kbn/expect'; import { parse } from 'url'; export default function canvasSmokeTest({ getService, getPageObjects }) { - const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); const retry = getService('retry'); const PageObjects = getPageObjects(['common']); + const esArchiver = getService('esArchiver'); describe('smoke test', function () { this.tags('includeFirefox'); @@ -20,12 +20,7 @@ export default function canvasSmokeTest({ getService, getPageObjects }) { const testWorkpadId = 'workpad-1705f884-6224-47de-ba49-ca224fe6ec31'; before(async () => { - // init data - await esArchiver.loadIfNeeded('logstash_functional'); await esArchiver.load('canvas/default'); - - // load canvas - // see also navigateToUrl(app, hash) await PageObjects.common.navigateToApp('canvas'); }); diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 020c5c977bd1b..e366401da534d 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -221,6 +221,17 @@ export default async function ({ readConfigFile }) { kibana: [], }, + global_canvas_all: { + kibana: [ + { + feature: { + canvas: ['all'], + }, + spaces: ['*'], + }, + ], + }, + global_discover_read: { kibana: [ {