mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
chore(NA): avoids imports of server or public code into common (#67231)
* chore(NA): avoids imports of server or public code into common * chore(NA): fix imports from public or server into common * chore(NA): fix typechecking for data plugin stubs * chore(NA): fix types and tests related with licensing plugin * chore(NA): fix problems on infra plugin * chore(NA): fix typo on .eslintrc.js Co-authored-by: Ryland Herrick <ryalnd@gmail.com> * chore(NA): migrate to license mock usage on security plugin licensing module Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Ryland Herrick <ryalnd@gmail.com>
This commit is contained in:
parent
c4d2ba306c
commit
20d60829b3
20 changed files with 55 additions and 29 deletions
|
@ -202,6 +202,11 @@ module.exports = {
|
|||
from: ['(src|x-pack)/plugins/*/server/**/*'],
|
||||
errorMessage: `Public code can not import from server, use a common directory.`,
|
||||
},
|
||||
{
|
||||
target: ['(src|x-pack)/plugins/*/common/**/*'],
|
||||
from: ['(src|x-pack)/plugins/*/(server|public)/**/*'],
|
||||
errorMessage: `Common code can not import from server or public, use a common directory.`,
|
||||
},
|
||||
{
|
||||
target: [
|
||||
'(src|x-pack)/legacy/**/*',
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { buildFilter, FilterStateStore, FILTERS } from '.';
|
||||
import { stubIndexPattern, stubFields } from '../../../public/stubs';
|
||||
import { stubIndexPattern, stubFields } from '../../../common/stubs';
|
||||
|
||||
describe('buildFilter', () => {
|
||||
it('should build phrase filters', () => {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { stubIndexPattern, phraseFilter } from 'src/plugins/data/public/stubs';
|
||||
import { stubIndexPattern, phraseFilter } from 'src/plugins/data/common/stubs';
|
||||
import { getIndexPatternFromFilter } from './get_index_pattern_from_filter';
|
||||
|
||||
describe('getIndexPatternFromFilter', () => {
|
||||
|
|
|
@ -24,7 +24,7 @@ import { IIndexPattern } from '../../../index_patterns/types';
|
|||
|
||||
// @ts-ignore
|
||||
import { parse as parseKuery } from './_generated_/kuery';
|
||||
import { JsonObject } from '../../../../../kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../kibana_utils/common';
|
||||
|
||||
const fromExpression = (
|
||||
expression: string | DslQuery,
|
||||
|
|
|
@ -21,7 +21,7 @@ import _ from 'lodash';
|
|||
import * as ast from '../ast';
|
||||
import { nodeTypes } from '../node_types';
|
||||
import { NamedArgTypeBuildNode } from './types';
|
||||
import { JsonObject } from '../../../../../kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../kibana_utils/common';
|
||||
|
||||
export function buildNode(name: string, value: any): NamedArgTypeBuildNode {
|
||||
const argumentNode =
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
import { IIndexPattern } from '../../../index_patterns';
|
||||
import { JsonValue } from '../../../../../kibana_utils/public';
|
||||
import { JsonValue } from '../../../../../kibana_utils/common';
|
||||
import { KueryNode } from '..';
|
||||
|
||||
export type FunctionName =
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { IFieldType } from '../../../../plugins/data/public';
|
||||
import { IFieldType } from '.';
|
||||
|
||||
export const stubFields: IFieldType[] = [
|
||||
{
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { IIndexPattern } from '../../common';
|
||||
import { IIndexPattern } from '.';
|
||||
import { stubFields } from './field.stub';
|
||||
|
||||
export const stubIndexPattern: IIndexPattern = {
|
22
src/plugins/data/common/stubs.ts
Normal file
22
src/plugins/data/common/stubs.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { stubIndexPattern, stubIndexPatternWithFields } from './index_patterns/index_pattern.stub';
|
||||
export { stubFields } from './index_patterns/field.stub';
|
||||
export * from './es_query/filters/stubs';
|
|
@ -17,6 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { stubIndexPattern, stubIndexPatternWithFields } from './index_patterns/index_pattern.stub';
|
||||
export { stubFields } from './index_patterns/field.stub';
|
||||
export * from '../common/es_query/filters/stubs';
|
||||
export * from '../common/stubs';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { ExpressionValue, ExpressionValueError } from '../expression_types';
|
||||
import { ExpressionFunction } from '../../public';
|
||||
import { ExpressionFunction } from '../../common';
|
||||
|
||||
export type ExpressionAstNode =
|
||||
| ExpressionAstExpression
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import { Execution } from './execution';
|
||||
import { parseExpression, ExpressionAstExpression } from '../ast';
|
||||
import { createUnitTestExecutor } from '../test_helpers';
|
||||
import { ExpressionFunctionDefinition } from '../../public';
|
||||
import { ExpressionFunctionDefinition } from '../../common';
|
||||
import { ExecutionContract } from './execution_contract';
|
||||
|
||||
beforeAll(() => {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { ExpressionValueError } from '../../public';
|
||||
import { ExpressionValueError } from '../../common';
|
||||
|
||||
type ErrorLike = Partial<Pick<Error, 'name' | 'message' | 'stack'>>;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import cytoscape from 'cytoscape';
|
||||
import { ILicense } from '../../licensing/public';
|
||||
import { ILicense } from '../../licensing/common/types';
|
||||
import {
|
||||
AGENT_NAME,
|
||||
SERVICE_ENVIRONMENT,
|
||||
|
|
|
@ -8,6 +8,7 @@ import React, { useMemo } from 'react';
|
|||
import { EuiFlexItem } from '@elastic/eui';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { WaffleSortControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/waffle_sort_controls';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { ToolbarProps } from '../../../../public/pages/metrics/inventory_view/components/toolbars/toolbar';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { WaffleMetricControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/metric_control';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { RENDER_AS, SORT_ORDER, SCALING_TYPES } from '../constants';
|
||||
import { MapExtent, MapQuery } from './map_descriptor';
|
||||
import { Filter, TimeRange } from '../../../../../src/plugins/data/public';
|
||||
import { Filter, TimeRange } from '../../../../../src/plugins/data/common';
|
||||
|
||||
// Global map state passed to every layer.
|
||||
export type MapFilters = {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
||||
|
||||
import { Query } from '../../../../../src/plugins/data/public';
|
||||
import { Query } from '../../../../../src/plugins/data/common';
|
||||
import { DRAW_TYPE, ES_GEO_FIELD_TYPE, ES_SPATIAL_RELATIONS } from '../constants';
|
||||
|
||||
export type MapExtent = {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { of, BehaviorSubject } from 'rxjs';
|
||||
import { licensingMock } from '../../../licensing/public/mocks';
|
||||
import { licenseMock } from '../../../licensing/common/licensing.mock';
|
||||
import { SecurityLicenseService } from './license_service';
|
||||
|
||||
describe('license features', function () {
|
||||
|
@ -29,7 +29,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should display error when X-Pack is unavailable', () => {
|
||||
const rawLicenseMock = licensingMock.createLicenseMock();
|
||||
const rawLicenseMock = licenseMock.createLicenseMock();
|
||||
rawLicenseMock.isAvailable = false;
|
||||
const serviceSetup = new SecurityLicenseService().setup({
|
||||
license$: of(rawLicenseMock),
|
||||
|
@ -50,7 +50,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should notify consumers of licensed feature changes', () => {
|
||||
const rawLicenseMock = licensingMock.createLicenseMock();
|
||||
const rawLicenseMock = licenseMock.createLicenseMock();
|
||||
rawLicenseMock.isAvailable = false;
|
||||
const rawLicense$ = new BehaviorSubject(rawLicenseMock);
|
||||
const serviceSetup = new SecurityLicenseService().setup({
|
||||
|
@ -79,7 +79,7 @@ describe('license features', function () {
|
|||
]
|
||||
`);
|
||||
|
||||
rawLicense$.next(licensingMock.createLicenseMock());
|
||||
rawLicense$.next(licenseMock.createLicenseMock());
|
||||
expect(subscriptionHandler).toHaveBeenCalledTimes(2);
|
||||
expect(subscriptionHandler.mock.calls[1]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
|
@ -103,7 +103,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should show login page and other security elements, allow RBAC but forbid paid features if license is basic.', () => {
|
||||
const mockRawLicense = licensingMock.createLicense({
|
||||
const mockRawLicense = licenseMock.createLicense({
|
||||
features: { security: { isEnabled: true, isAvailable: true } },
|
||||
});
|
||||
|
||||
|
@ -129,7 +129,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should not show login page or other security elements if security is disabled in Elasticsearch.', () => {
|
||||
const mockRawLicense = licensingMock.createLicense({
|
||||
const mockRawLicense = licenseMock.createLicense({
|
||||
features: { security: { isEnabled: false, isAvailable: true } },
|
||||
});
|
||||
|
||||
|
@ -151,7 +151,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should allow role mappings, access agreement and sub-feature privileges, but not DLS/FLS if license = gold', () => {
|
||||
const mockRawLicense = licensingMock.createLicense({
|
||||
const mockRawLicense = licenseMock.createLicense({
|
||||
license: { mode: 'gold', type: 'gold' },
|
||||
features: { security: { isEnabled: true, isAvailable: true } },
|
||||
});
|
||||
|
@ -174,7 +174,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should allow to login, allow RBAC, role mappings, access agreement, sub-feature privileges, and DLS if license >= platinum', () => {
|
||||
const mockRawLicense = licensingMock.createLicense({
|
||||
const mockRawLicense = licenseMock.createLicense({
|
||||
license: { mode: 'platinum', type: 'platinum' },
|
||||
features: { security: { isEnabled: true, isAvailable: true } },
|
||||
});
|
||||
|
@ -197,7 +197,7 @@ describe('license features', function () {
|
|||
});
|
||||
|
||||
it('should allow all basic features + audit logging for standard license', () => {
|
||||
const mockRawLicense = licensingMock.createLicense({
|
||||
const mockRawLicense = licenseMock.createLicense({
|
||||
license: { mode: 'standard', type: 'standard' },
|
||||
features: { security: { isEnabled: true, isAvailable: true } },
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { JsonObject } from '../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../src/plugins/kibana_utils/common';
|
||||
|
||||
export type ESQuery = ESRangeQuery | ESQueryStringQuery | ESMatchQuery | ESTermQuery | JsonObject;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { of } from 'rxjs';
|
||||
import { licensingMock } from '../../../licensing/public/mocks';
|
||||
import { licenseMock } from '../../../licensing/common/licensing.mock';
|
||||
import { SpacesLicenseService } from './license_service';
|
||||
import { LICENSE_TYPE, LicenseType } from '../../../licensing/common/types';
|
||||
|
||||
|
@ -18,7 +18,7 @@ describe('license#isEnabled', function () {
|
|||
});
|
||||
|
||||
it('should indicate that Spaces is disabled when xpack is unavailable', () => {
|
||||
const rawLicenseMock = licensingMock.createLicenseMock();
|
||||
const rawLicenseMock = licenseMock.createLicenseMock();
|
||||
rawLicenseMock.isAvailable = false;
|
||||
const serviceSetup = new SpacesLicenseService().setup({
|
||||
license$: of(rawLicenseMock),
|
||||
|
@ -29,7 +29,7 @@ describe('license#isEnabled', function () {
|
|||
for (const level in LICENSE_TYPE) {
|
||||
if (isNaN(level as any)) {
|
||||
it(`should indicate that Spaces is enabled with a ${level} license`, () => {
|
||||
const rawLicense = licensingMock.createLicense({
|
||||
const rawLicense = licenseMock.createLicense({
|
||||
license: {
|
||||
status: 'active',
|
||||
type: level as LicenseType,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue