mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Major cleanup of the no_restricted_paths rule for imports of core. For relative imports, we use eslint-module-utils/resolve which resolves to the full filesystem path. So, to support relative and absolute imports from the src alias we need to define both the directory and the index including file extension. This rule was handling both core imports, as well as imports from other plugins. Imports from other plugins are being used much more liberally allowed through the exceptions in tests. I choose to break these up, removing this exception for tests for core imports. Fixes: Absolute imports of src/core/server/mocks were not allowed in src. This was not an issue in x-pack due to the target excluding !x-pack/**/*.test.* and !x-pack/test/**/*. Non-top-level public and server imports were allowed from X-Pack tests to the previously mentioned exclusion. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
b0d12741cb
commit
a8edee1a68
48 changed files with 171 additions and 137 deletions
39
.eslintrc.js
39
.eslintrc.js
|
@ -191,31 +191,40 @@ module.exports = {
|
||||||
zones: [
|
zones: [
|
||||||
{
|
{
|
||||||
target: [
|
target: [
|
||||||
'src/legacy/**/*',
|
'(src|x-pack)/legacy/**/*',
|
||||||
'x-pack/**/*',
|
|
||||||
'!x-pack/**/*.test.*',
|
|
||||||
'!x-pack/test/**/*',
|
|
||||||
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
||||||
'src/core/(public|server)/**/*',
|
|
||||||
'examples/**/*',
|
'examples/**/*',
|
||||||
],
|
],
|
||||||
from: [
|
from: [
|
||||||
'src/core/public/**/*',
|
'src/core/public/**/*',
|
||||||
'!src/core/public/index.ts',
|
'!src/core/public/index.ts', // relative import
|
||||||
'!src/core/public/mocks.ts',
|
'!src/core/public/mocks{,.ts}',
|
||||||
'!src/core/public/*.test.mocks.ts',
|
'!src/core/server/types{,.ts}',
|
||||||
'!src/core/public/utils/**/*',
|
'!src/core/public/utils/**/*',
|
||||||
|
'!src/core/public/*.test.mocks{,.ts}',
|
||||||
|
|
||||||
'src/core/server/**/*',
|
'src/core/server/**/*',
|
||||||
'!src/core/server/index.ts',
|
'!src/core/server/index.ts', // relative import
|
||||||
'!src/core/server/mocks.ts',
|
'!src/core/server/mocks{,.ts}',
|
||||||
'!src/core/server/types.ts',
|
'!src/core/server/types{,.ts}',
|
||||||
'!src/core/server/test_utils.ts',
|
'!src/core/server/test_utils',
|
||||||
// for absolute imports until fixed in
|
// for absolute imports until fixed in
|
||||||
// https://github.com/elastic/kibana/issues/36096
|
// https://github.com/elastic/kibana/issues/36096
|
||||||
'!src/core/server/types',
|
'!src/core/server/*.test.mocks{,.ts}',
|
||||||
'!src/core/server/*.test.mocks.ts',
|
],
|
||||||
|
allowSameFolder: true,
|
||||||
|
errorMessage:
|
||||||
|
'Plugins may only import from top-level public and server modules in core.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: [
|
||||||
|
'(src|x-pack)/legacy/**/*',
|
||||||
|
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
||||||
|
'examples/**/*',
|
||||||
|
'!(src|x-pack)/**/*.test.*',
|
||||||
|
'!(x-pack/)?test/**/*',
|
||||||
|
],
|
||||||
|
from: [
|
||||||
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
||||||
'!(src|x-pack)/plugins/**/(public|server)/(index|mocks).{js,ts,tsx}',
|
'!(src|x-pack)/plugins/**/(public|server)/(index|mocks).{js,ts,tsx}',
|
||||||
],
|
],
|
||||||
|
|
|
@ -18,4 +18,5 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { HttpService } from './http_service';
|
export { HttpService } from './http_service';
|
||||||
|
export { HttpFetchError } from './http_fetch_error';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
|
|
|
@ -144,6 +144,7 @@ export {
|
||||||
export {
|
export {
|
||||||
HttpHeadersInit,
|
HttpHeadersInit,
|
||||||
HttpRequestInit,
|
HttpRequestInit,
|
||||||
|
HttpFetchError,
|
||||||
HttpFetchOptions,
|
HttpFetchOptions,
|
||||||
HttpFetchOptionsWithPath,
|
HttpFetchOptionsWithPath,
|
||||||
HttpFetchQuery,
|
HttpFetchQuery,
|
||||||
|
|
|
@ -593,6 +593,23 @@ export type HandlerFunction<T extends object> = (context: T, ...args: any[]) =>
|
||||||
// @public
|
// @public
|
||||||
export type HandlerParameters<T extends HandlerFunction<any>> = T extends (context: any, ...args: infer U) => any ? U : never;
|
export type HandlerParameters<T extends HandlerFunction<any>> = T extends (context: any, ...args: infer U) => any ? U : never;
|
||||||
|
|
||||||
|
// @internal (undocumented)
|
||||||
|
export class HttpFetchError extends Error implements IHttpFetchError {
|
||||||
|
constructor(message: string, name: string, request: Request, response?: Response | undefined, body?: any);
|
||||||
|
// (undocumented)
|
||||||
|
readonly body?: any;
|
||||||
|
// (undocumented)
|
||||||
|
readonly name: string;
|
||||||
|
// (undocumented)
|
||||||
|
readonly req: Request;
|
||||||
|
// (undocumented)
|
||||||
|
readonly request: Request;
|
||||||
|
// (undocumented)
|
||||||
|
readonly res?: Response;
|
||||||
|
// (undocumented)
|
||||||
|
readonly response?: Response | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
// @public
|
// @public
|
||||||
export interface HttpFetchOptions extends HttpRequestInit {
|
export interface HttpFetchOptions extends HttpRequestInit {
|
||||||
asResponse?: boolean;
|
asResponse?: boolean;
|
||||||
|
|
|
@ -45,6 +45,7 @@ export { elasticsearchServiceMock } from './elasticsearch/elasticsearch_service.
|
||||||
export { httpServiceMock } from './http/http_service.mock';
|
export { httpServiceMock } from './http/http_service.mock';
|
||||||
export { loggingServiceMock } from './logging/logging_service.mock';
|
export { loggingServiceMock } from './logging/logging_service.mock';
|
||||||
export { savedObjectsRepositoryMock } from './saved_objects/service/lib/repository.mock';
|
export { savedObjectsRepositoryMock } from './saved_objects/service/lib/repository.mock';
|
||||||
|
export { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock';
|
||||||
export { typeRegistryMock as savedObjectsTypeRegistryMock } from './saved_objects/saved_objects_type_registry.mock';
|
export { typeRegistryMock as savedObjectsTypeRegistryMock } from './saved_objects/saved_objects_type_registry.mock';
|
||||||
export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
||||||
export { metricsServiceMock } from './metrics/metrics_service.mock';
|
export { metricsServiceMock } from './metrics/metrics_service.mock';
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { EmptyStateComponent } from '../empty_state';
|
import { EmptyStateComponent } from '../empty_state';
|
||||||
import { StatesIndexStatus } from '../../../../../common/runtime_types';
|
import { StatesIndexStatus } from '../../../../../common/runtime_types';
|
||||||
import { IHttpFetchError } from '../../../../../../../../../target/types/core/public/http';
|
import { HttpFetchError, IHttpFetchError } from 'src/core/public';
|
||||||
import { HttpFetchError } from '../../../../../../../../../src/core/public/http/http_fetch_error';
|
|
||||||
import { mountWithRouter, shallowWithRouter } from '../../../../lib';
|
import { mountWithRouter, shallowWithRouter } from '../../../../lib';
|
||||||
|
|
||||||
describe('EmptyState component', () => {
|
describe('EmptyState component', () => {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { fetchSnapshotCount } from '../snapshot';
|
import { fetchSnapshotCount } from '../snapshot';
|
||||||
import { apiService } from '../utils';
|
import { apiService } from '../utils';
|
||||||
import { HttpFetchError } from '../../../../../../../../src/core/public/http/http_fetch_error';
|
import { HttpFetchError } from 'src/core/public';
|
||||||
|
|
||||||
describe('snapshot API', () => {
|
describe('snapshot API', () => {
|
||||||
let fetchMock: jest.SpyInstance<Partial<unknown>>;
|
let fetchMock: jest.SpyInstance<Partial<unknown>>;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import { call, put } from 'redux-saga/effects';
|
import { call, put } from 'redux-saga/effects';
|
||||||
import { fetchEffectFactory } from '../fetch_effect';
|
import { fetchEffectFactory } from '../fetch_effect';
|
||||||
import { indexStatusAction } from '../../actions';
|
import { indexStatusAction } from '../../actions';
|
||||||
import { HttpFetchError } from '../../../../../../../../src/core/public/http/http_fetch_error';
|
import { HttpFetchError } from 'src/core/public';
|
||||||
import { StatesIndexStatus } from '../../../../common/runtime_types';
|
import { StatesIndexStatus } from '../../../../common/runtime_types';
|
||||||
import { fetchIndexStatus } from '../../api';
|
import { fetchIndexStatus } from '../../api';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { createActionRoute } from './create';
|
import { createActionRoute } from './create';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
import { verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -20,7 +20,7 @@ beforeEach(() => {
|
||||||
describe('createActionRoute', () => {
|
describe('createActionRoute', () => {
|
||||||
it('creates an action with proper parameters', async () => {
|
it('creates an action with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
createActionRoute(router, licenseState);
|
createActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ describe('createActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows creating actions', async () => {
|
it('ensures the license allows creating actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
createActionRoute(router, licenseState);
|
createActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ describe('createActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents creating actions', async () => {
|
it('ensures the license check prevents creating actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
@ -135,7 +135,7 @@ describe('createActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the action type gets validated for the license', async () => {
|
it('ensures the action type gets validated for the license', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
createActionRoute(router, licenseState);
|
createActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { deleteActionRoute } from './delete';
|
import { deleteActionRoute } from './delete';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib';
|
import { verifyApiAccess } from '../lib';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -20,7 +20,7 @@ beforeEach(() => {
|
||||||
describe('deleteActionRoute', () => {
|
describe('deleteActionRoute', () => {
|
||||||
it('deletes an action with proper parameters', async () => {
|
it('deletes an action with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
deleteActionRoute(router, licenseState);
|
deleteActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ describe('deleteActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows deleting actions', async () => {
|
it('ensures the license allows deleting actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
deleteActionRoute(router, licenseState);
|
deleteActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ describe('deleteActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents deleting actions', async () => {
|
it('ensures the license check prevents deleting actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { executeActionRoute } from './execute';
|
import { executeActionRoute } from './execute';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { ActionExecutorContract, verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
import { ActionExecutorContract, verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
||||||
|
@ -21,7 +21,7 @@ beforeEach(() => {
|
||||||
describe('executeActionRoute', () => {
|
describe('executeActionRoute', () => {
|
||||||
it('executes an action with proper parameters', async () => {
|
it('executes an action with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const [context, req, res] = mockHandlerArguments(
|
const [context, req, res] = mockHandlerArguments(
|
||||||
{},
|
{},
|
||||||
|
@ -77,7 +77,7 @@ describe('executeActionRoute', () => {
|
||||||
|
|
||||||
it('returns a "204 NO CONTENT" when the executor returns a nullish value', async () => {
|
it('returns a "204 NO CONTENT" when the executor returns a nullish value', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const [context, req, res] = mockHandlerArguments(
|
const [context, req, res] = mockHandlerArguments(
|
||||||
{},
|
{},
|
||||||
|
@ -115,7 +115,7 @@ describe('executeActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows action execution', async () => {
|
it('ensures the license allows action execution', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const [context, req, res] = mockHandlerArguments(
|
const [context, req, res] = mockHandlerArguments(
|
||||||
{},
|
{},
|
||||||
|
@ -147,7 +147,7 @@ describe('executeActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents action execution', async () => {
|
it('ensures the license check prevents action execution', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
@ -183,7 +183,7 @@ describe('executeActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the action type gets validated for the license', async () => {
|
it('ensures the action type gets validated for the license', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const [context, req, res] = mockHandlerArguments(
|
const [context, req, res] = mockHandlerArguments(
|
||||||
{},
|
{},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getActionRoute } from './get';
|
import { getActionRoute } from './get';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib';
|
import { verifyApiAccess } from '../lib';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -21,7 +21,7 @@ beforeEach(() => {
|
||||||
describe('getActionRoute', () => {
|
describe('getActionRoute', () => {
|
||||||
it('gets an action with proper parameters', async () => {
|
it('gets an action with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getActionRoute(router, licenseState);
|
getActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ describe('getActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows getting actions', async () => {
|
it('ensures the license allows getting actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getActionRoute(router, licenseState);
|
getActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ describe('getActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents getting actions', async () => {
|
it('ensures the license check prevents getting actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getAllActionRoute } from './get_all';
|
import { getAllActionRoute } from './get_all';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib';
|
import { verifyApiAccess } from '../lib';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -21,7 +21,7 @@ beforeEach(() => {
|
||||||
describe('getAllActionRoute', () => {
|
describe('getAllActionRoute', () => {
|
||||||
it('get all actions with proper parameters', async () => {
|
it('get all actions with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAllActionRoute(router, licenseState);
|
getAllActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ describe('getAllActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows getting all actions', async () => {
|
it('ensures the license allows getting all actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAllActionRoute(router, licenseState);
|
getAllActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ describe('getAllActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents getting all actions', async () => {
|
it('ensures the license check prevents getting all actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { listActionTypesRoute } from './list_action_types';
|
import { listActionTypesRoute } from './list_action_types';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib';
|
import { verifyApiAccess } from '../lib';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -21,7 +21,7 @@ beforeEach(() => {
|
||||||
describe('listActionTypesRoute', () => {
|
describe('listActionTypesRoute', () => {
|
||||||
it('lists action types with proper parameters', async () => {
|
it('lists action types with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
listActionTypesRoute(router, licenseState);
|
listActionTypesRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ describe('listActionTypesRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows listing action types', async () => {
|
it('ensures the license allows listing action types', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
listActionTypesRoute(router, licenseState);
|
listActionTypesRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ describe('listActionTypesRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents listing action types', async () => {
|
it('ensures the license check prevents listing action types', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { updateActionRoute } from './update';
|
import { updateActionRoute } from './update';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { licenseStateMock } from '../lib/license_state.mock';
|
import { licenseStateMock } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
import { verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -20,7 +20,7 @@ beforeEach(() => {
|
||||||
describe('updateActionRoute', () => {
|
describe('updateActionRoute', () => {
|
||||||
it('updates an action with proper parameters', async () => {
|
it('updates an action with proper parameters', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
updateActionRoute(router, licenseState);
|
updateActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ describe('updateActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows deleting actions', async () => {
|
it('ensures the license allows deleting actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
updateActionRoute(router, licenseState);
|
updateActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ describe('updateActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents deleting actions', async () => {
|
it('ensures the license check prevents deleting actions', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
@ -168,7 +168,7 @@ describe('updateActionRoute', () => {
|
||||||
|
|
||||||
it('ensures the action type gets validated for the license', async () => {
|
it('ensures the action type gets validated for the license', async () => {
|
||||||
const licenseState = licenseStateMock.create();
|
const licenseState = licenseStateMock.create();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
updateActionRoute(router, licenseState);
|
updateActionRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createAlertRoute } from './create';
|
import { createAlertRoute } from './create';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -68,7 +68,7 @@ describe('createAlertRoute', () => {
|
||||||
|
|
||||||
it('creates an alert with proper parameters', async () => {
|
it('creates an alert with proper parameters', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
createAlertRoute(router, licenseState);
|
createAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ describe('createAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows creating alerts', async () => {
|
it('ensures the license allows creating alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
createAlertRoute(router, licenseState);
|
createAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ describe('createAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents creating alerts', async () => {
|
it('ensures the license check prevents creating alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { deleteAlertRoute } from './delete';
|
import { deleteAlertRoute } from './delete';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -23,7 +23,7 @@ beforeEach(() => {
|
||||||
describe('deleteAlertRoute', () => {
|
describe('deleteAlertRoute', () => {
|
||||||
it('deletes an alert with proper parameters', async () => {
|
it('deletes an alert with proper parameters', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
deleteAlertRoute(router, licenseState);
|
deleteAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ describe('deleteAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows deleting alerts', async () => {
|
it('ensures the license allows deleting alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
deleteAlertRoute(router, licenseState);
|
deleteAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ describe('deleteAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents deleting alerts', async () => {
|
it('ensures the license check prevents deleting alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { disableAlertRoute } from './disable';
|
import { disableAlertRoute } from './disable';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -23,7 +23,7 @@ beforeEach(() => {
|
||||||
describe('disableAlertRoute', () => {
|
describe('disableAlertRoute', () => {
|
||||||
it('disables an alert', async () => {
|
it('disables an alert', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
disableAlertRoute(router, licenseState);
|
disableAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { enableAlertRoute } from './enable';
|
import { enableAlertRoute } from './enable';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
describe('enableAlertRoute', () => {
|
describe('enableAlertRoute', () => {
|
||||||
it('enables an alert', async () => {
|
it('enables an alert', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
enableAlertRoute(router, licenseState);
|
enableAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findAlertRoute } from './find';
|
import { findAlertRoute } from './find';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -24,7 +24,7 @@ beforeEach(() => {
|
||||||
describe('findAlertRoute', () => {
|
describe('findAlertRoute', () => {
|
||||||
it('finds alerts with proper parameters', async () => {
|
it('finds alerts with proper parameters', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
findAlertRoute(router, licenseState);
|
findAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ describe('findAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows finding alerts', async () => {
|
it('ensures the license allows finding alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
findAlertRoute(router, licenseState);
|
findAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ describe('findAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents finding alerts', async () => {
|
it('ensures the license check prevents finding alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getAlertRoute } from './get';
|
import { getAlertRoute } from './get';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -55,7 +55,7 @@ describe('getAlertRoute', () => {
|
||||||
|
|
||||||
it('gets an alert with proper parameters', async () => {
|
it('gets an alert with proper parameters', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAlertRoute(router, licenseState);
|
getAlertRoute(router, licenseState);
|
||||||
const [config, handler] = router.get.mock.calls[0];
|
const [config, handler] = router.get.mock.calls[0];
|
||||||
|
@ -90,7 +90,7 @@ describe('getAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows getting alerts', async () => {
|
it('ensures the license allows getting alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAlertRoute(router, licenseState);
|
getAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ describe('getAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents getting alerts', async () => {
|
it('ensures the license check prevents getting alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getAlertStateRoute } from './get_alert_state';
|
import { getAlertStateRoute } from './get_alert_state';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { SavedObjectsErrorHelpers } from 'src/core/server/saved_objects';
|
import { SavedObjectsErrorHelpers } from 'src/core/server';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
|
||||||
const alertsClient = alertsClientMock.create();
|
const alertsClient = alertsClientMock.create();
|
||||||
|
@ -41,7 +41,7 @@ describe('getAlertStateRoute', () => {
|
||||||
|
|
||||||
it('gets alert state', async () => {
|
it('gets alert state', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAlertStateRoute(router, licenseState);
|
getAlertStateRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ describe('getAlertStateRoute', () => {
|
||||||
|
|
||||||
it('returns NO-CONTENT when alert exists but has no task state yet', async () => {
|
it('returns NO-CONTENT when alert exists but has no task state yet', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAlertStateRoute(router, licenseState);
|
getAlertStateRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ describe('getAlertStateRoute', () => {
|
||||||
|
|
||||||
it('returns NOT-FOUND when alert is not found', async () => {
|
it('returns NOT-FOUND when alert is not found', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
getAlertStateRoute(router, licenseState);
|
getAlertStateRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { healthRoute } from './health';
|
import { healthRoute } from './health';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks';
|
import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('healthRoute', () => {
|
describe('healthRoute', () => {
|
||||||
it('registers the route', async () => {
|
it('registers the route', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -35,7 +35,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('queries the usage api', async () => {
|
it('queries the usage api', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -64,7 +64,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates whether Encrypted Saved Objects is using an ephemeral encryption key', async () => {
|
it('evaluates whether Encrypted Saved Objects is using an ephemeral encryption key', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -88,7 +88,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates missing security info from the usage api to mean that the security plugin is disbled', async () => {
|
it('evaluates missing security info from the usage api to mean that the security plugin is disbled', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -112,7 +112,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates missing security http info from the usage api to mean that the security plugin is disbled', async () => {
|
it('evaluates missing security http info from the usage api to mean that the security plugin is disbled', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -136,7 +136,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates security enabled, and missing ssl info from the usage api to mean that the user cannot generate keys', async () => {
|
it('evaluates security enabled, and missing ssl info from the usage api to mean that the user cannot generate keys', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -162,7 +162,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates security enabled, SSL info present but missing http info from the usage api to mean that the user cannot generate keys', async () => {
|
it('evaluates security enabled, SSL info present but missing http info from the usage api to mean that the user cannot generate keys', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
@ -188,7 +188,7 @@ describe('healthRoute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('evaluates security and tls enabled to mean that the user can generate keys', async () => {
|
it('evaluates security and tls enabled to mean that the user can generate keys', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
const encryptedSavedObjects = encryptedSavedObjectsMock.createSetup();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { listAlertTypesRoute } from './list_alert_types';
|
import { listAlertTypesRoute } from './list_alert_types';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -21,7 +21,7 @@ beforeEach(() => {
|
||||||
describe('listAlertTypesRoute', () => {
|
describe('listAlertTypesRoute', () => {
|
||||||
it('lists alert types with proper parameters', async () => {
|
it('lists alert types with proper parameters', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
listAlertTypesRoute(router, licenseState);
|
listAlertTypesRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ describe('listAlertTypesRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows listing alert types', async () => {
|
it('ensures the license allows listing alert types', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
listAlertTypesRoute(router, licenseState);
|
listAlertTypesRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ describe('listAlertTypesRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents listing alert types', async () => {
|
it('ensures the license check prevents listing alert types', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { muteAllAlertRoute } from './mute_all';
|
import { muteAllAlertRoute } from './mute_all';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
describe('muteAllAlertRoute', () => {
|
describe('muteAllAlertRoute', () => {
|
||||||
it('mute an alert', async () => {
|
it('mute an alert', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
muteAllAlertRoute(router, licenseState);
|
muteAllAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { muteAlertInstanceRoute } from './mute_instance';
|
import { muteAlertInstanceRoute } from './mute_instance';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
describe('muteAlertInstanceRoute', () => {
|
describe('muteAlertInstanceRoute', () => {
|
||||||
it('mutes an alert instance', async () => {
|
it('mutes an alert instance', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
muteAlertInstanceRoute(router, licenseState);
|
muteAlertInstanceRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { unmuteAllAlertRoute } from './unmute_all';
|
import { unmuteAllAlertRoute } from './unmute_all';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -21,7 +21,7 @@ beforeEach(() => {
|
||||||
describe('unmuteAllAlertRoute', () => {
|
describe('unmuteAllAlertRoute', () => {
|
||||||
it('unmutes an alert', async () => {
|
it('unmutes an alert', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
unmuteAllAlertRoute(router, licenseState);
|
unmuteAllAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { unmuteAlertInstanceRoute } from './unmute_instance';
|
import { unmuteAlertInstanceRoute } from './unmute_instance';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
describe('unmuteAlertInstanceRoute', () => {
|
describe('unmuteAlertInstanceRoute', () => {
|
||||||
it('unmutes an alert instance', async () => {
|
it('unmutes an alert instance', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
unmuteAlertInstanceRoute(router, licenseState);
|
unmuteAlertInstanceRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { updateAlertRoute } from './update';
|
import { updateAlertRoute } from './update';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { verifyApiAccess } from '../lib/license_api_access';
|
import { verifyApiAccess } from '../lib/license_api_access';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
|
@ -45,7 +45,7 @@ describe('updateAlertRoute', () => {
|
||||||
|
|
||||||
it('updates an alert with proper parameters', async () => {
|
it('updates an alert with proper parameters', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
updateAlertRoute(router, licenseState);
|
updateAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ describe('updateAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license allows updating alerts', async () => {
|
it('ensures the license allows updating alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
updateAlertRoute(router, licenseState);
|
updateAlertRoute(router, licenseState);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ describe('updateAlertRoute', () => {
|
||||||
|
|
||||||
it('ensures the license check prevents updating alerts', async () => {
|
it('ensures the license check prevents updating alerts', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||||
throw new Error('OMG');
|
throw new Error('OMG');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { updateApiKeyRoute } from './update_api_key';
|
import { updateApiKeyRoute } from './update_api_key';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockLicenseState } from '../lib/license_state.mock';
|
import { mockLicenseState } from '../lib/license_state.mock';
|
||||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||||
import { alertsClientMock } from '../alerts_client.mock';
|
import { alertsClientMock } from '../alerts_client.mock';
|
||||||
|
@ -22,7 +22,7 @@ beforeEach(() => {
|
||||||
describe('updateApiKeyRoute', () => {
|
describe('updateApiKeyRoute', () => {
|
||||||
it('updates api key for an alert', async () => {
|
it('updates api key for an alert', async () => {
|
||||||
const licenseState = mockLicenseState();
|
const licenseState = mockLicenseState();
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
updateApiKeyRoute(router, licenseState);
|
updateApiKeyRoute(router, licenseState);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import { IEventLogConfig } from './types';
|
import { IEventLogConfig } from './types';
|
||||||
import { EventLogService } from './event_log_service';
|
import { EventLogService } from './event_log_service';
|
||||||
import { contextMock } from './es/context.mock';
|
import { contextMock } from './es/context.mock';
|
||||||
import { loggingServiceMock } from '../../../../src/core/server/logging/logging_service.mock';
|
import { loggingServiceMock } from 'src/core/server/mocks';
|
||||||
|
|
||||||
const loggingService = loggingServiceMock.create();
|
const loggingService = loggingServiceMock.create();
|
||||||
const systemLogger = loggingService.get();
|
const systemLogger = loggingService.get();
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
import { EventLogClientService } from './event_log_start_service';
|
import { EventLogClientService } from './event_log_start_service';
|
||||||
import { contextMock } from './es/context.mock';
|
import { contextMock } from './es/context.mock';
|
||||||
import { KibanaRequest } from 'kibana/server';
|
import { KibanaRequest } from 'kibana/server';
|
||||||
import { savedObjectsServiceMock } from 'src/core/server/saved_objects/saved_objects_service.mock';
|
import { savedObjectsClientMock, savedObjectsServiceMock } from 'src/core/server/mocks';
|
||||||
import { savedObjectsClientMock } from 'src/core/server/mocks';
|
|
||||||
|
|
||||||
jest.mock('./event_log_client');
|
jest.mock('./event_log_client');
|
||||||
|
|
||||||
|
|
|
@ -9,20 +9,20 @@ import { ECS_VERSION } from './types';
|
||||||
import { EventLogService } from './event_log_service';
|
import { EventLogService } from './event_log_service';
|
||||||
import { EsContext } from './es/context';
|
import { EsContext } from './es/context';
|
||||||
import { contextMock } from './es/context.mock';
|
import { contextMock } from './es/context.mock';
|
||||||
import { loggerMock, MockedLogger } from '../../../../src/core/server/logging/logger.mock';
|
import { loggingServiceMock } from 'src/core/server/mocks';
|
||||||
import { delay } from './lib/delay';
|
import { delay } from './lib/delay';
|
||||||
import { EVENT_LOGGED_PREFIX } from './event_logger';
|
import { EVENT_LOGGED_PREFIX } from './event_logger';
|
||||||
|
|
||||||
const KIBANA_SERVER_UUID = '424-24-2424';
|
const KIBANA_SERVER_UUID = '424-24-2424';
|
||||||
|
|
||||||
describe('EventLogger', () => {
|
describe('EventLogger', () => {
|
||||||
let systemLogger: MockedLogger;
|
let systemLogger: ReturnType<typeof loggingServiceMock.createLogger>;
|
||||||
let esContext: EsContext;
|
let esContext: EsContext;
|
||||||
let service: IEventLogService;
|
let service: IEventLogService;
|
||||||
let eventLogger: IEventLogger;
|
let eventLogger: IEventLogger;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
systemLogger = loggerMock.create();
|
systemLogger = loggingServiceMock.createLogger();
|
||||||
esContext = contextMock.create();
|
esContext = contextMock.create();
|
||||||
service = new EventLogService({
|
service = new EventLogService({
|
||||||
esContext,
|
esContext,
|
||||||
|
@ -153,7 +153,10 @@ describe('EventLogger', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// return the next logged event; throw if not an event
|
// return the next logged event; throw if not an event
|
||||||
async function waitForLogEvent(mockLogger: MockedLogger, waitSeconds: number = 1): Promise<IEvent> {
|
async function waitForLogEvent(
|
||||||
|
mockLogger: ReturnType<typeof loggingServiceMock.createLogger>,
|
||||||
|
waitSeconds: number = 1
|
||||||
|
): Promise<IEvent> {
|
||||||
const result = await waitForLog(mockLogger, waitSeconds);
|
const result = await waitForLog(mockLogger, waitSeconds);
|
||||||
if (typeof result === 'string') throw new Error('expecting an event');
|
if (typeof result === 'string') throw new Error('expecting an event');
|
||||||
return result;
|
return result;
|
||||||
|
@ -161,7 +164,7 @@ async function waitForLogEvent(mockLogger: MockedLogger, waitSeconds: number = 1
|
||||||
|
|
||||||
// return the next logged message; throw if it is an event
|
// return the next logged message; throw if it is an event
|
||||||
async function waitForLogMessage(
|
async function waitForLogMessage(
|
||||||
mockLogger: MockedLogger,
|
mockLogger: ReturnType<typeof loggingServiceMock.createLogger>,
|
||||||
waitSeconds: number = 1
|
waitSeconds: number = 1
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const result = await waitForLog(mockLogger, waitSeconds);
|
const result = await waitForLog(mockLogger, waitSeconds);
|
||||||
|
@ -171,7 +174,7 @@ async function waitForLogMessage(
|
||||||
|
|
||||||
// return the next logged message, if it's an event log entry, parse it
|
// return the next logged message, if it's an event log entry, parse it
|
||||||
async function waitForLog(
|
async function waitForLog(
|
||||||
mockLogger: MockedLogger,
|
mockLogger: ReturnType<typeof loggingServiceMock.createLogger>,
|
||||||
waitSeconds: number = 1
|
waitSeconds: number = 1
|
||||||
): Promise<string | IEvent> {
|
): Promise<string | IEvent> {
|
||||||
const intervals = 4;
|
const intervals = 4;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createBoundedQueue } from './bounded_queue';
|
import { createBoundedQueue } from './bounded_queue';
|
||||||
import { loggingServiceMock } from '../../../../../src/core/server/logging/logging_service.mock';
|
import { loggingServiceMock } from 'src/core/server/mocks';
|
||||||
|
|
||||||
const loggingService = loggingServiceMock.create();
|
const loggingService = loggingServiceMock.create();
|
||||||
const logger = loggingService.get();
|
const logger = loggingService.get();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findRoute } from './find';
|
import { findRoute } from './find';
|
||||||
import { mockRouter, RouterMock } from '../../../../../src/core/server/http/router/router.mock';
|
import { httpServiceMock } from 'src/core/server/mocks';
|
||||||
import { mockHandlerArguments, fakeEvent } from './_mock_handler_arguments';
|
import { mockHandlerArguments, fakeEvent } from './_mock_handler_arguments';
|
||||||
import { eventLogClientMock } from '../event_log_client.mock';
|
import { eventLogClientMock } from '../event_log_client.mock';
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('find', () => {
|
describe('find', () => {
|
||||||
it('finds events with proper parameters', async () => {
|
it('finds events with proper parameters', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
findRoute(router);
|
findRoute(router);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe('find', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports optional pagination parameters', async () => {
|
it('supports optional pagination parameters', async () => {
|
||||||
const router: RouterMock = mockRouter.create();
|
const router = httpServiceMock.createRouter();
|
||||||
|
|
||||||
findRoute(router);
|
findRoute(router);
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@ import {
|
||||||
RequestHandlerContext,
|
RequestHandlerContext,
|
||||||
SavedObjectsClientContract,
|
SavedObjectsClientContract,
|
||||||
} from 'kibana/server';
|
} from 'kibana/server';
|
||||||
import { savedObjectsClientMock } from '../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock';
|
import { savedObjectsClientMock, httpServerMock } from 'src/core/server/mocks';
|
||||||
import { httpServerMock } from '../../../../../../src/core/server/http/http_server.mocks';
|
|
||||||
import { ActionsService } from '../../services/agents';
|
import { ActionsService } from '../../services/agents';
|
||||||
import { AgentAction } from '../../../common/types/models';
|
import { AgentAction } from '../../../common/types/models';
|
||||||
import { postNewAgentActionHandlerBuilder } from './actions_handlers';
|
import { postNewAgentActionHandlerBuilder } from './actions_handlers';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import Boom from 'boom';
|
import Boom from 'boom';
|
||||||
import { SavedObjectsBulkResponse } from 'kibana/server';
|
import { SavedObjectsBulkResponse } from 'kibana/server';
|
||||||
import { savedObjectsClientMock } from '../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock';
|
import { savedObjectsClientMock } from 'src/core/server/mocks';
|
||||||
import { encryptedSavedObjectsMock } from '../../../../../plugins/encrypted_saved_objects/server/mocks';
|
import { encryptedSavedObjectsMock } from '../../../../../plugins/encrypted_saved_objects/server/mocks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import { createAgentAction } from './actions';
|
import { createAgentAction } from './actions';
|
||||||
import { SavedObject } from 'kibana/server';
|
import { SavedObject } from 'kibana/server';
|
||||||
import { AgentAction } from '../../../common/types/models';
|
import { AgentAction } from '../../../common/types/models';
|
||||||
import { savedObjectsClientMock } from '../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock';
|
import { savedObjectsClientMock } from 'src/core/server/mocks';
|
||||||
|
|
||||||
describe('test agent actions services', () => {
|
describe('test agent actions services', () => {
|
||||||
it('should create a new action', async () => {
|
it('should create a new action', async () => {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { savedObjectsClientMock } from '../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock';
|
import { savedObjectsClientMock } from 'src/core/server/mocks';
|
||||||
import { getAgentStatusById } from './status';
|
import { getAgentStatusById } from './status';
|
||||||
import { AGENT_TYPE_PERMANENT } from '../../../common/constants';
|
import { AGENT_TYPE_PERMANENT } from '../../../common/constants';
|
||||||
import { AgentSOAttributes } from '../../../common/types/models';
|
import { AgentSOAttributes } from '../../../common/types/models';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { httpServerMock } from '../../../../../src/core/server/http/http_server.mocks';
|
import { httpServerMock } from 'src/core/server/mocks';
|
||||||
|
|
||||||
import { canRedirectRequest } from './can_redirect_request';
|
import { canRedirectRequest } from './can_redirect_request';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loggerMock } from 'src/core/server/logging/logger.mock';
|
import { loggingServiceMock } from 'src/core/server/mocks';
|
||||||
import { getResult } from '../routes/__mocks__/request_responses';
|
import { getResult } from '../routes/__mocks__/request_responses';
|
||||||
import { rulesNotificationAlertType } from './rules_notification_alert_type';
|
import { rulesNotificationAlertType } from './rules_notification_alert_type';
|
||||||
import { buildSignalsSearchQuery } from './build_signals_query';
|
import { buildSignalsSearchQuery } from './build_signals_query';
|
||||||
|
@ -15,12 +15,12 @@ jest.mock('./build_signals_query');
|
||||||
describe('rules_notification_alert_type', () => {
|
describe('rules_notification_alert_type', () => {
|
||||||
let payload: NotificationExecutorOptions;
|
let payload: NotificationExecutorOptions;
|
||||||
let alert: ReturnType<typeof rulesNotificationAlertType>;
|
let alert: ReturnType<typeof rulesNotificationAlertType>;
|
||||||
let logger: ReturnType<typeof loggerMock.create>;
|
let logger: ReturnType<typeof loggingServiceMock.createLogger>;
|
||||||
let alertServices: AlertServicesMock;
|
let alertServices: AlertServicesMock;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alertServices = alertsMock.createAlertServices();
|
alertServices = alertsMock.createAlertServices();
|
||||||
logger = loggerMock.create();
|
logger = loggingServiceMock.createLogger();
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
alertId: '1111',
|
alertId: '1111',
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loggerMock } from 'src/core/server/logging/logger.mock';
|
import { loggingServiceMock } from 'src/core/server/mocks';
|
||||||
import { getNotificationResult, getResult } from '../routes/__mocks__/request_responses';
|
import { getNotificationResult, getResult } from '../routes/__mocks__/request_responses';
|
||||||
import { isAlertTypes, isNotificationAlertExecutor } from './types';
|
import { isAlertTypes, isNotificationAlertExecutor } from './types';
|
||||||
import { rulesNotificationAlertType } from './rules_notification_alert_type';
|
import { rulesNotificationAlertType } from './rules_notification_alert_type';
|
||||||
|
@ -20,7 +20,9 @@ describe('types', () => {
|
||||||
|
|
||||||
it('isNotificationAlertExecutor should return true it passed object is NotificationAlertTypeDefinition type', () => {
|
it('isNotificationAlertExecutor should return true it passed object is NotificationAlertTypeDefinition type', () => {
|
||||||
expect(
|
expect(
|
||||||
isNotificationAlertExecutor(rulesNotificationAlertType({ logger: loggerMock.create() }))
|
isNotificationAlertExecutor(
|
||||||
|
rulesNotificationAlertType({ logger: loggingServiceMock.createLogger() })
|
||||||
|
)
|
||||||
).toEqual(true);
|
).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { loggerMock } from 'src/core/server/logging/logger.mock';
|
import { loggingServiceMock } from 'src/core/server/mocks';
|
||||||
import { getResult, getMlResult } from '../routes/__mocks__/request_responses';
|
import { getResult, getMlResult } from '../routes/__mocks__/request_responses';
|
||||||
import { signalRulesAlertType } from './signal_rule_alert_type';
|
import { signalRulesAlertType } from './signal_rule_alert_type';
|
||||||
import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks';
|
import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks';
|
||||||
|
@ -70,13 +70,13 @@ describe('rules_notification_alert_type', () => {
|
||||||
};
|
};
|
||||||
let payload: jest.Mocked<RuleExecutorOptions>;
|
let payload: jest.Mocked<RuleExecutorOptions>;
|
||||||
let alert: ReturnType<typeof signalRulesAlertType>;
|
let alert: ReturnType<typeof signalRulesAlertType>;
|
||||||
let logger: ReturnType<typeof loggerMock.create>;
|
let logger: ReturnType<typeof loggingServiceMock.createLogger>;
|
||||||
let alertServices: AlertServicesMock;
|
let alertServices: AlertServicesMock;
|
||||||
let ruleStatusService: Record<string, jest.Mock>;
|
let ruleStatusService: Record<string, jest.Mock>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alertServices = alertsMock.createAlertServices();
|
alertServices = alertsMock.createAlertServices();
|
||||||
logger = loggerMock.create();
|
logger = loggingServiceMock.createLogger();
|
||||||
ruleStatusService = {
|
ruleStatusService = {
|
||||||
success: jest.fn(),
|
success: jest.fn(),
|
||||||
find: jest.fn(),
|
find: jest.fn(),
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { buildRouteValidation } from './route_validation';
|
import { buildRouteValidation } from './route_validation';
|
||||||
import * as rt from 'io-ts';
|
import * as rt from 'io-ts';
|
||||||
import { RouteValidationResultFactory } from '../../../../../../src/core/server/http';
|
import { RouteValidationResultFactory } from 'src/core/server';
|
||||||
|
|
||||||
describe('buildRouteValidation', () => {
|
describe('buildRouteValidation', () => {
|
||||||
const schema = rt.exact(
|
const schema = rt.exact(
|
||||||
|
|
|
@ -17,9 +17,12 @@ import {
|
||||||
TaskLifecycleResult,
|
TaskLifecycleResult,
|
||||||
} from './task';
|
} from './task';
|
||||||
import { StoreOpts, OwnershipClaimingOpts, TaskStore, SearchOpts } from './task_store';
|
import { StoreOpts, OwnershipClaimingOpts, TaskStore, SearchOpts } from './task_store';
|
||||||
import { savedObjectsRepositoryMock } from '../../../../src/core/server/mocks';
|
import { savedObjectsRepositoryMock } from 'src/core/server/mocks';
|
||||||
import { SavedObjectsSerializer, SavedObjectTypeRegistry } from '../../../../src/core/server';
|
import {
|
||||||
import { SavedObjectsErrorHelpers } from '../../../../src/core/server/saved_objects/service/lib/errors';
|
SavedObjectsSerializer,
|
||||||
|
SavedObjectTypeRegistry,
|
||||||
|
SavedObjectsErrorHelpers,
|
||||||
|
} from 'src/core/server';
|
||||||
import { asTaskClaimEvent, TaskEvent } from './task_events';
|
import { asTaskClaimEvent, TaskEvent } from './task_events';
|
||||||
import { asOk, asErr } from './lib/result_type';
|
import { asOk, asErr } from './lib/result_type';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { ReindexStatus, ReindexStep } from '../../../../../../../common/types';
|
import { ReindexStatus, ReindexStep } from '../../../../../../../common/types';
|
||||||
import { ReindexPollingService } from './polling_service';
|
import { ReindexPollingService } from './polling_service';
|
||||||
import { httpServiceMock } from 'src/core/public/http/http_service.mock';
|
import { httpServiceMock } from 'src/core/public/mocks';
|
||||||
|
|
||||||
const mockClient = httpServiceMock.createSetupContract();
|
const mockClient = httpServiceMock.createSetupContract();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { kibanaResponseFactory } from 'src/core/server';
|
import { kibanaResponseFactory } from 'src/core/server';
|
||||||
import { savedObjectsServiceMock } from 'src/core/server/saved_objects/saved_objects_service.mock';
|
import { savedObjectsServiceMock } from 'src/core/server/mocks';
|
||||||
import { createMockRouter, MockRouter, routeHandlerContextMock } from './__mocks__/routes.mock';
|
import { createMockRouter, MockRouter, routeHandlerContextMock } from './__mocks__/routes.mock';
|
||||||
import { createRequestMock } from './__mocks__/request.mock';
|
import { createRequestMock } from './__mocks__/request.mock';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { elasticsearchServiceMock } from '../../../../../../../src/core/server/mocks';
|
import { elasticsearchServiceMock } from '../../../../../../../src/core/server/mocks';
|
||||||
import { getMonitorStatus } from '../get_monitor_status';
|
import { getMonitorStatus } from '../get_monitor_status';
|
||||||
import { ScopedClusterClient } from 'src/core/server/elasticsearch';
|
import { ScopedClusterClient } from 'src/core/server';
|
||||||
import { defaultDynamicSettings } from '../../../../../../legacy/plugins/uptime/common/runtime_types';
|
import { defaultDynamicSettings } from '../../../../../../legacy/plugins/uptime/common/runtime_types';
|
||||||
|
|
||||||
interface BucketItemCriteria {
|
interface BucketItemCriteria {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue