Skip to content

Commit

Permalink
Merge branch 'master' into docs__add-ingest-proc-desc-e-j
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Sep 7, 2020
2 parents c8ed625 + b65c95a commit 8d8152c
Show file tree
Hide file tree
Showing 39 changed files with 698 additions and 968 deletions.
1 change: 0 additions & 1 deletion src/core/server/legacy/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@

export { ensureValidConfiguration } from './ensure_valid_configuration';
export { LegacyObjectToConfigAdapter } from './legacy_object_to_config_adapter';
export { convertLegacyDeprecationProvider } from './legacy_deprecation_adapters';
106 changes: 0 additions & 106 deletions src/core/server/legacy/config/legacy_deprecation_adapters.test.ts

This file was deleted.

57 changes: 0 additions & 57 deletions src/core/server/legacy/config/legacy_deprecation_adapters.ts

This file was deleted.

44 changes: 2 additions & 42 deletions src/core/server/legacy/legacy_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

jest.mock('../../../legacy/server/kbn_server');
jest.mock('../../../cli/cluster/cluster_manager');
jest.mock('./config/legacy_deprecation_adapters', () => ({
convertLegacyDeprecationProvider: (provider: any) => Promise.resolve(provider),
}));

import {
findLegacyPluginSpecsMock,
logLegacyThirdPartyPluginDeprecationWarningMock,
Expand Down Expand Up @@ -446,46 +444,8 @@ describe('#discoverPlugins()', () => {
expect(findLegacyPluginSpecs).toHaveBeenCalledWith(expect.any(Object), logger, env.packageInfo);
});

it(`register legacy plugin's deprecation providers`, async () => {
findLegacyPluginSpecsMock.mockImplementation(
(settings) =>
Promise.resolve({
pluginSpecs: [
{
getDeprecationsProvider: () => undefined,
},
{
getDeprecationsProvider: () => 'providerA',
},
{
getDeprecationsProvider: () => 'providerB',
},
],
pluginExtendedConfig: settings,
disabledPluginSpecs: [],
uiExports: {},
navLinks: [],
}) as any
);

const legacyService = new LegacyService({
coreId,
env,
logger,
configService: configService as any,
});

await legacyService.discoverPlugins();
expect(configService.addDeprecationProvider).toHaveBeenCalledTimes(2);
expect(configService.addDeprecationProvider).toHaveBeenCalledWith('', 'providerA');
expect(configService.addDeprecationProvider).toHaveBeenCalledWith('', 'providerB');
});

it(`logs deprecations for legacy third party plugins`, async () => {
const pluginSpecs = [
{ getId: () => 'pluginA', getDeprecationsProvider: () => undefined },
{ getId: () => 'pluginB', getDeprecationsProvider: () => undefined },
];
const pluginSpecs = [{ getId: () => 'pluginA' }, { getId: () => 'pluginB' }];
findLegacyPluginSpecsMock.mockImplementation(
(settings) =>
Promise.resolve({
Expand Down
15 changes: 1 addition & 14 deletions src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import { combineLatest, ConnectableObservable, EMPTY, Observable, Subscription }
import { first, map, publishReplay, tap } from 'rxjs/operators';

import { CoreService } from '../../types';
import { Config, ConfigDeprecationProvider } from '../config';
import { Config } from '../config';
import { CoreContext } from '../core_context';
import { CspConfigType, config as cspConfig } from '../csp';
import { DevConfig, DevConfigType, config as devConfig } from '../dev';
import { BasePathProxyServer, HttpConfig, HttpConfigType, config as httpConfig } from '../http';
import { Logger } from '../logging';
import { PathConfigType } from '../path';
import { findLegacyPluginSpecs, logLegacyThirdPartyPluginDeprecationWarning } from './plugins';
import { convertLegacyDeprecationProvider } from './config';
import {
ILegacyInternals,
LegacyServiceSetupDeps,
Expand Down Expand Up @@ -145,18 +144,6 @@ export class LegacyService implements CoreService {
navLinks,
};

const deprecationProviders = await pluginSpecs
.map((spec) => spec.getDeprecationsProvider())
.reduce(async (providers, current) => {
if (current) {
return [...(await providers), await convertLegacyDeprecationProvider(current)];
}
return providers;
}, Promise.resolve([] as ConfigDeprecationProvider[]));
deprecationProviders.forEach((provider) =>
this.coreContext.configService.addDeprecationProvider('', provider)
);

this.legacyRawConfig = pluginExtendedConfig;

// check for unknown uiExport types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const createPluginSpec = ({ id, path }: { id: string; path: string }): LegacyPlu
getId: () => id,
getExpectedKibanaVersion: () => 'kibana',
getConfigPrefix: () => 'plugin.config',
getDeprecationsProvider: () => undefined,
getPack: () => ({
getPath: () => path,
}),
Expand Down
31 changes: 0 additions & 31 deletions src/core/server/legacy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,6 @@ export interface LegacyConfig {
set(config: LegacyVars): void;
}

/**
* Representation of a legacy configuration deprecation factory used for
* legacy plugin deprecations.
*
* @internal
* @deprecated
*/
export interface LegacyConfigDeprecationFactory {
rename(oldKey: string, newKey: string): LegacyConfigDeprecation;
unused(unusedKey: string): LegacyConfigDeprecation;
}

/**
* Representation of a legacy configuration deprecation.
*
* @internal
* @deprecated
*/
export type LegacyConfigDeprecation = (settings: LegacyVars, log: (msg: string) => void) => void;

/**
* Representation of a legacy configuration deprecation provider.
*
* @internal
* @deprecated
*/
export type LegacyConfigDeprecationProvider = (
factory: LegacyConfigDeprecationFactory
) => LegacyConfigDeprecation[] | Promise<LegacyConfigDeprecation[]>;

/**
* @internal
* @deprecated
Expand All @@ -97,7 +67,6 @@ export interface LegacyPluginSpec {
getId: () => unknown;
getExpectedKibanaVersion: () => string;
getConfigPrefix: () => string;
getDeprecationsProvider: () => LegacyConfigDeprecationProvider | undefined;
getPack: () => LegacyPluginPack;
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2949,11 +2949,11 @@ export const validBodyOutput: readonly ["data", "stream"];
// Warnings were encountered during analysis:
//
// src/core/server/http/router/response.ts:316:3 - (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:163:3 - (ae-forgotten-export) The symbol "VarsProvider" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:164:3 - (ae-forgotten-export) The symbol "VarsReplacer" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:165:3 - (ae-forgotten-export) The symbol "LegacyNavLinkSpec" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:166:3 - (ae-forgotten-export) The symbol "LegacyAppSpec" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:167:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:132:3 - (ae-forgotten-export) The symbol "VarsProvider" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:133:3 - (ae-forgotten-export) The symbol "VarsReplacer" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:134:3 - (ae-forgotten-export) The symbol "LegacyNavLinkSpec" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:135:3 - (ae-forgotten-export) The symbol "LegacyAppSpec" needs to be exported by the entry point index.d.ts
// src/core/server/legacy/types.ts:136:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts
// src/core/server/plugins/types.ts:266:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts
// src/core/server/plugins/types.ts:266:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts
// src/core/server/plugins/types.ts:268:3 - (ae-forgotten-export) The symbol "PathConfigType" needs to be exported by the entry point index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/server/logging/log_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class TransformObjStream extends Stream.Transform {
method: event.method || '',
headers: event.headers,
remoteAddress: source.remoteAddress,
userAgent: source.remoteAddress,
userAgent: source.userAgent,
referer: source.referer,
};

Expand Down
4 changes: 3 additions & 1 deletion src/legacy/server/logging/log_format_json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ describe('KbnLoggerJsonFormat', () => {
},
};
const result = await createPromiseFromStreams([createListStream([event]), format]);
const { type, method, statusCode, message } = JSON.parse(result);
const { type, method, statusCode, message, req } = JSON.parse(result);

expect(type).toBe('response');
expect(method).toBe('GET');
expect(statusCode).toBe(200);
expect(message).toBe('GET /path/to/resource 200 12000ms - 13.0B');
expect(req.remoteAddress).toBe('127.0.0.1');
expect(req.userAgent).toBe('Test Thing');
});

it('ops', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import {
createAndActivateRule,
fillAboutRuleAndContinue,
fillDefineCustomRuleWithImportedQueryAndContinue,
expectDefineFormToRepopulateAndContinue,
expectAboutFormToRepopulateAndContinue,
} from '../tasks/create_new_rule';
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver';
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
Expand All @@ -82,6 +84,8 @@ describe('Detection rules, custom', () => {
goToCreateNewRule();
fillDefineCustomRuleWithImportedQueryAndContinue(newRule);
fillAboutRuleAndContinue(newRule);
expectDefineFormToRepopulateAndContinue(newRule);
expectAboutFormToRepopulateAndContinue(newRule);
createAndActivateRule();

cy.get(CUSTOM_RULES_BTN).invoke('text').should('eql', 'Custom rules (1)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

export const ABOUT_CONTINUE_BTN = '[data-test-subj="about-continue"]';

export const ABOUT_EDIT_BUTTON = '[data-test-subj="edit-about-rule"]';

export const ADD_FALSE_POSITIVE_BTN =
'[data-test-subj="detectionEngineStepAboutRuleFalsePositives"] .euiButtonEmpty__text';

Expand All @@ -26,6 +28,8 @@ export const CUSTOM_QUERY_INPUT = '[data-test-subj="queryInput"]';

export const DEFINE_CONTINUE_BUTTON = '[data-test-subj="define-continue"]';

export const DEFINE_EDIT_BUTTON = '[data-test-subj="edit-define-rule"]';

export const IMPORT_QUERY_FROM_SAVED_TIMELINE_LINK =
'[data-test-subj="importQueryFromSavedTimeline"]';

Expand Down
Loading

0 comments on commit 8d8152c

Please sign in to comment.