Skip to content

Commit

Permalink
Uncomments code, reverts test assertion changes, use global header co…
Browse files Browse the repository at this point in the history
…nst over hard coded string
  • Loading branch information
TinaHeiligers committed Sep 11, 2024
1 parent 9297290 commit 555870e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
7 changes: 4 additions & 3 deletions test/analytics/services/kibana_ebt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
};
Expand All @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions test/analytics/tests/analytics_from_the_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions test/api_integration/apis/console/proxy_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/api_integration/apis/kql_telemetry/kql_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand All @@ -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);
});
});

Expand Down

0 comments on commit 555870e

Please sign in to comment.