From 555870e218c72fe9d21ca726e4373716cea246da Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Wed, 11 Sep 2024 10:41:09 -0700 Subject: [PATCH] Uncomments code, reverts test assertion changes, use global header const over hard coded string --- test/analytics/services/kibana_ebt.ts | 7 ++++--- test/analytics/tests/analytics_from_the_server.ts | 5 +++-- test/api_integration/apis/console/proxy_route.ts | 8 ++++---- test/api_integration/apis/kql_telemetry/kql_telemetry.ts | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/test/analytics/services/kibana_ebt.ts b/test/analytics/services/kibana_ebt.ts index 5f1f0152ca715..f2b635dcbdbbe 100644 --- a/test/analytics/services/kibana_ebt.ts +++ b/test/analytics/services/kibana_ebt.ts @@ -9,6 +9,7 @@ import '@kbn/analytics-ftr-helpers-plugin/public/types'; import type { EBTHelpersContract } from '@kbn/analytics-ftr-helpers-plugin/common/types'; +import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common'; import type { FtrProviderContext } from '../../functional/ftr_provider_context'; export function KibanaEBTServerProvider({ getService }: FtrProviderContext): EBTHelpersContract { @@ -18,7 +19,7 @@ export function KibanaEBTServerProvider({ getService }: FtrProviderContext): EBT await supertest .post(`/internal/analytics_ftr_helpers/opt_in`) .set('kbn-xsrf', 'xxx') - .set('x-elastic-internal-origin', 'kibana') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query({ consent: optIn }) .expect(200); }; @@ -39,7 +40,7 @@ export function KibanaEBTServerProvider({ getService }: FtrProviderContext): EBT fromTimestamp, }) .set('kbn-xsrf', 'xxx') - .set('x-elastic-internal-origin', 'kibana') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .expect(200); return resp.body; @@ -50,7 +51,7 @@ export function KibanaEBTServerProvider({ getService }: FtrProviderContext): EBT .get(`/internal/analytics_ftr_helpers/count_events`) .query({ eventTypes: JSON.stringify(eventTypes), withTimeoutMs, fromTimestamp }) .set('kbn-xsrf', 'xxx') - .set('x-elastic-internal-origin', 'kibana') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .expect(200); return resp.body.count; diff --git a/test/analytics/tests/analytics_from_the_server.ts b/test/analytics/tests/analytics_from_the_server.ts index 6e7158b68b988..af15d083419a3 100644 --- a/test/analytics/tests/analytics_from_the_server.ts +++ b/test/analytics/tests/analytics_from_the_server.ts @@ -10,6 +10,7 @@ import expect from '@kbn/expect'; import type { Event, TelemetryCounter } from '@kbn/core/server'; import type { Action } from '@kbn/analytics-plugin-a-plugin/server/custom_shipper'; +import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common'; import type { FtrProviderContext } from '../services'; export default function ({ getService }: FtrProviderContext) { @@ -23,7 +24,7 @@ export default function ({ getService }: FtrProviderContext) { .get(`/internal/analytics_plugin_a/stats`) .query({ takeNumberOfCounters, eventType: 'test-plugin-lifecycle' }) .set('kbn-xsrf', 'xxx') - .set('x-elastic-internal-origin', 'kibana') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .expect(200); return resp.body; @@ -33,7 +34,7 @@ export default function ({ getService }: FtrProviderContext) { const resp = await supertest .get(`/internal/analytics_plugin_a/actions`) .set('kbn-xsrf', 'xxx') - .set('x-elastic-internal-origin', 'kibana') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .expect(200); return resp.body; diff --git a/test/api_integration/apis/console/proxy_route.ts b/test/api_integration/apis/console/proxy_route.ts index b09312863710f..3cc40f318d97b 100644 --- a/test/api_integration/apis/console/proxy_route.ts +++ b/test/api_integration/apis/console/proxy_route.ts @@ -30,16 +30,16 @@ export default function ({ getService }: FtrProviderContext) { }); it('does not forward x-elastic-product-origin', async () => { - // If we pass the header and we still get the warning back, we assume that the header was not forwarded. return await supertest .post('/api/console/proxy?method=GET&path=/.kibana/_settings') .set('kbn-xsrf', 'true') .set('x-elastic-product-origin', 'kibana') .then((response) => { expect(response.header).to.have.property('connection', 'close'); - // const { warning } = response.header as { warning: string }; - // expect(warning.startsWith('299')).to.be(true); - // expect(warning.includes('system indices')).to.be(true); + expect(response.header).to.have.property('warning'); + const { warning } = response.header as { warning: string }; + expect(warning.startsWith('299')).to.be(true); + expect(warning.includes('system indices')).to.be(true); }); }); }); diff --git a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts index c7a789128fafa..7d3224c0306a5 100644 --- a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts +++ b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts @@ -50,7 +50,7 @@ export default function ({ getService }: FtrProviderContext) { }) .then((response) => { const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry'); - expect(kqlTelemetryDoc.optInCount).to.be.greaterThan(0); + expect(kqlTelemetryDoc.optInCount).to.be(1); }); }); @@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) { }) .then((response) => { const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry'); - expect(kqlTelemetryDoc.optOutCount).to.be.greaterThan(0); + expect(kqlTelemetryDoc.optOutCount).to.be(1); }); });