Skip to content

Commit

Permalink
Merge branch 'main' into assign-security-solution
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 14, 2024
2 parents 6c0d912 + 1454a75 commit 3e598c7
Show file tree
Hide file tree
Showing 35 changed files with 511 additions and 154 deletions.
90 changes: 89 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,90 @@ x-pack/test_serverless/**/test_suites/observability/ai_assistant @elastic/obs-ai
/.eslintrc.js @elastic/kibana-operations
/.eslintignore @elastic/kibana-operations

# Appex QA
# QA - Appex QA
/test/server_integration/services/index.js @elastic/appex-qa
/x-pack/test/stack_functional_integration/configs/config.stack_functional_integration_base.js @elastic/appex-qa
/x-pack/test/stack_functional_integration/configs/consume_state.js @elastic/appex-qa
/x-pack/test/functional/services/remote_es/remote_es_archiver.ts @elastic/appex-qa
/test/functional/services/remote_es/remote_es_archiver.ts @elastic/appex-qa
/x-pack/test/kibana.jsonc @elastic/appex-qa
/x-pack/test/functional_with_es_ssl/ftr_provider_context.d.ts @elastic/appex-qa
/x-pack/test/stack_functional_integration/apps @elastic/appex-qa
/x-pack/test/plugin_functional/config.ts @elastic/appex-qa
/x-pack/test/plugin_functional/ftr_provider_context.d.ts @elastic/appex-qa
/x-pack/test/plugin_functional/page_objects.ts @elastic/appex-qa
/x-pack/test/upgrade/services/index.ts @elastic/appex-qa
/x-pack/test/upgrade/ftr_provider_context.d.ts @elastic/appex-qa
/x-pack/test/upgrade/config.ts @elastic/appex-qa
/x-pack/test/functional_basic/ftr_provider_context.d.ts @elastic/appex-qa
/x-pack/test/functional/services/remote_es/remote_es.ts @elastic/appex-qa
/x-pack/test/functional/services/random.js @elastic/appex-qa
/x-pack/test/functional/services/index.ts @elastic/appex-qa
/x-pack/test/functional/page_objects/index.ts @elastic/appex-qa
/x-pack/test/functional/ftr_provider_context.ts @elastic/appex-qa
/x-pack/test/functional/README.md @elastic/appex-qa
/x-pack/test/examples/config.ts @elastic/appex-qa
/x-pack/test/common/services/index.ts @elastic/appex-qa
/x-pack/test/common/services/bsearch_secure.ts @elastic/appex-qa
/x-pack/test/common/ftr_provider_context.ts @elastic/appex-qa
/x-pack/test/api_integration_basic/ftr_provider_context.d.ts @elastic/appex-qa
/x-pack/test/api_integration_basic/config.ts @elastic/appex-qa
/x-pack/test/api_integration_basic/apis/index.ts @elastic/appex-qa
/x-pack/test/api_integration/services/index.ts @elastic/appex-qa
/x-pack/test/api_integration/services/es_supertest_without_auth.js @elastic/appex-qa
/x-pack/test/api_integration/config.ts @elastic/appex-qa
/x-pack/test/api_integration/apis/kibana/config.ts @elastic/appex-qa
/x-pack/test/tsconfig.json @elastic/appex-qa
/x-pack/test/load @elastic/appex-qa
/test/tsconfig.json @elastic/appex-qa
/test/plugin_functional/services/index.ts @elastic/appex-qa
/test/plugin_functional/README.md @elastic/appex-qa
/test/plugin_functional/config.ts @elastic/appex-qa
/test/kibana.jsonc @elastic/appex-qa
/test/harden @elastic/appex-qa
/test/functional/services/supertest.ts @elastic/appex-qa
/test/functional/services/remote_es/remote_es.ts @elastic/appex-qa
/test/functional/services/query_bar.ts @elastic/appex-qa
/test/functional/services/menu_toggle.ts @elastic/appex-qa
/test/functional/services/listing_table.ts @elastic/appex-qa
/test/common/fixtures/plugins/coverage @elastic/appex-qa
/test/functional/services/index.ts @elastic/appex-qa
/test/functional/services/global_nav.ts @elastic/appex-qa
/test/functional/services/flyout.ts @elastic/appex-qa
/test/functional/services/filter_bar.ts @elastic/appex-qa
/test/functional/services/field_editor.ts @elastic/appex-qa
/test/functional/services/embedding.ts @elastic/appex-qa
/test/functional/services/doc_table.ts @elastic/appex-qa
/test/functional/services/data_grid.ts @elastic/appex-qa
/test/functional/services/combo_box.ts @elastic/appex-qa
/test/functional/page_objects/unified_field_list.ts @elastic/appex-qa
/test/functional/page_objects/time_picker.ts @elastic/appex-qa
/test/functional/page_objects/index.ts @elastic/appex-qa
/test/functional/page_objects/header_page.ts @elastic/appex-qa
/test/functional/page_objects/error_page.ts @elastic/appex-qa
/test/functional/page_objects/common_page.ts @elastic/appex-qa
/test/functional/jest.config.js @elastic/appex-qa
/test/functional/ftr_provider_context.ts @elastic/appex-qa
/test/functional/fixtures/es_archiver/README.md @elastic/appex-qa
/test/functional/firefox/config.base.ts @elastic/appex-qa
/test/functional/config.* @elastic/appex-qa
/test/functional/README.md @elastic/appex-qa
/test/examples/config.js @elastic/appex-qa
/test/examples/README.md @elastic/appex-qa
/test/common/services/index.ts @elastic/appex-qa
/test/common/fixtures/plugins/coverage/*.ts @elastic/appex-qa
/test/common/config.js @elastic/appex-qa
/test/api_integration/services/index.ts @elastic/appex-qa
/test/api_integration/jest.config.js @elastic/appex-qa
/test/api_integration/ftr_provider_context.d.ts @elastic/appex-qa
/test/api_integration/config.js @elastic/appex-qa
/test/api_integration/apis/index.ts @elastic/appex-qa
/test/accessibility/services/index.ts @elastic/appex-qa
/test/accessibility/services/a11y @elastic/appex-qa
/test/accessibility/page_objects.ts @elastic/appex-qa
/test/accessibility/ftr_provider_context.ts @elastic/appex-qa
/test/accessibility/config.ts @elastic/appex-qa
/test/accessibility/apps/index.ts @elastic/appex-qa
/x-pack/test/scalability @elastic/appex-qa
/src/dev/performance @elastic/appex-qa
/x-pack/test/functional/config.*.* @elastic/appex-qa
Expand Down Expand Up @@ -1563,6 +1646,11 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/test/functional/es_archives/cases/signals/hosts_users @elastic/response-ops

# Enterprise Search
# search
/x-pack/test/functional_solution_sidenav/tests/search_sidenav.ts @elastic/search-kibana
/x-pack/test/functional/services/search_sessions.ts @elastic/search-kibana
/x-pack/test/functional/page_objects/search_* @elastic/search-kibana
/x-pack/test/functional/apps/search_playground @elastic/search-kibana
/x-pack/test_serverless/functional/page_objects/svl_ingest_pipelines.ts @elastic/search-kibana
/x-pack/test/functional/apps/dev_tools/embedded_console.ts @elastic/search-kibana
/x-pack/test/functional/apps/ingest_pipelines/feature_controls/ingest_pipelines_security.ts @elastic/search-kibana
Expand Down
9 changes: 9 additions & 0 deletions packages/kbn-expect/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@ function i (obj, showHidden, depth) {
return stylize('null', 'null');
}

// format sets like arrays
if (value instanceof Set) {
value = Array.from(value)
}

if (isDOMElement(value)) {
return getOuterHTML(value);
}
Expand Down Expand Up @@ -930,6 +935,10 @@ expect.eql = function eql(actual, expected) {
// to determine equivalence.
} else if (isRegExp(actual) && isRegExp(expected)) {
return regExpEquiv(actual, expected);
// If both are Sets, they should be treated equal if they have the same
// entries, independent of the ordering
} else if (actual instanceof Set && expected instanceof Set) {
return actual.size === expected.size && actual.difference(expected).size === 0;
// 7.4. For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
Expand Down
47 changes: 47 additions & 0 deletions packages/kbn-expect/expect.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

// importing this package's expect as `kbnExpect` to not conflict with Jest's expect
import kbnExpect from './expect';

it('asserts that sets with same entries but different ordering are equal', async () => {
const setA = new Set(['a', 'b', 'c']);
const setB = new Set(['c', 'b', 'a']);

expect(() => {
kbnExpect(setA).to.eql(setB);
}).not.toThrow();
expect(() => {
kbnExpect(setB).to.eql(setA);
}).not.toThrow();
});

it('asserts that sets with same size but different entries are not equal', async () => {
const setA = new Set(['a', 'b', 'c']);
const setB = new Set(['x', 'y', 'z']);

expect(() => {
kbnExpect(setA).to.eql(setB);
}).toThrow();
expect(() => {
kbnExpect(setB).to.eql(setA);
}).toThrow();
});

it('asserts that sets with different size but overlapping items are not equal', async () => {
const setA = new Set(['a', 'b', 'c']);
const setB = new Set(['a', 'b']);

expect(() => {
kbnExpect(setA).to.eql(setB);
}).toThrow();
expect(() => {
kbnExpect(setB).to.eql(setA);
}).toThrow();
});
14 changes: 14 additions & 0 deletions packages/kbn-expect/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-expect'],
};
8 changes: 6 additions & 2 deletions packages/kbn-expect/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types"
"outDir": "target/types",
"types": [
"jest",
],
},
"include": [
"expect.d.ts"
"expect.d.ts",
"**/*.ts"
],
"exclude": [
"target/**/*",
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/field_formats/common/converters/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ describe('UrlFormat', () => {
);
});

