mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Osquery][Ops] Move Osquery/cypress configurations close to cypress (#167428)
## Summary The osquery-cypress package was referring to configurations from a parent folder. This caused difficulties with having to exclude/include the same files in the `tsconfig.json`s, leading to hard-to-resolve typescript issues. This PR moves the configs in, and cleans up redundancies and type errors. chore(osquery): move osquery/cypress configs to cypress folder, fix type errors --------- Co-authored-by: Patryk Kopyciński <contact@patrykkopycinski.com> Co-authored-by: Brad White <Ikuni17@users.noreply.github.com> Co-authored-by: Brad White <brad.white@elastic.co>
This commit is contained in:
parent
8759b03474
commit
e84742dfc6
12 changed files with 24 additions and 36 deletions
|
@ -11,11 +11,10 @@ import path from 'path';
|
|||
import { safeLoad as loadYaml } from 'js-yaml';
|
||||
import { readFileSync } from 'fs';
|
||||
|
||||
import type { YamlRoleDefinitions } from '../../test_serverless/shared/lib';
|
||||
// eslint-disable-next-line @kbn/imports/no_boundary_crossing
|
||||
import { setupUserDataLoader } from '../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks';
|
||||
import type { YamlRoleDefinitions } from '../../../test_serverless/shared/lib';
|
||||
import { setupUserDataLoader } from '../../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks';
|
||||
const ROLES_YAML_FILE_PATH = path.join(
|
||||
`${__dirname}/cypress/support`,
|
||||
`${__dirname}/support`,
|
||||
'project_controller_osquery_roles.yml'
|
||||
);
|
||||
const roleDefinitions = loadYaml(readFileSync(ROLES_YAML_FILE_PATH, 'utf8')) as YamlRoleDefinitions;
|
|
@ -198,7 +198,6 @@ describe('ALL - Add Integration', { tags: ['@ess', '@brokenInServerless'] }, ()
|
|||
|
||||
// test list of prebuilt queries
|
||||
navigateTo('/app/osquery/saved_queries');
|
||||
cy.waitForReact();
|
||||
cy.react('EuiTableRow').should('have.length.above', 5);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -544,8 +544,6 @@ describe('Packs - Create and Edit', () => {
|
|||
|
||||
recurse<string>(
|
||||
() => {
|
||||
cy.waitForReact();
|
||||
|
||||
cy.getBySel('docsLoading').should('exist');
|
||||
cy.getBySel('docsLoading').should('not.exist');
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ describe('Reader - only READ', { tags: ['@ess'] }, () => {
|
|||
|
||||
it('should not be able to add nor run saved queries', () => {
|
||||
navigateTo('/app/osquery/saved_queries');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains(savedQueryName);
|
||||
cy.contains('Add saved query').should('be.disabled');
|
||||
cy.react('PlayButtonComponent', {
|
||||
|
@ -70,13 +69,11 @@ describe('Reader - only READ', { tags: ['@ess'] }, () => {
|
|||
|
||||
it('should not be able to enter live queries with just read and no run saved queries', () => {
|
||||
navigateTo('/app/osquery/live_queries/new');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains('Permission denied');
|
||||
});
|
||||
|
||||
it('should not be able to play in live queries history', () => {
|
||||
navigateTo('/app/osquery/live_queries');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains('New live query').should('be.disabled');
|
||||
cy.contains(liveQueryQuery);
|
||||
cy.react('EuiIconPlay', { options: { timeout: 3000 } }).should('not.exist');
|
||||
|
@ -85,7 +82,6 @@ describe('Reader - only READ', { tags: ['@ess'] }, () => {
|
|||
|
||||
it('should not be able to add nor edit packs', () => {
|
||||
navigateTo('/app/osquery/packs');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains('Add pack').should('be.disabled');
|
||||
cy.getBySel('tablePaginationPopoverButton').click();
|
||||
cy.getBySel('tablePagination-50-rows').click();
|
||||
|
|
|
@ -57,7 +57,6 @@ describe(`T1 and T2 analysts`, { tags: ['@ess', '@serverless'] }, () => {
|
|||
|
||||
it('should be able to run saved queries but not add new ones', () => {
|
||||
navigateTo('/app/osquery/saved_queries');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains(savedQueryName);
|
||||
cy.contains('Add saved query').should('be.disabled');
|
||||
cy.react('PlayButtonComponent', {
|
||||
|
@ -79,7 +78,6 @@ describe(`T1 and T2 analysts`, { tags: ['@ess', '@serverless'] }, () => {
|
|||
|
||||
it('should be able to play in live queries history', () => {
|
||||
navigateTo('/app/osquery/live_queries');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains('New live query').should('not.be.disabled');
|
||||
cy.contains(liveQueryQuery);
|
||||
cy.wait(1000);
|
||||
|
@ -91,7 +89,6 @@ describe(`T1 and T2 analysts`, { tags: ['@ess', '@serverless'] }, () => {
|
|||
|
||||
it('should be able to use saved query in a new query', () => {
|
||||
navigateTo('/app/osquery/live_queries');
|
||||
cy.waitForReact(1000);
|
||||
cy.contains('New live query').should('not.be.disabled').click();
|
||||
selectAllAgents();
|
||||
getSavedQueriesDropdown().type(`${savedQueryName}{downArrow} {enter}`);
|
||||
|
@ -102,7 +99,6 @@ describe(`T1 and T2 analysts`, { tags: ['@ess', '@serverless'] }, () => {
|
|||
|
||||
it('should not be able to add nor edit packs', () => {
|
||||
navigateTo('/app/osquery/packs');
|
||||
cy.waitForReact(1000);
|
||||
cy.getBySel('tablePaginationPopoverButton').click();
|
||||
cy.getBySel('tablePagination-50-rows').click();
|
||||
cy.contains('Add pack').should('be.disabled');
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
*/
|
||||
|
||||
import { defineCypressConfig } from '@kbn/cypress-config';
|
||||
// eslint-disable-next-line @kbn/imports/no_boundary_crossing
|
||||
import { setupUserDataLoader } from '../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks';
|
||||
import { setupUserDataLoader } from '../../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineCypressConfig({
|
|
@ -23,17 +23,17 @@
|
|||
// ***********************************************************
|
||||
|
||||
// force ESM in this module
|
||||
import type { SecuritySolutionDescribeBlockFtrConfig } from '@kbn/security-solution-plugin/scripts/run_cypress/utils';
|
||||
|
||||
export {};
|
||||
|
||||
import 'cypress-react-selector';
|
||||
// @ts-expect-error ts(2306) module has some interesting ways of importing, see https://github.com/cypress-io/cypress/blob/0871b03c5b21711cd23056454da8f23dcaca4950/npm/grep/README.md#support-file
|
||||
import registerCypressGrep from '@cypress/grep';
|
||||
registerCypressGrep();
|
||||
|
||||
import { login } from '../../../../test_serverless/functional/test_suites/security/cypress/tasks/login';
|
||||
import type { SecuritySolutionDescribeBlockFtrConfig } from '@kbn/security-solution-plugin/scripts/run_cypress/utils';
|
||||
import type { ServerlessRoleName } from './roles';
|
||||
|
||||
registerCypressGrep();
|
||||
import 'cypress-react-selector';
|
||||
import { login } from '../../../../test_serverless/functional/test_suites/security/cypress/tasks/login';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
|
|
|
@ -21,7 +21,11 @@ export const navigateTo = (page: string, opts?: Partial<Cypress.VisitOptions>) =
|
|||
|
||||
// There's a security warning toast that seemingly makes ui elements in the bottom right unavailable, so we close it
|
||||
closeToastIfVisible();
|
||||
cy.waitForReact();
|
||||
cy.waitForReact(
|
||||
10000,
|
||||
Cypress.env('cypress-react-selector')?.root,
|
||||
'../../../node_modules/resq/dist/index.js'
|
||||
);
|
||||
};
|
||||
|
||||
export const openNavigationFlyout = () => {
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
"extends": "../../../../tsconfig.base.json",
|
||||
"include": [
|
||||
"**/*",
|
||||
"../cypress.config.ts",
|
||||
"../serverless_cypress.config.ts",
|
||||
"./cypress.config.ts",
|
||||
"./serverless_cypress.config.ts",
|
||||
"../../../test_serverless/shared/lib"
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*"
|
||||
"target/**/*",
|
||||
"../../../test_serverless/shared/lib/security/default_http_headers.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
"scripts": {
|
||||
"cypress:burn": "yarn cypress:run --env burn=2 --headed",
|
||||
"cypress:changed-specs-only": "yarn cypress:run --changed-specs-only --env burn=2",
|
||||
"cypress": "NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel --config-file ../osquery/cypress.config.ts --ftr-config-file ../../../x-pack/test/osquery_cypress/cli_config",
|
||||
"cypress": "NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel --config-file ../osquery/cypress/cypress.config.ts --ftr-config-file ../../../x-pack/test/osquery_cypress/cli_config",
|
||||
"cypress:open": "yarn cypress open",
|
||||
"cypress:run": "yarn cypress run",
|
||||
"cypress:serverless": "NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel --config-file ../osquery/serverless_cypress.config.ts --ftr-config-file ../../../x-pack/test/osquery_cypress/serverless_cli_config",
|
||||
"cypress:serverless": "NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel --config-file ../osquery/cypress/serverless_cypress.config.ts --ftr-config-file ../../../x-pack/test/osquery_cypress/serverless_cli_config",
|
||||
"cypress:serverless:open": "yarn cypress:serverless open",
|
||||
"cypress:serverless:run": "yarn cypress:serverless run",
|
||||
"nyc": "../../../node_modules/.bin/nyc report --reporter=text-summary",
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
"outDir": "target/types"
|
||||
},
|
||||
"exclude": [
|
||||
"cypress.config.ts",
|
||||
"serverless_cypress.config.ts",
|
||||
"target/**/*",
|
||||
"target/**/*"
|
||||
],
|
||||
"include": [
|
||||
// add all the folders contains files to be compiled
|
||||
|
@ -15,8 +13,6 @@
|
|||
"scripts/**/*",
|
||||
"scripts/**/**.json",
|
||||
"server/**/*",
|
||||
"cypress.config.ts",
|
||||
"serverless_cypress.config.ts",
|
||||
"../../../typings/**/*",
|
||||
// ECS and Osquery schema files
|
||||
"public/common/schemas/*/**.json",
|
||||
|
@ -77,6 +73,6 @@
|
|||
"@kbn/core-saved-objects-server",
|
||||
"@kbn/monaco",
|
||||
"@kbn/io-ts-utils",
|
||||
"@kbn/shared-ux-page-kibana-template",
|
||||
"@kbn/shared-ux-page-kibana-template"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ const sendApiLoginRequest = (
|
|||
};
|
||||
|
||||
interface CyLoginTask {
|
||||
(user?: ServerlessRoleName): ReturnType<typeof sendApiLoginRequest>;
|
||||
(user?: ServerlessRoleName | 'elastic'): ReturnType<typeof sendApiLoginRequest>;
|
||||
|
||||
/**
|
||||
* Login using any username/password
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue