Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 198994-migrate-time_range_metadata-test
Browse files Browse the repository at this point in the history
elasticmachine authored Nov 14, 2024

Verified

This commit was signed with the committer’s verified signature.
bukka Jakub Zelenka
2 parents 2fea0f9 + 75679b2 commit 58e6203
Showing 102 changed files with 3,071 additions and 2,272 deletions.
46 changes: 45 additions & 1 deletion oas_docs/bundle.json
Original file line number Diff line number Diff line change
@@ -16951,6 +16951,49 @@
},
"type": "array"
},
"list": {
"deprecated": true,
"items": {
"additionalProperties": false,
"properties": {
"active": {
"description": "When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents.",
"type": "boolean"
},
"api_key": {
"description": "The enrollment API key (token) used for enrolling Elastic Agents.",
"type": "string"
},
"api_key_id": {
"description": "The ID of the API key in the Security API.",
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"description": "The name of the enrollment API key.",
"type": "string"
},
"policy_id": {
"description": "The ID of the agent policy the Elastic Agent will be enrolled in.",
"type": "string"
}
},
"required": [
"id",
"api_key_id",
"api_key",
"active",
"created_at"
],
"type": "object"
},
"type": "array"
},
"page": {
"type": "number"
},
@@ -16965,7 +17008,8 @@
"items",
"total",
"page",
"perPage"
"perPage",
"list"
],
"type": "object"
}
46 changes: 45 additions & 1 deletion oas_docs/bundle.serverless.json
Original file line number Diff line number Diff line change
@@ -16951,6 +16951,49 @@
},
"type": "array"
},
"list": {
"deprecated": true,
"items": {
"additionalProperties": false,
"properties": {
"active": {
"description": "When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents.",
"type": "boolean"
},
"api_key": {
"description": "The enrollment API key (token) used for enrolling Elastic Agents.",
"type": "string"
},
"api_key_id": {
"description": "The ID of the API key in the Security API.",
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"description": "The name of the enrollment API key.",
"type": "string"
},
"policy_id": {
"description": "The ID of the agent policy the Elastic Agent will be enrolled in.",
"type": "string"
}
},
"required": [
"id",
"api_key_id",
"api_key",
"active",
"created_at"
],
"type": "object"
},
"type": "array"
},
"page": {
"type": "number"
},
@@ -16965,7 +17008,8 @@
"items",
"total",
"page",
"perPage"
"perPage",
"list"
],
"type": "object"
}
39 changes: 39 additions & 0 deletions oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
@@ -16686,6 +16686,44 @@ paths:
- active
- created_at
type: array
list:
deprecated: true
items:
additionalProperties: false
type: object
properties:
active:
description: >-
When false, the enrollment API key is revoked and
cannot be used for enrolling Elastic Agents.
type: boolean
api_key:
description: >-
The enrollment API key (token) used for enrolling
Elastic Agents.
type: string
api_key_id:
description: The ID of the API key in the Security API.
type: string
created_at:
type: string
id:
type: string
name:
description: The name of the enrollment API key.
type: string
policy_id:
description: >-
The ID of the agent policy the Elastic Agent will be
enrolled in.
type: string
required:
- id
- api_key_id
- api_key
- active
- created_at
type: array
page:
type: number
perPage:
@@ -16697,6 +16735,7 @@ paths:
- total
- page
- perPage
- list
'400':
content:
application/json; Elastic-Api-Version=2023-10-31:
39 changes: 39 additions & 0 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
@@ -19470,6 +19470,44 @@ paths:
- active
- created_at
type: array
list:
deprecated: true
items:
additionalProperties: false
type: object
properties:
active:
description: >-
When false, the enrollment API key is revoked and
cannot be used for enrolling Elastic Agents.
type: boolean
api_key:
description: >-
The enrollment API key (token) used for enrolling
Elastic Agents.
type: string
api_key_id:
description: The ID of the API key in the Security API.
type: string
created_at:
type: string
id:
type: string
name:
description: The name of the enrollment API key.
type: string
policy_id:
description: >-
The ID of the agent policy the Elastic Agent will be
enrolled in.
type: string
required:
- id
- api_key_id
- api_key
- active
- created_at
type: array
page:
type: number
perPage:
@@ -19481,6 +19519,7 @@ paths:
- total
- page
- perPage
- list
'400':
content:
application/json; Elastic-Api-Version=2023-10-31:
Original file line number Diff line number Diff line change
@@ -26,14 +26,14 @@ import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks';
import { customBrandingServiceMock } from '@kbn/core-custom-branding-browser-mocks';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { MockLifecycle } from './test_helpers/test_types';
import type { MockLifecycle } from './test_helpers/test_types';
import { ApplicationService } from './application_service';
import {
App,
AppDeepLink,
type App,
type AppDeepLink,
AppStatus,
AppUpdater,
PublicAppInfo,
type AppUpdater,
type PublicAppInfo,
} from '@kbn/core-application-browser';
import { act } from 'react-dom/test-utils';
import { DEFAULT_APP_VISIBILITY } from './utils';
@@ -618,6 +618,26 @@ describe('#start()', () => {
});
});

