Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 51277
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Feb 3, 2020
2 parents c171a4e + 8def60e commit 80a090d
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 67 deletions.
1 change: 1 addition & 0 deletions src/core/server/http/integration_tests/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ describe('Auth', () => {
res.ok({
headers: {
'www-authenticate': 'from handler',
'another-header': 'yet another header',
},
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/lifecycle/on_pre_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export function adoptToHapiOnPreResponseFormat(fn: OnPreResponseHandler, log: Lo
...(result.headers as any), // hapi types don't specify string[] as valid value
};
} else {
findHeadersIntersection(response.headers, result.headers, log);
for (const [headerName, headerValue] of Object.entries(result.headers)) {
findHeadersIntersection(response.headers, result.headers, log);
response.header(headerName, headerValue as any); // hapi types don't specify string[] as valid value
}
}
Expand Down
6 changes: 3 additions & 3 deletions x-pack/legacy/plugins/alerting/server/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
CreateAPIKeyResult as SecurityPluginCreateAPIKeyResult,
InvalidateAPIKeyResult as SecurityPluginInvalidateAPIKeyResult,
} from '../../../../plugins/security/server';
import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../../plugins/encrypted_saved_objects/server';
import { EncryptedSavedObjectsPluginStart } from '../../../../plugins/encrypted_saved_objects/server';
import { TaskManagerStartContract } from '../../../../plugins/task_manager/server';

type NormalizedAlertAction = Omit<AlertAction, 'actionTypeId'>;
Expand All @@ -45,7 +45,7 @@ interface ConstructorOptions {
taskManager: TaskManagerStartContract;
savedObjectsClient: SavedObjectsClientContract;
alertTypeRegistry: AlertTypeRegistry;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;
spaceId?: string;
namespace?: string;
getUserName: () => Promise<string | null>;
Expand Down Expand Up @@ -120,7 +120,7 @@ export class AlertsClient {
private readonly invalidateAPIKey: (
params: InvalidateAPIKeyParams
) => Promise<InvalidateAPIKeyResult>;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;

constructor({
alertTypeRegistry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AlertTypeRegistry, SpaceIdToNamespaceFunction } from './types';
import { SecurityPluginStartContract } from './shim';
import { KibanaRequest, Logger } from '../../../../../src/core/server';
import { InvalidateAPIKeyParams } from '../../../../plugins/security/server';
import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../../plugins/encrypted_saved_objects/server';
import { EncryptedSavedObjectsPluginStart } from '../../../../plugins/encrypted_saved_objects/server';
import { TaskManagerStartContract } from '../../../../plugins/task_manager/server';

export interface ConstructorOpts {
Expand All @@ -21,7 +21,7 @@ export interface ConstructorOpts {
securityPluginSetup?: SecurityPluginStartContract;
getSpaceId: (request: Hapi.Request) => string | undefined;
spaceIdToNamespace: SpaceIdToNamespaceFunction;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;
}

export class AlertsClientFactory {
Expand All @@ -31,7 +31,7 @@ export class AlertsClientFactory {
private readonly securityPluginSetup?: SecurityPluginStartContract;
private readonly getSpaceId: (request: Hapi.Request) => string | undefined;
private readonly spaceIdToNamespace: SpaceIdToNamespaceFunction;
private readonly encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
private readonly encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;

constructor(options: ConstructorOpts) {
this.logger = options.logger;
Expand Down
18 changes: 9 additions & 9 deletions x-pack/legacy/plugins/alerting/server/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { getTaskManagerSetup, getTaskManagerStart } from '../../task_manager/ser
import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
import KbnServer from '../../../../../src/legacy/server/kbn_server';
import {
PluginSetupContract as EncryptedSavedObjectsSetupContract,
PluginStartContract as EncryptedSavedObjectsStartContract,
EncryptedSavedObjectsPluginSetup,
EncryptedSavedObjectsPluginStart,
} from '../../../../plugins/encrypted_saved_objects/server';
import { PluginSetupContract as SecurityPlugin } from '../../../../plugins/security/server';
import { SecurityPluginSetup } from '../../../../plugins/security/server';
import {
CoreSetup,
LoggerFactory,
Expand All @@ -44,8 +44,8 @@ export interface Server extends Legacy.Server {
/**
* Shim what we're thinking setup and start contracts will look like
*/
export type SecurityPluginSetupContract = Pick<SecurityPlugin, '__legacyCompat'>;
export type SecurityPluginStartContract = Pick<SecurityPlugin, 'authc'>;
export type SecurityPluginSetupContract = Pick<SecurityPluginSetup, '__legacyCompat'>;
export type SecurityPluginStartContract = Pick<SecurityPluginSetup, 'authc'>;
export type XPackMainPluginSetupContract = Pick<XPackMainPlugin, 'registerFeature'>;

/**
Expand All @@ -71,14 +71,14 @@ export interface AlertingPluginsSetup {
taskManager: TaskManagerSetupContract;
actions: ActionsPluginSetupContract;
xpack_main: XPackMainPluginSetupContract;
encryptedSavedObjects: EncryptedSavedObjectsSetupContract;
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup;
licensing: LicensingPluginSetup;
}
export interface AlertingPluginsStart {
actions: ActionsPluginStartContract;
security?: SecurityPluginStartContract;
spaces: () => SpacesPluginStartContract | undefined;
encryptedSavedObjects: EncryptedSavedObjectsStartContract;
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
taskManager: TaskManagerStartContract;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export function shim(
actions: newPlatform.setup.plugins.actions as ActionsPluginSetupContract,
xpack_main: server.plugins.xpack_main,
encryptedSavedObjects: newPlatform.setup.plugins
.encryptedSavedObjects as EncryptedSavedObjectsSetupContract,
.encryptedSavedObjects as EncryptedSavedObjectsPluginSetup,
licensing: newPlatform.setup.plugins.licensing as LicensingPluginSetup,
};

Expand All @@ -131,7 +131,7 @@ export function shim(
// initializes after this function is called
spaces: () => server.plugins.spaces,
encryptedSavedObjects: newPlatform.start.plugins
.encryptedSavedObjects as EncryptedSavedObjectsStartContract,
.encryptedSavedObjects as EncryptedSavedObjectsPluginStart,
taskManager: getTaskManagerStart(server)!,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { Logger } from '../../../../../../src/core/server';
import { RunContext } from '../../../../../plugins/task_manager/server';
import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../../../plugins/encrypted_saved_objects/server';
import { EncryptedSavedObjectsPluginStart } from '../../../../../plugins/encrypted_saved_objects/server';
import { PluginStartContract as ActionsPluginStartContract } from '../../../../../plugins/actions/server';
import {
AlertType,
Expand All @@ -19,7 +19,7 @@ export interface TaskRunnerContext {
logger: Logger;
getServices: GetServicesFunction;
executeAction: ActionsPluginStartContract['execute'];
encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;
spaceIdToNamespace: SpaceIdToNamespaceFunction;
getBasePath: GetBasePathFunction;
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/encrypted_saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Root } from 'joi';
import { Legacy } from 'kibana';
import { PluginSetupContract } from '../../../plugins/encrypted_saved_objects/server';
import { EncryptedSavedObjectsPluginSetup } from '../../../plugins/encrypted_saved_objects/server';
// @ts-ignore
import { AuditLogger } from '../../server/lib/audit_logger';

Expand All @@ -29,7 +29,7 @@ export const encryptedSavedObjects = (kibana: {

init(server: Legacy.Server) {
const encryptedSavedObjectsPlugin = (server.newPlatform.setup.plugins
.encryptedSavedObjects as unknown) as PluginSetupContract;
.encryptedSavedObjects as unknown) as EncryptedSavedObjectsPluginSetup;
if (!encryptedSavedObjectsPlugin) {
throw new Error('New Platform XPack EncryptedSavedObjects plugin is not available.');
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/reporting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Legacy } from 'kibana';
import { IUiSettingsClient } from 'kibana/server';
import { resolve } from 'path';
import { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server';
import { PluginSetupContract as SecurityPluginSetup } from '../../../plugins/security/server';
import { SecurityPluginSetup } from '../../../plugins/security/server';
import { PLUGIN_ID, UI_SETTINGS_CUSTOM_PDF_LOGO } from './common/constants';
import { config as reportingConfig } from './config';
import { LegacySetup, ReportingPlugin, reportingPluginFactory } from './server/plugin';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/reporting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from 'src/core/server';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server';
import { PluginSetupContract as SecurityPluginSetup } from '../../../../plugins/security/server';
import { SecurityPluginSetup } from '../../../../plugins/security/server';
// @ts-ignore
import { mirrorPluginStatus } from '../../../server/lib/mirror_plugin_status';
import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const EMPTY_TITLE = i18n.translate('xpack.siem.pages.common.emptyTitle',

export const EMPTY_MESSAGE = i18n.translate('xpack.siem.pages.common.emptyMessage', {
defaultMessage:
'To begin using security information and event management, you’ll need to begin adding SIEM-related data to Kibana by installing and configuring our data shippers, called Beats. Let’s do that now!',
'To begin using security information and event management (SIEM), you’ll need to add SIEM-related data, in Elastic Common Schema (ECS) format, to the Elastic Stack. An easy way to get started is by installing and configuring our data shippers, called Beats. Let’s do that now!',
});

export const EMPTY_ACTION_PRIMARY = i18n.translate('xpack.siem.pages.common.emptyActionPrimary', {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/siem/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { i18n } from '@kbn/i18n';
import { CoreSetup, PluginInitializerContext, Logger } from 'src/core/server';
import { PluginSetupContract as SecurityPlugin } from '../../../../plugins/security/server';
import { SecurityPluginSetup } from '../../../../plugins/security/server';
import { PluginSetupContract as FeaturesSetupContract } from '../../../../plugins/features/server';
import { initServer } from './init_server';
import { compose } from './lib/compose/kibana';
Expand All @@ -17,7 +17,7 @@ import {
ruleStatusSavedObjectType,
} from './saved_objects';

export type SiemPluginSecurity = Pick<SecurityPlugin, 'authc'>;
export type SiemPluginSecurity = Pick<SecurityPluginSetup, 'authc'>;

export interface PluginsSetup {
features: FeaturesSetupContract;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
GetServicesFunction,
RawAction,
} from '../types';
import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../encrypted_saved_objects/server';
import { EncryptedSavedObjectsPluginStart } from '../../../encrypted_saved_objects/server';
import { SpacesServiceSetup } from '../../../spaces/server';
import { EVENT_LOG_ACTIONS } from '../plugin';
import { IEvent, IEventLogger } from '../../../event_log/server';
Expand All @@ -21,7 +21,7 @@ export interface ActionExecutorContext {
logger: Logger;
spaces?: SpacesServiceSetup;
getServices: GetServicesFunction;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;
actionTypeRegistry: ActionTypeRegistryContract;
eventLogger: IEventLogger;
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/actions/server/lib/task_runner_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { ActionExecutorContract } from './action_executor';
import { ExecutorError } from './executor_error';
import { Logger, CoreStart } from '../../../../../src/core/server';
import { RunContext } from '../../../task_manager/server';
import { PluginStartContract as EncryptedSavedObjectsStartContract } from '../../../encrypted_saved_objects/server';
import { EncryptedSavedObjectsPluginStart } from '../../../encrypted_saved_objects/server';
import { ActionTaskParams, GetBasePathFunction, SpaceIdToNamespaceFunction } from '../types';

export interface TaskRunnerContext {
logger: Logger;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsStartContract;
encryptedSavedObjectsPlugin: EncryptedSavedObjectsPluginStart;
spaceIdToNamespace: SpaceIdToNamespaceFunction;
getBasePath: GetBasePathFunction;
getScopedSavedObjectsClient: CoreStart['savedObjects']['getScopedClient'];
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
} from '../../../../src/core/server';

import {
PluginSetupContract as EncryptedSavedObjectsSetupContract,
PluginStartContract as EncryptedSavedObjectsStartContract,
EncryptedSavedObjectsPluginSetup,
EncryptedSavedObjectsPluginStart,
} from '../../encrypted_saved_objects/server';
import { TaskManagerSetupContract, TaskManagerStartContract } from '../../task_manager/server';
import { LicensingPluginSetup } from '../../licensing/server';
Expand Down Expand Up @@ -67,13 +67,13 @@ export interface PluginStartContract {

export interface ActionsPluginsSetup {
taskManager: TaskManagerSetupContract;
encryptedSavedObjects: EncryptedSavedObjectsSetupContract;
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup;
licensing: LicensingPluginSetup;
spaces?: SpacesPluginSetup;
event_log: IEventLogService;
}
export interface ActionsPluginsStart {
encryptedSavedObjects: EncryptedSavedObjectsStartContract;
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
taskManager: TaskManagerStartContract;
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/case/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CoreSetup, Logger, PluginInitializerContext } from 'kibana/server';
import { ConfigType } from './config';
import { initCaseApi } from './routes/api';
import { CaseService } from './services';
import { PluginSetupContract as SecurityPluginSetup } from '../../security/server';
import { SecurityPluginSetup } from '../../security/server';

function createConfig$(context: PluginInitializerContext) {
return context.config.create<ConfigType>().pipe(map(config => config));
Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/case/server/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import {
UpdatedCaseType,
UpdatedCommentType,
} from '../routes/api/types';
import {
AuthenticatedUser,
PluginSetupContract as SecurityPluginSetup,
} from '../../../security/server';
import { AuthenticatedUser, SecurityPluginSetup } from '../../../security/server';

interface ClientArgs {
client: SavedObjectsClientContract;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/encrypted_saved_objects/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ConfigSchema } from './config';
import { Plugin } from './plugin';

export { EncryptedSavedObjectTypeRegistration, EncryptionError } from './crypto';
export { PluginSetupContract, PluginStartContract } from './plugin';
export { EncryptedSavedObjectsPluginSetup, EncryptedSavedObjectsPluginStart } from './plugin';

export const config = { schema: ConfigSchema };
export const plugin = (initializerContext: PluginInitializerContext) =>
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/encrypted_saved_objects/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { PluginSetupContract, PluginStartContract } from './plugin';
import { EncryptedSavedObjectsPluginSetup, EncryptedSavedObjectsPluginStart } from './plugin';

function createEncryptedSavedObjectsSetupMock() {
return {
registerType: jest.fn(),
__legacyCompat: { registerLegacyAPI: jest.fn() },
usingEphemeralEncryptionKey: true,
} as jest.Mocked<PluginSetupContract>;
} as jest.Mocked<EncryptedSavedObjectsPluginSetup>;
}

function createEncryptedSavedObjectsStartMock() {
return {
isEncryptionError: jest.fn(),
getDecryptedAsInternalUser: jest.fn(),
} as jest.Mocked<PluginStartContract>;
} as jest.Mocked<EncryptedSavedObjectsPluginStart>;
}

export const encryptedSavedObjectsMock = {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/encrypted_saved_objects/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import {
import { EncryptedSavedObjectsAuditLogger } from './audit';
import { SavedObjectsSetup, setupSavedObjects } from './saved_objects';

export interface PluginSetupContract {
export interface EncryptedSavedObjectsPluginSetup {
registerType: (typeRegistration: EncryptedSavedObjectTypeRegistration) => void;
__legacyCompat: { registerLegacyAPI: (legacyAPI: LegacyAPI) => void };
usingEphemeralEncryptionKey: boolean;
}

export interface PluginStartContract extends SavedObjectsSetup {
export interface EncryptedSavedObjectsPluginStart extends SavedObjectsSetup {
isEncryptionError: (error: Error) => boolean;
}

Expand Down Expand Up @@ -59,7 +59,7 @@ export class Plugin {
this.logger = this.initializerContext.logger.get();
}

public async setup(core: CoreSetup): Promise<PluginSetupContract> {
public async setup(core: CoreSetup): Promise<EncryptedSavedObjectsPluginSetup> {
const { config, usingEphemeralEncryptionKey } = await createConfig$(this.initializerContext)
.pipe(first())
.toPromise();
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/security/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RecursiveReadonly,
} from '../../../../src/core/server';
import { ConfigSchema } from './config';
import { Plugin, PluginSetupContract, PluginSetupDependencies } from './plugin';
import { Plugin, SecurityPluginSetup, PluginSetupDependencies } from './plugin';

// These exports are part of public Security plugin contract, any change in signature of exported
// functions or removal of exports should be considered as a breaking change.
Expand All @@ -24,7 +24,7 @@ export {
InvalidateAPIKeyParams,
InvalidateAPIKeyResult,
} from './authentication';
export { PluginSetupContract };
export { SecurityPluginSetup };
export { AuthenticatedUser } from '../common/model';

export const config: PluginConfigDescriptor<TypeOf<typeof ConfigSchema>> = {
Expand All @@ -35,7 +35,7 @@ export const config: PluginConfigDescriptor<TypeOf<typeof ConfigSchema>> = {
],
};
export const plugin: PluginInitializer<
RecursiveReadonly<PluginSetupContract>,
RecursiveReadonly<SecurityPluginSetup>,
void,
PluginSetupDependencies
> = (initializerContext: PluginInitializerContext) => new Plugin(initializerContext);
4 changes: 2 additions & 2 deletions x-pack/plugins/security/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { PluginSetupContract } from './plugin';
import { SecurityPluginSetup } from './plugin';

import { authenticationMock } from './authentication/index.mock';
import { authorizationMock } from './authorization/index.mock';
Expand All @@ -19,7 +19,7 @@ function createSetupMock() {
mode: mockAuthz.mode,
},
registerSpacesService: jest.fn(),
__legacyCompat: {} as PluginSetupContract['__legacyCompat'],
__legacyCompat: {} as SecurityPluginSetup['__legacyCompat'],
};
}

Expand Down
Loading

0 comments on commit 80a090d

Please sign in to comment.