Skip to content

Commit

Permalink
Changes in other plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Oct 28, 2019
1 parent 5e6a836 commit bb13b13
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 287 deletions.
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/server/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface Server extends Legacy.Server {
*/
export type TaskManagerStartContract = Pick<TaskManager, 'schedule' | 'fetch' | 'remove'>;
export type XPackMainPluginSetupContract = Pick<XPackMainPlugin, 'registerFeature'>;
export type SecurityPluginSetupContract = Pick<SecurityPlugin, 'config' | 'registerLegacyAPI'>;
export type SecurityPluginSetupContract = Pick<SecurityPlugin, '__legacyCompat'>;
export type SecurityPluginStartContract = Pick<SecurityPlugin, 'authc'>;
export type EncryptedSavedObjectsSetupContract = Pick<EncryptedSavedObjectsPlugin, 'registerType'>;
export type TaskManagerSetupContract = Pick<
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/alerting/server/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface Server extends Legacy.Server {
* Shim what we're thinking setup and start contracts will look like
*/
export type TaskManagerStartContract = Pick<TaskManager, 'schedule' | 'fetch' | 'remove'>;
export type SecurityPluginSetupContract = Pick<SecurityPlugin, 'config' | 'registerLegacyAPI'>;
export type SecurityPluginSetupContract = Pick<SecurityPlugin, '__legacyCompat'>;
export type SecurityPluginStartContract = Pick<SecurityPlugin, 'authc'>;
export type EncryptedSavedObjectsSetupContract = Pick<EncryptedSavedObjectsPlugin, 'registerType'>;
export type XPackMainPluginSetupContract = Pick<XPackMainPlugin, 'registerFeature'>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export const getCustomLogo = async ({
// We use the basePath from the saved job, which we'll have post spaces being implemented;
// or we use the server base path, which uses the default space
getBasePath: () => job.basePath || serverBasePath,
path: '/',
route: { settings: {} },
url: {
href: '/',
},
raw: {
req: {
url: '/',
},
},
};

const savedObjects = server.savedObjects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ function executeJobFn(server) {
// We use the basePath from the saved job, which we'll have post spaces being implemented;
// or we use the server base path, which uses the default space
getBasePath: () => basePath || serverBasePath,
path: '/',
route: { settings: {} },
url: {
href: '/',
},
raw: {
req: {
url: '/',
},
},
};

const callEndpoint = (endpoint, clientParams = {}, options = {}) => {
Expand Down
17 changes: 1 addition & 16 deletions x-pack/legacy/plugins/reporting/server/lib/get_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,9 @@
*/

import { oncePerServer } from './once_per_server';
import { getClient as getShieldClient } from '../../../../server/lib/get_client_shield';

function getUserFn(server) {
const callShieldWithRequest = getShieldClient(server).callWithRequest;

return async function getUser(request) {
const xpackInfo = server.plugins.xpack_main.info;
if (xpackInfo && xpackInfo.isAvailable() && xpackInfo.feature('security').isEnabled()) {
try {
return await callShieldWithRequest(request, 'shield.authenticate');
} catch (err) {
server.log(['reporting', 'getUser', 'debug'], err);
return null;
}
}

return null;
};
return (request) => server.plugins.security.getUser(request);
}

export const getUserFactory = oncePerServer(getUserFn);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('authorized_user_pre_routing', function () {
// so createMockServer reuses the same 'instance' of the server and overwrites
// the properties to contain different values
const createMockServer = (function () {
const callWithRequestStub = sinon.stub();
const getUserStub = sinon.stub();
let mockConfig;

const mockServer = {
Expand All @@ -30,13 +30,7 @@ describe('authorized_user_pre_routing', function () {
log: function () {},
plugins: {
xpack_main: {},
elasticsearch: {
createCluster: function () {
return {
callWithRequest: callWithRequestStub
};
}
}
security: { getUser: getUserStub },
}
};

Expand All @@ -57,8 +51,8 @@ describe('authorized_user_pre_routing', function () {
}
};

callWithRequestStub.resetHistory();
callWithRequestStub.returns(Promise.resolve(user));
getUserStub.resetHistory();
getUserStub.resolves(user);
return mockServer;
};
}());
Expand Down
8 changes: 0 additions & 8 deletions x-pack/legacy/plugins/spaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import { Legacy } from 'kibana';
import { KibanaRequest } from '../../../../src/core/server';
import { SpacesServiceSetup } from '../../../plugins/spaces/server/spaces_service/spaces_service';
import { SpacesPluginSetup } from '../../../plugins/spaces/server';
import { createOptionalPlugin } from '../../server/lib/optional_plugin';
// @ts-ignore
import { AuditLogger } from '../../server/lib/audit_logger';
import mappings from './mappings.json';
import { wrapError } from './server/lib/errors';
import { migrateToKibana660 } from './server/lib/migrations';
import { SecurityPlugin } from '../security';
// @ts-ignore
import { watchStatusAndLicenseToInitialize } from '../../server/lib/watch_status_and_license_to_initialize';
import { initSpaceSelectorView, initEnterSpaceView } from './server/routes/views';
Expand Down Expand Up @@ -139,12 +137,6 @@ export const spaces = (kibana: Record<string, any>) =>
create: (pluginId: string) =>
new AuditLogger(server, pluginId, server.config(), server.plugins.xpack_main.info),
},
security: createOptionalPlugin<SecurityPlugin>(
server.config(),
'xpack.security',
server.plugins,
'security'
),
xpackMain: server.plugins.xpack_main,
});

Expand Down

This file was deleted.

85 changes: 0 additions & 85 deletions x-pack/legacy/server/lib/optional_plugin.test.ts

This file was deleted.

48 changes: 0 additions & 48 deletions x-pack/legacy/server/lib/optional_plugin.ts

This file was deleted.

1 change: 1 addition & 0 deletions x-pack/plugins/spaces/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"kibanaVersion": "kibana",
"configPath": ["xpack", "spaces"],
"requiredPlugins": ["features", "licensing"],
"optionalPlugins": ["security"],
"server": true,
"ui": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ import { SpacesAuditLogger } from '../audit_logger';
import { convertSavedObjectToSpace } from '../../routes/lib';
import { initSpacesOnPostAuthRequestInterceptor } from './on_post_auth_interceptor';
import { Feature } from '../../../../features/server';
import { OptionalPlugin } from '../../../../../legacy/server/lib/optional_plugin';
import { SecurityPlugin } from '../../../../../legacy/plugins/security';
import { spacesConfig } from '../__fixtures__';
import { securityMock } from '../../../../security/server/mocks';

describe('onPostAuthInterceptor', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
Expand Down Expand Up @@ -170,7 +169,7 @@ describe('onPostAuthInterceptor', () => {
const spacesService = await service.setup({
http: (http as unknown) as CoreSetup['http'],
elasticsearch: elasticsearchServiceMock.createSetupContract(),
getSecurity: () => ({} as OptionalPlugin<SecurityPlugin>),
authorization: securityMock.createSetup().authz,
getSpacesAuditLogger: () => ({} as SpacesAuditLogger),
config$: Rx.of(spacesConfig),
});
Expand Down
Loading

0 comments on commit bb13b13

Please sign in to comment.