describe('isAppRegistered', () => {
let isAppRegistered: any;
beforeEach(async () => {
const { register } = service.setup(setupDeps);
register(Symbol(), createApp({ id: 'one_app' }));
register(Symbol(), createApp({ id: 'another_app', appRoute: '/custom/path' }));

const start = await service.start(startDeps);
isAppRegistered = start.isAppRegistered;
});

it('returns false for unregistered apps', () => {
expect(isAppRegistered('oneApp')).toEqual(false);
});

it('returns true for registered apps', () => {
expect(isAppRegistered('another_app')).toEqual(true);
});
});

describe('getUrlForApp', () => {
it('creates URL for unregistered appId', async () => {
service.setup(setupDeps);
Original file line number Diff line number Diff line change
@@ -327,6 +327,9 @@ export class ApplicationService {
takeUntil(this.stop$)
),
history: this.history!,
isAppRegistered: (appId: string): boolean => {
return applications$.value.get(appId) !== undefined;
},
getUrlForApp: (
appId,
{
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ const createStartContractMock = (): jest.Mocked<ApplicationStart> => {
navigateToApp: jest.fn(),
navigateToUrl: jest.fn(),
getUrlForApp: jest.fn(),
isAppRegistered: jest.fn(),
};
};

@@ -92,6 +93,7 @@ const createInternalStartContractMock = (
currentActionMenu$: new BehaviorSubject<MountPoint | undefined>(undefined),
getComponent: jest.fn(),
getUrlForApp: jest.fn(),
isAppRegistered: jest.fn(),
navigateToApp: jest.fn().mockImplementation((appId) => currentAppId$.next(appId)),
navigateToUrl: jest.fn(),
history: createHistoryMock(),
Original file line number Diff line number Diff line change
@@ -68,9 +68,12 @@ export interface ApplicationStart {
applications$: Observable<ReadonlyMap<string, PublicAppInfo>>;

/**
* Navigate to a given app
* Navigate to a given app.
* If a plugin is disabled any applications it registers won't be available either.
* Before rendering a UI element that a user could use to navigate to another application,
* first check if the destination application is actually available using the isAppRegistered API.
*
* @param appId
* @param appId - The identifier of the app to navigate to
* @param options - navigation options
*/
navigateToApp(appId: string, options?: NavigateToAppOptions): Promise<void>;
@@ -114,6 +117,14 @@ export interface ApplicationStart {
*/
navigateToUrl(url: string, options?: NavigateToUrlOptions): Promise<void>;

/**
* Checks whether a given application is registered.
*
* @param appId - The identifier of the app to check
* @returns true if the given appId is registered in the system, false otherwise.
*/
isAppRegistered(appId: string): boolean;

/**
* Returns the absolute path (or URL) to a given app, including the global base path.
*
Original file line number Diff line number Diff line change
@@ -143,6 +143,7 @@ export function createPluginStartContext<
navigateToApp: deps.application.navigateToApp,
navigateToUrl: deps.application.navigateToUrl,
getUrlForApp: deps.application.getUrlForApp,
isAppRegistered: deps.application.isAppRegistered,
currentLocation$: deps.application.currentLocation$,
},
customBranding: deps.customBranding,
1 change: 1 addition & 0 deletions src/plugins/discover/public/__mocks__/start_contract.ts
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ export const createStartContractMock = (): jest.Mocked<ApplicationStart> => {
capabilities,
navigateToApp: jest.fn(),
navigateToUrl: jest.fn(),
isAppRegistered: jest.fn(),
getUrlForApp: jest.fn(),
};
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58e6203

Please sign in to comment.