Exposing server.savedObjects without a getter
This required me to remove the kbnTestServer.createServer() method and change all usages to createServerWithCorePlugins since we're reading the kibana.index, which is part of the core plugins, when configuring the saved objects service which is attached to the server.
This commit is contained in:
parent
b0b3bd2848
commit
17d36b3e9a
|
@ -4,7 +4,7 @@ const basePath = '/kibana';
|
|||
describe('Server basePath config', function () {
|
||||
let kbnServer;
|
||||
beforeAll(async function () {
|
||||
kbnServer = kbnTestServer.createServer({
|
||||
kbnServer = kbnTestServer.createServerWithCorePlugins({
|
||||
server: { basePath }
|
||||
});
|
||||
await kbnServer.ready();
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('version_check request filter', function () {
|
|||
}
|
||||
|
||||
async function makeServer() {
|
||||
const kbnServer = kbnTestServer.createServer();
|
||||
const kbnServer = kbnTestServer.createServerWithCorePlugins();
|
||||
|
||||
await kbnServer.ready();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('xsrf request filter', function () {
|
|||
}
|
||||
|
||||
const makeServer = async function () {
|
||||
const kbnServer = kbnTestServer.createServer({
|
||||
const kbnServer = kbnTestServer.createServerWithCorePlugins({
|
||||
server: {
|
||||
xsrf: {
|
||||
disableProtection: false,
|
||||
|
|
|
@ -26,17 +26,10 @@ export function savedObjectsMixin(kbnServer, server) {
|
|||
server.route(createGetRoute(prereqs));
|
||||
server.route(createUpdateRoute(prereqs));
|
||||
|
||||
let savedObjectsService;
|
||||
server.decorate('server', 'savedObjects', () => {
|
||||
if (!savedObjectsService) {
|
||||
savedObjectsService = createSavedObjectsService(server);
|
||||
}
|
||||
|
||||
return savedObjectsService;
|
||||
});
|
||||
server.decorate('server', 'savedObjects', createSavedObjectsService(server));
|
||||
|
||||
server.decorate('server', 'savedObjectsClientFactory', ({ request }) => {
|
||||
return server.savedObjects().getScopedSavedObjectsClient(request);
|
||||
return server.savedObjects.getScopedSavedObjectsClient(request);
|
||||
});
|
||||
|
||||
const savedObjectsClientCache = new WeakMap();
|
||||
|
|
|
@ -30,20 +30,12 @@ const DEFAULT_SETTINGS_WITH_CORE_PLUGINS = {
|
|||
url: esTestConfig.getUrl(),
|
||||
username: kibanaServerTestUser.username,
|
||||
password: kibanaServerTestUser.password
|
||||
},
|
||||
kibana: {
|
||||
index: '.kibana'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an instance of KbnServer with default configuration
|
||||
* tailored for unit tests
|
||||
*
|
||||
* @param {Object} [settings={}] Any config overrides for this instance
|
||||
* @return {KbnServer}
|
||||
*/
|
||||
export function createServer(settings = {}) {
|
||||
return new KbnServer(defaultsDeep({}, settings, DEFAULTS_SETTINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of KbnServer, including all of the core plugins,
|
||||
* with default configuration tailored for unit tests
|
||||
|
|
Loading…
Reference in a new issue