test('outputs a mailto: link when URL starts with mailto:', () => {
const url = new UrlFormat({});

expect(url.convert('mailto:test@example.com', HTML_CONTEXT_TYPE)).toBe(
'<a href="mailto:test@example.com" target="_blank" rel="noopener noreferrer">mailto:test@example.com</a>'
);
});

test('outputs an <audio> if type === "audio"', () => {
const url = new UrlFormat({ type: 'audio' });

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/field_formats/common/converters/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../types';

const templateMatchRE = /{{([\s\S]+?)}}/g;
const allowedUrlSchemes = ['http://', 'https://'];
const allowedUrlSchemes = ['http://', 'https://', 'mailto:'];

const URL_TYPES = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ import { calculateWidthFromEntries } from '@kbn/calculate-width-from-char-count'
import { DataViewListItemEnhanced } from './dataview_list';

const MIN_WIDTH = 300;
const MAX_MOBILE_WIDTH = 350;

export const changeDataViewStyles = ({
fullWidth,
dataViewsList,
theme,
isMobile,
}: {
fullWidth?: boolean;
dataViewsList: DataViewListItemEnhanced[];
theme: EuiThemeComputed;
isMobile: boolean;
}) => {
return {
trigger: {
Expand All @@ -30,7 +33,10 @@ export const changeDataViewStyles = ({
borderBottomLeftRadius: 0,
},
popoverContent: {
width: calculateWidthFromEntries(dataViewsList, ['name', 'id'], { minWidth: MIN_WIDTH }),
width: calculateWidthFromEntries(dataViewsList, ['name', 'id'], {
minWidth: MIN_WIDTH,
...(isMobile && { maxWidth: MAX_MOBILE_WIDTH }),
}),
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
EuiContextMenuItem,
useEuiTheme,
useGeneratedHtmlId,
useIsWithinBreakpoints,
EuiIcon,
EuiText,
EuiContextMenuPanelProps,
Expand Down Expand Up @@ -68,10 +69,13 @@ export function ChangeDataView({
const kibana = useKibana<IUnifiedSearchPluginServices>();
const { application, data, dataViews, dataViewEditor } = kibana.services;

const isMobile = useIsWithinBreakpoints(['xs']);

const styles = changeDataViewStyles({
fullWidth: trigger.fullWidth,
dataViewsList,
theme: euiTheme,
isMobile,
});

// Create a reusable id to ensure search input is the first focused item in the popover even though it's not the first item
Expand Down
Empty file removed test/functional/screenshots/.empty
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const createClientMock = (): jest.Mocked<AgentClient> => ({
getAgentStatusForAgentPolicy: jest.fn(),
listAgents: jest.fn(),
getLatestAgentAvailableVersion: jest.fn(),
getLatestAgentAvailableBaseVersion: jest.fn(),
getLatestAgentAvailableDockerImageVersion: jest.fn(),
getByIds: jest.fn(async (..._) => []),
});

Expand Down
24 changes: 24 additions & 0 deletions x-pack/plugins/fleet/server/services/agents/agent_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,28 @@ function expectApisToCallServicesSuccessfully(
);
expect(mockgetLatestAvailableAgentVersion).toHaveBeenCalledTimes(1);
});

test('client.getLatestAgentAvailableBaseVersion strips away IAR suffix', async () => {
mockgetLatestAvailableAgentVersion.mockResolvedValue('1.2.3+build12345678987654321');
await expect(agentClient.getLatestAgentAvailableBaseVersion()).resolves.toEqual('1.2.3');
});

test('client.getLatestAgentAvailableBaseVersion does not break on usual version numbers', async () => {
mockgetLatestAvailableAgentVersion.mockResolvedValue('8.17.0');
await expect(agentClient.getLatestAgentAvailableBaseVersion()).resolves.toEqual('8.17.0');
});

test('client.getLatestAgentAvailableDockerImageVersion transforms IAR suffix', async () => {
mockgetLatestAvailableAgentVersion.mockResolvedValue('1.2.3+build12345678987654321');
await expect(agentClient.getLatestAgentAvailableDockerImageVersion()).resolves.toEqual(
'1.2.3.build12345678987654321'
);
});

test('client.getLatestAgentAvailableDockerImageVersion does not break on usual version numbers', async () => {
mockgetLatestAvailableAgentVersion.mockResolvedValue('8.17.0');
await expect(agentClient.getLatestAgentAvailableDockerImageVersion()).resolves.toEqual(
'8.17.0'
);
});
}
18 changes: 18 additions & 0 deletions x-pack/plugins/fleet/server/services/agents/agent_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ export interface AgentClient {
* Return the latest agent available version
*/
getLatestAgentAvailableVersion(includeCurrentVersion?: boolean): Promise<string>;
/**
* Return the latest agent available version, not taking into account IAR versions
*/
getLatestAgentAvailableBaseVersion(includeCurrentVersion?: boolean): Promise<string>;
/**
* Return the latest agent available version formatted for the docker image
*/
getLatestAgentAvailableDockerImageVersion(includeCurrentVersion?: boolean): Promise<string>;
}

/**
Expand Down Expand Up @@ -163,6 +171,16 @@ class AgentClientImpl implements AgentClient {
);
}

public async getLatestAgentAvailableBaseVersion(includeCurrentVersion?: boolean) {
const fullVersion = await this.getLatestAgentAvailableVersion(includeCurrentVersion);
return fullVersion.split('+')[0];
}

public async getLatestAgentAvailableDockerImageVersion(includeCurrentVersion?: boolean) {
const fullVersion = await this.getLatestAgentAvailableVersion(includeCurrentVersion);
return fullVersion.replace('+', '.');
}

public async getLatestAgentAvailableVersion(includeCurrentVersion?: boolean) {
await this.#runPreflight();
return getLatestAvailableAgentVersion({ includeCurrentVersion });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export interface ElasticAgentVersionInfo {
agentVersion: string;
agentBaseVersion: string;
agentDockerImageVersion: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function getAutoDetectCommand(
--kibana-url=${options.kibanaUrl}
--install-key=${options.installApiKey}
--ingest-key=${options.ingestApiKey}
--ea-version=${options.elasticAgentVersion}
--ea-version=${options.elasticAgentVersionInfo.agentVersion}
`;
}
function oneLine(parts: TemplateStringsArray, ...args: string[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export function InstallElasticAgent() {
apiKeyEncoded,
apiEndpoint: setup?.apiEndpoint,
scriptDownloadUrl: setup?.scriptDownloadUrl,
elasticAgentVersion: setup?.elasticAgentVersion,
elasticAgentVersion: setup?.elasticAgentVersionInfo.agentVersion,
autoDownloadConfig,
onboardingId,
})}
Expand Down
Loading

0 comments on commit 3e598c7

Please sign in to comment.