From 532a9daab2daa37ba70193747f940ef8abce67ce Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Tue, 24 Nov 2020 16:03:31 +0100 Subject: [PATCH] Fix advanced settings API integration tests on cloud (#84110) (#84208) This PR fixes the advanced settings feature controls API integration tests for cloud and moves some deployment helper methods to a separate service. --- test/common/services/deployment.ts | 78 +++++++++++++++++++ test/common/services/index.ts | 2 + test/examples/state_sync/todo_app.ts | 3 +- .../apps/dashboard/url_field_formatter.ts | 3 +- .../functional/apps/discover/_shared_links.js | 3 +- test/functional/apps/home/_newsfeed.ts | 5 +- .../apps/management/_scripted_fields.js | 9 ++- .../functional/apps/visualize/_chart_types.ts | 5 +- test/functional/apps/visualize/index.ts | 6 +- test/functional/page_objects/common_page.ts | 48 ------------ test/functional/page_objects/home_page.ts | 3 +- .../test_suites/core_plugins/applications.ts | 3 +- .../test_suites/core_plugins/rendering.ts | 6 +- .../test_suites/core_plugins/top_nav.ts | 7 +- .../advanced_settings/feature_controls.ts | 44 +++++++---- .../monitoring/setup/metricbeat_migration.js | 3 +- .../functional/page_objects/security_page.ts | 3 +- .../functional/page_objects/status_page.ts | 6 +- .../functional/services/monitoring/no_data.js | 6 +- .../login_selector/auth_provider_hint.ts | 3 +- .../login_selector/basic_functionality.ts | 3 +- .../tests/oidc/url_capture.ts | 5 +- .../tests/saml/url_capture.ts | 5 +- 23 files changed, 159 insertions(+), 100 deletions(-) create mode 100644 test/common/services/deployment.ts diff --git a/test/common/services/deployment.ts b/test/common/services/deployment.ts new file mode 100644 index 0000000000000..88389b57dd1db --- /dev/null +++ b/test/common/services/deployment.ts @@ -0,0 +1,78 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { get } from 'lodash'; +import fetch from 'node-fetch'; +// @ts-ignore not TS yet +import getUrl from '../../../src/test_utils/get_url'; + +import { FtrProviderContext } from '../ftr_provider_context'; + +export function DeploymentProvider({ getService }: FtrProviderContext) { + const config = getService('config'); + + return { + /** + * Returns Kibana host URL + */ + getHostPort() { + return getUrl.baseUrl(config.get('servers.kibana')); + }, + + /** + * Returns ES host URL + */ + getEsHostPort() { + return getUrl.baseUrl(config.get('servers.elasticsearch')); + }, + + /** + * Helper to detect an OSS licensed Kibana + * Useful for functional testing in cloud environment + */ + async isOss() { + const baseUrl = this.getEsHostPort(); + const username = config.get('servers.elasticsearch.username'); + const password = config.get('servers.elasticsearch.password'); + const response = await fetch(baseUrl + '/_xpack', { + method: 'get', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Basic ' + Buffer.from(username + ':' + password).toString('base64'), + }, + }); + return response.status !== 200; + }, + + async isCloud(): Promise { + const baseUrl = this.getHostPort(); + const username = config.get('servers.kibana.username'); + const password = config.get('servers.kibana.password'); + const response = await fetch(baseUrl + '/api/stats?extended', { + method: 'get', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Basic ' + Buffer.from(username + ':' + password).toString('base64'), + }, + }); + const data = await response.json(); + return get(data, 'usage.cloud.is_cloud_enabled', false); + }, + }; +} diff --git a/test/common/services/index.ts b/test/common/services/index.ts index 0a714e9875c37..b9fa99995ce9d 100644 --- a/test/common/services/index.ts +++ b/test/common/services/index.ts @@ -17,6 +17,7 @@ * under the License. */ +import { DeploymentProvider } from './deployment'; import { LegacyEsProvider } from './legacy_es'; import { ElasticsearchProvider } from './elasticsearch'; import { EsArchiverProvider } from './es_archiver'; @@ -26,6 +27,7 @@ import { RandomnessProvider } from './randomness'; import { SecurityServiceProvider } from './security'; export const services = { + deployment: DeploymentProvider, legacyEs: LegacyEsProvider, es: ElasticsearchProvider, esArchiver: EsArchiverProvider, diff --git a/test/examples/state_sync/todo_app.ts b/test/examples/state_sync/todo_app.ts index 1ac5376b9ed8d..d29a533aa1af1 100644 --- a/test/examples/state_sync/todo_app.ts +++ b/test/examples/state_sync/todo_app.ts @@ -29,6 +29,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide const browser = getService('browser'); const PageObjects = getPageObjects(['common']); const log = getService('log'); + const deployment = getService('deployment'); describe('TODO app', () => { describe("TODO app with browser history (platform's ScopedHistory)", async () => { @@ -36,7 +37,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide let base: string; before(async () => { - base = await PageObjects.common.getHostPort(); + base = await deployment.getHostPort(); await PageObjects.common.navigateToApp(appId, { insertTimestamp: false }); }); diff --git a/test/functional/apps/dashboard/url_field_formatter.ts b/test/functional/apps/dashboard/url_field_formatter.ts index a18ad740681bf..62cc1a7e95754 100644 --- a/test/functional/apps/dashboard/url_field_formatter.ts +++ b/test/functional/apps/dashboard/url_field_formatter.ts @@ -34,6 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const browser = getService('browser'); const fieldName = 'clientip'; + const deployment = getService('deployment'); const clickFieldAndCheckUrl = async (fieldLink: WebElementWrapper) => { const fieldValue = await fieldLink.getVisibleText(); @@ -42,7 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(windowHandlers.length).to.equal(2); await browser.switchToWindow(windowHandlers[1]); const currentUrl = await browser.getCurrentUrl(); - const fieldUrl = common.getHostPort() + '/app/' + fieldValue; + const fieldUrl = deployment.getHostPort() + '/app/' + fieldValue; expect(currentUrl).to.equal(fieldUrl); }; diff --git a/test/functional/apps/discover/_shared_links.js b/test/functional/apps/discover/_shared_links.js index 56c6485624043..9cd92626f73bf 100644 --- a/test/functional/apps/discover/_shared_links.js +++ b/test/functional/apps/discover/_shared_links.js @@ -27,13 +27,14 @@ export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'discover', 'share', 'timePicker']); const browser = getService('browser'); const toasts = getService('toasts'); + const deployment = getService('deployment'); // FLAKY: https://github.com/elastic/kibana/issues/80104 describe.skip('shared links', function describeIndexTests() { let baseUrl; async function setup({ storeStateInSessionStorage }) { - baseUrl = PageObjects.common.getHostPort(); + baseUrl = deployment.getHostPort(); log.debug('baseUrl = ' + baseUrl); // browsers don't show the ':port' if it's 80 or 443 so we have to // remove that part so we can get a match in the tests. diff --git a/test/functional/apps/home/_newsfeed.ts b/test/functional/apps/home/_newsfeed.ts index aabd243e48f21..4568ba2b47d80 100644 --- a/test/functional/apps/home/_newsfeed.ts +++ b/test/functional/apps/home/_newsfeed.ts @@ -22,7 +22,8 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const globalNav = getService('globalNav'); - const PageObjects = getPageObjects(['common', 'newsfeed']); + const deployment = getService('deployment'); + const PageObjects = getPageObjects(['newsfeed']); describe('Newsfeed', () => { before(async () => { @@ -48,7 +49,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('shows all news from newsfeed', async () => { const objects = await PageObjects.newsfeed.getNewsfeedList(); - if (await PageObjects.common.isOss()) { + if (await deployment.isOss()) { expect(objects).to.eql([ '21 June 2019\nYou are functionally testing the newsfeed widget with fixtures!\nSee test/common/fixtures/plugins/newsfeed/newsfeed_simulation\nGeneric feed-viewer could go here', '21 June 2019\nStaging too!\nHello world\nGeneric feed-viewer could go here', diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 5ca01f239e762..a2cc976f23127 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -44,6 +44,7 @@ export default function ({ getService, getPageObjects }) { const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); + const deployment = getService('deployment'); const PageObjects = getPageObjects([ 'common', 'header', @@ -202,7 +203,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName); await PageObjects.header.waitUntilLoadingHasFinished(); - if (await PageObjects.common.isOss()) { + if (await deployment.isOss()) { // OSS renders a vertical bar chart and we check the data in the Inspect panel const expectedChartValues = [ ['14', '31'], @@ -318,7 +319,7 @@ export default function ({ getService, getPageObjects }) { it('should visualize scripted field in vertical bar chart', async function () { await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); await PageObjects.header.waitUntilLoadingHasFinished(); - if (await PageObjects.common.isOss()) { + if (await deployment.isOss()) { // OSS renders a vertical bar chart and we check the data in the Inspect panel await inspector.open(); await inspector.expectTableData([ @@ -414,7 +415,7 @@ export default function ({ getService, getPageObjects }) { it('should visualize scripted field in vertical bar chart', async function () { await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); await PageObjects.header.waitUntilLoadingHasFinished(); - if (await PageObjects.common.isOss()) { + if (await deployment.isOss()) { // OSS renders a vertical bar chart and we check the data in the Inspect panel await inspector.open(); await inspector.expectTableData([ @@ -514,7 +515,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2); await PageObjects.header.waitUntilLoadingHasFinished(); - if (await PageObjects.common.isOss()) { + if (await deployment.isOss()) { // OSS renders a vertical bar chart and we check the data in the Inspect panel await inspector.open(); await inspector.setTablePageSize(50); diff --git a/test/functional/apps/visualize/_chart_types.ts b/test/functional/apps/visualize/_chart_types.ts index d3949b36591ad..b404b74039be9 100644 --- a/test/functional/apps/visualize/_chart_types.ts +++ b/test/functional/apps/visualize/_chart_types.ts @@ -22,14 +22,15 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { + const deployment = getService('deployment'); const log = getService('log'); - const PageObjects = getPageObjects(['common', 'visualize']); + const PageObjects = getPageObjects(['visualize']); let isOss = true; describe('chart types', function () { before(async function () { log.debug('navigateToApp visualize'); - isOss = await PageObjects.common.isOss(); + isOss = await deployment.isOss(); await PageObjects.visualize.navigateToNewVisualization(); }); diff --git a/test/functional/apps/visualize/index.ts b/test/functional/apps/visualize/index.ts index a30517519820e..de73b2deabbd9 100644 --- a/test/functional/apps/visualize/index.ts +++ b/test/functional/apps/visualize/index.ts @@ -20,12 +20,12 @@ import { FtrProviderContext } from '../../ftr_provider_context.d'; import { UI_SETTINGS } from '../../../../src/plugins/data/common'; -export default function ({ getService, getPageObjects, loadTestFile }: FtrProviderContext) { +export default function ({ getService, loadTestFile }: FtrProviderContext) { const browser = getService('browser'); const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common']); + const deployment = getService('deployment'); let isOss = true; describe('visualize app', () => { @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid defaultIndex: 'logstash-*', [UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN]: '0,0.[000]b', }); - isOss = await PageObjects.common.isOss(); + isOss = await deployment.isOss(); }); describe('', function () { diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 43ada726c2915..31df98bb23c1e 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -19,7 +19,6 @@ import { delay } from 'bluebird'; import expect from '@kbn/expect'; -import { get } from 'lodash'; // @ts-ignore import fetch from 'node-fetch'; import { FtrProviderContext } from '../ftr_provider_context'; @@ -48,20 +47,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo } class CommonPage { - /** - * Returns Kibana host URL - */ - public getHostPort() { - return getUrl.baseUrl(config.get('servers.kibana')); - } - - /** - * Returns ES host URL - */ - public getEsHostPort() { - return getUrl.baseUrl(config.get('servers.elasticsearch')); - } - /** * Logins to Kibana as default user and navigates to provided app * @param appUrl Kibana URL @@ -449,39 +434,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo return await body.getVisibleText(); } - /** - * Helper to detect an OSS licensed Kibana - * Useful for functional testing in cloud environment - */ - async isOss() { - const baseUrl = this.getEsHostPort(); - const username = config.get('servers.elasticsearch.username'); - const password = config.get('servers.elasticsearch.password'); - const response = await fetch(baseUrl + '/_xpack', { - method: 'get', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Basic ' + Buffer.from(username + ':' + password).toString('base64'), - }, - }); - return response.status !== 200; - } - - async isCloud(): Promise { - const baseUrl = this.getHostPort(); - const username = config.get('servers.kibana.username'); - const password = config.get('servers.kibana.password'); - const response = await fetch(baseUrl + '/api/stats?extended', { - method: 'get', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Basic ' + Buffer.from(username + ':' + password).toString('base64'), - }, - }); - const data = await response.json(); - return get(data, 'usage.cloud.is_cloud_enabled', false); - } - async waitForSaveModalToClose() { log.debug('Waiting for save modal to close'); await retry.try(async () => { diff --git a/test/functional/page_objects/home_page.ts b/test/functional/page_objects/home_page.ts index c12c633926c1c..7f1db636de32d 100644 --- a/test/functional/page_objects/home_page.ts +++ b/test/functional/page_objects/home_page.ts @@ -23,6 +23,7 @@ export function HomePageProvider({ getService, getPageObjects }: FtrProviderCont const testSubjects = getService('testSubjects'); const retry = getService('retry'); const find = getService('find'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['common']); let isOss = true; @@ -82,7 +83,7 @@ export function HomePageProvider({ getService, getPageObjects }: FtrProviderCont async launchSampleDashboard(id: string) { await this.launchSampleDataSet(id); - isOss = await PageObjects.common.isOss(); + isOss = await deployment.isOss(); if (!isOss) { await find.clickByLinkText('Dashboard'); } diff --git a/test/plugin_functional/test_suites/core_plugins/applications.ts b/test/plugin_functional/test_suites/core_plugins/applications.ts index 4c72c091a2bee..d18fa31b0694b 100644 --- a/test/plugin_functional/test_suites/core_plugins/applications.ts +++ b/test/plugin_functional/test_suites/core_plugins/applications.ts @@ -28,6 +28,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide const testSubjects = getService('testSubjects'); const find = getService('find'); const retry = getService('retry'); + const deployment = getService('deployment'); const loadingScreenNotShown = async () => expect(await testSubjects.exists('kbnLoadingMessage')).to.be(false); @@ -55,7 +56,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide }; const navigateTo = async (path: string) => - await browser.navigateTo(`${PageObjects.common.getHostPort()}${path}`); + await browser.navigateTo(`${deployment.getHostPort()}${path}`); describe('ui applications', function describeIndexTests() { before(async () => { diff --git a/test/plugin_functional/test_suites/core_plugins/rendering.ts b/test/plugin_functional/test_suites/core_plugins/rendering.ts index 9931a3fabcd8d..781e364996a56 100644 --- a/test/plugin_functional/test_suites/core_plugins/rendering.ts +++ b/test/plugin_functional/test_suites/core_plugins/rendering.ts @@ -32,15 +32,15 @@ declare global { } } -export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) { - const PageObjects = getPageObjects(['common']); +export default function ({ getService }: PluginFunctionalProviderContext) { const appsMenu = getService('appsMenu'); const browser = getService('browser'); + const deployment = getService('deployment'); const find = getService('find'); const testSubjects = getService('testSubjects'); const navigateTo = async (path: string) => - await browser.navigateTo(`${PageObjects.common.getHostPort()}${path}`); + await browser.navigateTo(`${deployment.getHostPort()}${path}`); const navigateToApp = async (title: string) => { await appsMenu.clickLink(title); return browser.execute(() => { diff --git a/test/plugin_functional/test_suites/core_plugins/top_nav.ts b/test/plugin_functional/test_suites/core_plugins/top_nav.ts index c679ac89f2f61..9420ee2911b98 100644 --- a/test/plugin_functional/test_suites/core_plugins/top_nav.ts +++ b/test/plugin_functional/test_suites/core_plugins/top_nav.ts @@ -19,15 +19,14 @@ import expect from '@kbn/expect'; import { PluginFunctionalProviderContext } from '../../services'; -export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) { - const PageObjects = getPageObjects(['common']); - +export default function ({ getService }: PluginFunctionalProviderContext) { const browser = getService('browser'); + const deployment = getService('deployment'); const testSubjects = getService('testSubjects'); describe.skip('top nav', function describeIndexTests() { before(async () => { - const url = `${PageObjects.common.getHostPort()}/app/kbn_tp_top_nav/`; + const url = `${deployment.getHostPort()}/app/kbn_tp_top_nav/`; await browser.get(url); }); diff --git a/x-pack/test/api_integration/apis/management/advanced_settings/feature_controls.ts b/x-pack/test/api_integration/apis/management/advanced_settings/feature_controls.ts index 7a0d0fe2f5d48..d4dae769662d2 100644 --- a/x-pack/test/api_integration/apis/management/advanced_settings/feature_controls.ts +++ b/x-pack/test/api_integration/apis/management/advanced_settings/feature_controls.ts @@ -13,6 +13,27 @@ export default function featureControlsTests({ getService }: FtrProviderContext) const supertest: SuperTest = getService('supertestWithoutAuth'); const security = getService('security'); const spaces = getService('spaces'); + const deployment = getService('deployment'); + + async function expectTelemetryResponse(result: any, expectSuccess: boolean) { + if ((await deployment.isCloud()) === true) { + // Cloud deployments don't allow to change the opt-in status + expectTelemetryCloud400(result); + } else { + if (expectSuccess === true) { + expectResponse(result); + } else { + expect403(result); + } + } + } + + const expectTelemetryCloud400 = (result: any) => { + expect(result.error).to.be(undefined); + expect(result.response).not.to.be(undefined); + expect(result.response).to.have.property('statusCode', 400); + expect(result.response.body.message).to.be('{"error":"Not allowed to change Opt-in Status."}'); + }; const expect403 = (result: any) => { expect(result.error).to.be(undefined); @@ -21,16 +42,9 @@ export default function featureControlsTests({ getService }: FtrProviderContext) }; const expectResponse = (result: any) => { - if (result.response && result.response.statusCode === 400) { - // expect a change of telemetry settings to fail in cloud environment - expect(result.response.body.message).to.be( - '{"error":"Not allowed to change Opt-in Status."}' - ); - } else { - expect(result.error).to.be(undefined); - expect(result.response).not.to.be(undefined); - expect(result.response).to.have.property('statusCode', 200); - } + expect(result.error).to.be(undefined); + expect(result.response).not.to.be(undefined); + expect(result.response).to.have.property('statusCode', 200); }; async function saveAdvancedSetting(username: string, password: string, spaceId?: string) { @@ -83,7 +97,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expectResponse(regularSettingResult); const telemetryResult = await saveTelemetrySetting(username, password); - expectResponse(telemetryResult); + expectTelemetryResponse(telemetryResult, true); } finally { await security.role.delete(roleName); await security.user.delete(username); @@ -115,7 +129,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expect403(regularSettingResult); const telemetryResult = await saveTelemetrySetting(username, password); - expect403(telemetryResult); + expectTelemetryResponse(telemetryResult, false); } finally { await security.role.delete(roleName); await security.user.delete(username); @@ -189,7 +203,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expectResponse(regularSettingResult); const telemetryResult = await saveTelemetrySetting(username, password, space1Id); - expectResponse(telemetryResult); + expectTelemetryResponse(telemetryResult, true); }); it(`user_1 can only save telemetry in space_2`, async () => { @@ -197,7 +211,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expect403(regularSettingResult); const telemetryResult = await saveTelemetrySetting(username, password, space2Id); - expectResponse(telemetryResult); + expectTelemetryResponse(telemetryResult, true); }); it(`user_1 can't save either settings or telemetry in space_3`, async () => { @@ -205,7 +219,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expect403(regularSettingResult); const telemetryResult = await saveTelemetrySetting(username, password, space3Id); - expect403(telemetryResult); + expectTelemetryResponse(telemetryResult, false); }); }); }); diff --git a/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js b/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js index 95bd866d386b1..8a0c4216dfbd4 100644 --- a/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js +++ b/x-pack/test/functional/apps/monitoring/setup/metricbeat_migration.js @@ -8,6 +8,7 @@ import expect from '@kbn/expect'; import { getLifecycleMethods } from '../_get_lifecycle_methods'; export default function ({ getService, getPageObjects }) { + const deployment = getService('deployment'); const setupMode = getService('monitoringSetupMode'); const PageObjects = getPageObjects(['common', 'console']); @@ -39,7 +40,7 @@ export default function ({ getService, getPageObjects }) { }); it('should not show metricbeat migration if cloud', async () => { - const isCloud = await PageObjects.common.isCloud(); + const isCloud = await deployment.isCloud(); expect(await setupMode.doesMetricbeatMigrationTooltipAppear()).to.be(!isCloud); }); diff --git a/x-pack/test/functional/page_objects/security_page.ts b/x-pack/test/functional/page_objects/security_page.ts index ef80ab475cbd6..aca37d3d058e7 100644 --- a/x-pack/test/functional/page_objects/security_page.ts +++ b/x-pack/test/functional/page_objects/security_page.ts @@ -18,6 +18,7 @@ export function SecurityPageProvider({ getService, getPageObjects }: FtrProvider const userMenu = getService('userMenu'); const comboBox = getService('comboBox'); const supertest = getService('supertestWithoutAuth'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['common', 'header', 'error']); interface LoginOptions { @@ -248,7 +249,7 @@ export function SecurityPageProvider({ getService, getPageObjects }: FtrProvider } log.debug('Redirecting to /logout to force the logout'); - const url = PageObjects.common.getHostPort() + '/logout'; + const url = deployment.getHostPort() + '/logout'; await browser.get(url); log.debug('Waiting on the login form to appear'); await waitForLoginPage(); diff --git a/x-pack/test/functional/page_objects/status_page.ts b/x-pack/test/functional/page_objects/status_page.ts index 08726e1320f29..c24b97b2b4feb 100644 --- a/x-pack/test/functional/page_objects/status_page.ts +++ b/x-pack/test/functional/page_objects/status_page.ts @@ -7,12 +7,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../ftr_provider_context'; -export function StatusPagePageProvider({ getService, getPageObjects }: FtrProviderContext) { +export function StatusPagePageProvider({ getService }: FtrProviderContext) { const retry = getService('retry'); const log = getService('log'); const browser = getService('browser'); const find = getService('find'); - const { common } = getPageObjects(['common']); + const deployment = getService('deployment'); class StatusPage { async initTests() { @@ -21,7 +21,7 @@ export function StatusPagePageProvider({ getService, getPageObjects }: FtrProvid async navigateToPage() { return await retry.try(async () => { - const url = common.getHostPort() + '/status'; + const url = deployment.getHostPort() + '/status'; log.info(`StatusPage:navigateToPage(): ${url}`); await browser.get(url); }); diff --git a/x-pack/test/functional/services/monitoring/no_data.js b/x-pack/test/functional/services/monitoring/no_data.js index 9cb383c8c6259..f43f6cb4209c3 100644 --- a/x-pack/test/functional/services/monitoring/no_data.js +++ b/x-pack/test/functional/services/monitoring/no_data.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -export function MonitoringNoDataProvider({ getService, getPageObjects }) { +export function MonitoringNoDataProvider({ getService }) { + const deployment = getService('deployment'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common']); return new (class NoData { async enableMonitoring() { @@ -15,7 +15,7 @@ export function MonitoringNoDataProvider({ getService, getPageObjects }) { // so the UI does not give the user a choice between the two collection // methods. So if we're on cloud, do not try and switch to internal collection // as it's already the default - if (!(await PageObjects.common.isCloud())) { + if (!(await deployment.isCloud())) { await testSubjects.click('useInternalCollection'); } await testSubjects.click('enableCollectionEnabled'); diff --git a/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts b/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts index 8c20862559092..3e41fa9183305 100644 --- a/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts +++ b/x-pack/test/security_functional/tests/login_selector/auth_provider_hint.ts @@ -12,6 +12,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const browser = getService('browser'); const security = getService('security'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['security', 'common']); describe('Authentication provider hint', function () { @@ -39,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await browser.get(`${PageObjects.common.getHostPort()}/login`); + await browser.get(`${deployment.getHostPort()}/login`); await PageObjects.security.loginSelector.verifyLoginSelectorIsVisible(); }); diff --git a/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts b/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts index a08fae4cdb0a1..fe2dca806a6c1 100644 --- a/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts +++ b/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts @@ -13,6 +13,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const browser = getService('browser'); const security = getService('security'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['security', 'common']); describe('Basic functionality', function () { @@ -33,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await browser.get(`${PageObjects.common.getHostPort()}/login`); + await browser.get(`${deployment.getHostPort()}/login`); await PageObjects.security.loginSelector.verifyLoginSelectorIsVisible(); }); diff --git a/x-pack/test/security_functional/tests/oidc/url_capture.ts b/x-pack/test/security_functional/tests/oidc/url_capture.ts index bb4917f18fc1c..a1afcd1e76020 100644 --- a/x-pack/test/security_functional/tests/oidc/url_capture.ts +++ b/x-pack/test/security_functional/tests/oidc/url_capture.ts @@ -12,6 +12,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const find = getService('find'); const browser = getService('browser'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['common']); describe('URL capture', function () { @@ -31,13 +32,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await browser.get(PageObjects.common.getHostPort() + '/logout'); + await browser.get(deployment.getHostPort() + '/logout'); await PageObjects.common.waitUntilUrlIncludes('logged_out'); }); it('can login preserving original URL', async () => { await browser.get( - PageObjects.common.getHostPort() + '/app/management/security/users#some=hash-value' + deployment.getHostPort() + '/app/management/security/users#some=hash-value' ); await find.byCssSelector( diff --git a/x-pack/test/security_functional/tests/saml/url_capture.ts b/x-pack/test/security_functional/tests/saml/url_capture.ts index 5d47d80efadcb..cdb0be6942251 100644 --- a/x-pack/test/security_functional/tests/saml/url_capture.ts +++ b/x-pack/test/security_functional/tests/saml/url_capture.ts @@ -12,6 +12,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const find = getService('find'); const browser = getService('browser'); + const deployment = getService('deployment'); const PageObjects = getPageObjects(['common']); describe('URL capture', function () { @@ -31,13 +32,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await browser.get(PageObjects.common.getHostPort() + '/logout'); + await browser.get(deployment.getHostPort() + '/logout'); await PageObjects.common.waitUntilUrlIncludes('logged_out'); }); it('can login preserving original URL', async () => { await browser.get( - PageObjects.common.getHostPort() + '/app/management/security/users#some=hash-value' + deployment.getHostPort() + '/app/management/security/users#some=hash-value' ); await find.byCssSelector(