remove deprecated header support (#112505)

This commit is contained in:
Mikhail Shustov 2021-09-18 16:53:00 +03:00 committed by GitHub
parent 7040b47840
commit 4a1a060f25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 55 deletions

View file

@ -245,32 +245,6 @@ describe('Fetch', () => {
});
});
// Deprecated header used by legacy platform pre-7.7. Remove in 8.x.
it('should not allow overwriting of kbn-system-api when asSystemRequest: true', async () => {
fetchMock.get('*', {});
await expect(
fetchInstance.fetch('/my/path', {
headers: { myHeader: 'foo', 'kbn-system-api': 'ANOTHER!' },
asSystemRequest: true,
})
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Invalid fetch headers, headers beginning with \\"kbn-\\" are not allowed: [kbn-system-api]"`
);
});
// Deprecated header used by legacy platform pre-7.7. Remove in 8.x.
it('should not allow overwriting of kbn-system-api when asSystemRequest: false', async () => {
fetchMock.get('*', {});
await expect(
fetchInstance.fetch('/my/path', {
headers: { myHeader: 'foo', 'kbn-system-api': 'ANOTHER!' },
asSystemRequest: false,
})
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Invalid fetch headers, headers beginning with \\"kbn-\\" are not allowed: [kbn-system-api]"`
);
});
it('should return response', async () => {
fetchMock.get('*', { foo: 'bar' });
const json = await fetchInstance.fetch('/my/path');

View file

@ -141,31 +141,6 @@ describe('KibanaRequest', () => {
const kibanaRequest = KibanaRequest.from(request);
expect(kibanaRequest.isSystemRequest).toBe(false);
});
// Remove support for kbn-system-api header in 8.x. Only used by legacy platform.
it('is false when no kbn-system-api header is set', () => {
const request = httpServerMock.createRawRequest({
headers: { custom: 'one' },
});
const kibanaRequest = KibanaRequest.from(request);
expect(kibanaRequest.isSystemRequest).toBe(false);
});
it('is true when kbn-system-api header is set to true', () => {
const request = httpServerMock.createRawRequest({
headers: { custom: 'one', 'kbn-system-api': 'true' },
});
const kibanaRequest = KibanaRequest.from(request);
expect(kibanaRequest.isSystemRequest).toBe(true);
});
it('is false when kbn-system-api header is set to false', () => {
const request = httpServerMock.createRawRequest({
headers: { custom: 'one', 'kbn-system-api': 'false' },
});
const kibanaRequest = KibanaRequest.from(request);
expect(kibanaRequest.isSystemRequest).toBe(false);
});
});
describe('route.options.authRequired property', () => {

View file

@ -202,10 +202,7 @@ export class KibanaRequest<
this.url = request.url;
this.headers = deepFreeze({ ...request.headers });
this.isSystemRequest =
request.headers['kbn-system-request'] === 'true' ||
// Remove support for `kbn-system-api` in 8.x. Used only by legacy platform.
request.headers['kbn-system-api'] === 'true';
this.isSystemRequest = request.headers['kbn-system-request'] === 'true';
// prevent Symbol exposure via Object.getOwnPropertySymbols()
Object.defineProperty(this, requestSymbol, {