Upgrading cypress to 12.17.4 (#165869)

Co-authored-by: Yuliia Naumenko <jo.naumenko@gmail.com>
Co-authored-by: Thomas Watson <w@tson.dk>
Co-authored-by: Kyle Pollich <kyle.pollich@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Gloria Hornero 2023-09-19 19:15:53 +02:00 committed by GitHub
parent 3782792f13
commit dd4708414a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 326 additions and 314 deletions

View file

@ -4,7 +4,8 @@ steps:
agents:
queue: n2-4-spot
depends_on: build
timeout_in_minutes: 120
timeout_in_minutes: 50
parallelism: 6
retry:
automatic:
- exit_status: '-1'

View file

@ -3,12 +3,14 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-fleet-cypress
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
echo "--- Fleet Cypress tests"
echo "--- Fleet Cypress tests (Chrome)"
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config x-pack/test/fleet_cypress/cli_config.ts
cd x-pack/plugins/fleet
set +e
yarn cypress:run:reporter; status=$?; yarn junit:merge || :; exit $status

View file

@ -13,5 +13,5 @@ echo "--- Profiling Cypress Tests"
cd "$XPACK_DIR"
node plugins/profiling/scripts/test/e2e.js \
NODE_OPTIONS=--openssl-legacy-provider node plugins/profiling/scripts/test/e2e.js \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \

View file

@ -1446,7 +1446,7 @@
"cssnano": "^5.1.12",
"cssnano-preset-default": "^5.2.12",
"csstype": "^3.0.2",
"cypress": "^12.13.0",
"cypress": "^12.17.4",
"cypress-axe": "^1.4.0",
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.6.3",

View file

@ -5,10 +5,8 @@ source test/scripts/jenkins_test_setup_xpack.sh
echo " -> Running fleet cypress tests"
cd "$XPACK_DIR"
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--config test/fleet_cypress/cli_config.ts
cd x-pack/plugins/fleet
yarn --cwd x-pack/plugins/fleet cypress:run
echo ""
echo ""

View file

@ -69,7 +69,11 @@ function runTests() {
return childProcess.spawnSync('node', spawnArgs, {
cwd: e2eDir,
env: { ...process.env, CYPRESS_CLI_ARGS: JSON.stringify(cypressCliArgs) },
env: {
...process.env,
CYPRESS_CLI_ARGS: JSON.stringify(cypressCliArgs),
NODE_OPTIONS: '--openssl-legacy-provider',
},
encoding: 'utf8',
stdio: 'inherit',
});

View file

@ -18,6 +18,10 @@ export default defineCypressConfig({
runMode: 2,
},
env: {
grepFilterSpecs: false,
},
screenshotsFolder: '../../../target/kibana-fleet/cypress/screenshots',
trashAssetsBeforeRuns: false,
video: false,
@ -26,14 +30,16 @@ export default defineCypressConfig({
viewportWidth: 1440,
screenshotOnRunFailure: true,
env: {
protocol: 'http',
hostname: 'localhost',
configport: '5601',
},
e2e: {
baseUrl: 'http://localhost:5601',
experimentalRunAllSpecs: true,
experimentalMemoryManagement: true,
numTestsKeptInMemory: 3,
specPattern: './cypress/e2e/**/*.cy.ts',
supportFile: './cypress/support/e2e.ts',
setupNodeEvents(on, config) {
// eslint-disable-next-line @typescript-eslint/no-var-requires, @kbn/imports/no_boundary_crossing
return require('./cypress/plugins')(on, config);

View file

@ -52,8 +52,9 @@ node scripts/build_kibana_platform_plugins
# launch the cypress test runner
cd x-pack/plugins/fleet
yarn cypress:run-as-ci
yarn cypress:run
```
#### FTR + Interactive
This is the preferred mode for developing new tests.
@ -67,17 +68,7 @@ node scripts/build_kibana_platform_plugins
# launch the cypress test runner
cd x-pack/plugins/fleet
yarn cypress:open-as-ci
```
Alternatively, kibana test server can be started separately, to pick up changes in UI (e.g. change in data-test-subj selector)
```
# launch kibana test server
node scripts/functional_tests_server --config x-pack/test/fleet_cypress/config.ts
# launch cypress runner
node scripts/functional_test_runner --config x-pack/test/fleet_cypress/visual_config.ts
yarn cypress:open
```
Note that you can select the browser you want to use on the top right side of the interactive runner.

View file

@ -34,12 +34,18 @@ import { cleanupAgentPolicies, unenrollAgent } from '../../tasks/cleanup';
import { setFleetServerHost } from '../../tasks/fleet_server';
import { API_VERSIONS } from '../../../common/constants';
import { login } from '../../tasks/login';
import { request } from '../../tasks/common';
describe('Home page', () => {
before(() => {
setFleetServerHost('https://fleetserver:8220');
});
beforeEach(() => {
login();
});
describe('Agents', () => {
beforeEach(() => {
navigateTo(FLEET);
@ -150,7 +156,7 @@ describe('Home page', () => {
describe('Uninstall Tokens', () => {
before(() => {
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
body: { name: 'Agent policy for A11y test', namespace: 'default', id: 'agent-policy-a11y' },
@ -162,7 +168,7 @@ describe('Home page', () => {
cy.getBySel(UNINSTALL_TOKENS_TAB).click();
});
after(() => {
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies/delete',
body: { agentPolicyId: 'agent-policy-a11y' },
@ -182,6 +188,7 @@ describe('Home page', () => {
describe('Data Streams', () => {
before(() => {
login();
navigateTo(FLEET);
cy.getBySel(DATA_STREAMS_TAB, { timeout: 15000 }).should('be.visible');
cy.getBySel(DATA_STREAMS_TAB).click();

View file

@ -11,15 +11,19 @@ import {
AGENT_BINARY_SOURCES_FLYOUT,
AGENT_POLICY_FORM,
} from '../screens/fleet';
import { cleanupDownloadSources } from '../tasks/cleanup';
import { cleanupAgentPolicies, cleanupDownloadSources } from '../tasks/cleanup';
import { FLEET, navigateTo } from '../tasks/navigation';
import { CONFIRM_MODAL } from '../screens/navigation';
import { API_VERSIONS } from '../../common/constants';
import { request } from '../tasks/common';
import { login } from '../tasks/login';
describe('Agent binary download source section', () => {
beforeEach(() => {
cleanupDownloadSources();
cleanupAgentPolicies();
login();
navigateTo(FLEET);
});
@ -74,7 +78,7 @@ describe('Agent binary download source section', () => {
});
it('the download source is displayed in agent policy settings', () => {
cy.request({
request({
method: 'POST',
url: `api/fleet/agent_download_sources`,
body: {
@ -82,9 +86,8 @@ describe('Agent binary download source section', () => {
id: 'fleet-local-registry',
host: 'https://new-custom-host.co',
},
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
body: {
@ -95,7 +98,6 @@ describe('Agent binary download source section', () => {
id: 'new-agent-policy',
download_source_id: 'fleet-local-registry',
},
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
}).then((response: any) => {
navigateTo('app/fleet/policies/new-agent-policy/settings');
cy.getBySel(AGENT_POLICY_FORM.DOWNLOAD_SOURCE_SELECT).contains('Custom Host');

View file

@ -4,11 +4,14 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { TOAST_CLOSE_BTN } from '../screens/navigation';
import { setupFleetServer } from '../tasks/fleet_server';
import { AGENT_FLYOUT, AGENT_POLICY_DETAILS_PAGE } from '../screens/fleet';
import { login } from '../tasks/login';
describe('Edit agent policy', () => {
beforeEach(() => {
login();
cy.intercept('/api/fleet/agent_policies/policy-1', {
item: {
id: 'policy-1',
@ -35,7 +38,6 @@ describe('Edit agent policy', () => {
it('should edit agent policy', () => {
cy.visit('/app/fleet/policies/policy-1/settings');
cy.getBySel(TOAST_CLOSE_BTN).click();
cy.get('[placeholder="Optional description"').clear().type('desc');
cy.intercept('/api/fleet/agent_policies/policy-1', {

View file

@ -14,6 +14,8 @@ import type { CreateAgentPolicyRequest } from '../../../common/types';
import { setUISettings } from '../../tasks/ui_settings';
import { API_VERSIONS } from '../../../common/constants';
import { request } from '../../tasks/common';
import { login } from '../../tasks/login';
const createAgentDocs = (kibanaVersion: string) => [
createAgentDoc('agent-1', 'policy-1'), // this agent will have upgrade available
@ -65,7 +67,7 @@ const POLICIES: Array<CreateAgentPolicyRequest['body']> = [
];
function createAgentPolicy(body: CreateAgentPolicyRequest['body']) {
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
headers: { 'kbn-xsrf': 'xx', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
@ -101,11 +103,13 @@ describe('View agents list', () => {
}
});
after(() => {
deleteFleetServerDocs();
deleteAgentDocs();
deleteFleetServerDocs(true);
deleteAgentDocs(true);
cleanupAgentPolicies();
});
beforeEach(() => {
login();
cy.intercept('/api/fleet/agents/setup', {
isReady: true,
missing_optional_features: [],
@ -369,7 +373,6 @@ describe('View agents list', () => {
cy.get('.euiModalFooter button:enabled').contains('Assign policy').click();
cy.wait('@getAgents');
assertTableIsEmpty();
cy.pause();
// Select new policy is filters
cy.getBySel(FLEET_AGENT_LIST_PAGE.POLICY_FILTER).click();
cy.get('button').contains('Agent policy 4').click();

View file

@ -9,10 +9,12 @@ import { cleanupAgentPolicies } from '../tasks/cleanup';
import { ENROLLMENT_TOKENS } from '../screens/fleet';
import { API_VERSIONS } from '../../common/constants';
import { request } from '../tasks/common';
import { login } from '../tasks/login';
describe('Enrollment token page', () => {
before(() => {
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
body: {
@ -30,6 +32,10 @@ describe('Enrollment token page', () => {
cleanupAgentPolicies();
});
beforeEach(() => {
login();
});
it('Create new Token', () => {
cy.visit('app/fleet/enrollment-tokens');
cy.getBySel(ENROLLMENT_TOKENS.CREATE_TOKEN_BUTTON).click();

View file

@ -10,8 +10,10 @@ import { cleanupAgentPolicies, deleteFleetServerDocs, deleteAgentDocs } from '..
import { createAgentDoc } from '../tasks/agents';
import { setFleetServerHost } from '../tasks/fleet_server';
import { FLEET, navigateTo } from '../tasks/navigation';
import { request } from '../tasks/common';
import { API_VERSIONS } from '../../common/constants';
import { login } from '../tasks/login';
const FLEET_SERVER_POLICY_ID = 'fleet-server-policy';
@ -27,7 +29,7 @@ describe('Fleet add agent flyout', () => {
cleanUp();
let policyId: string;
// Create a Fleet server policy
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
headers: { 'kbn-xsrf': 'xx', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
@ -61,6 +63,8 @@ describe('Fleet add agent flyout', () => {
});
setFleetServerHost();
});
login();
});
afterEach(() => {

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { TOAST_CLOSE_BTN, CONFIRM_MODAL } from '../screens/navigation';
import { CONFIRM_MODAL } from '../screens/navigation';
import {
SETTINGS_SAVE_BTN,
SETTINGS_OUTPUTS,
@ -14,9 +14,12 @@ import {
FLEET_SERVER_SETUP,
GENERATE_FLEET_SERVER_POLICY_BUTTON,
} from '../screens/fleet';
import { login } from '../tasks/login';
describe('Edit settings', () => {
beforeEach(() => {
login();
cy.intercept('/api/fleet/fleet_server_hosts', {
items: [
{
@ -43,7 +46,6 @@ describe('Edit settings', () => {
});
cy.visit('/app/fleet/settings');
cy.getBySel(TOAST_CLOSE_BTN).click();
});
it('should allow to update Fleet server hosts', () => {

View file

@ -17,31 +17,20 @@ import {
LANDING_PAGE_ADD_FLEET_SERVER_BUTTON,
} from '../screens/fleet';
import { cleanupAgentPolicies, unenrollAgent } from '../tasks/cleanup';
import { request } from '../tasks/common';
import { verifyPolicy, verifyAgentPackage, navigateToTab } from '../tasks/fleet';
import { deleteFleetServer } from '../tasks/fleet_server';
import { deleteFleetServer, setFleetServerHost } from '../tasks/fleet_server';
import { login } from '../tasks/login';
import { FLEET, navigateTo } from '../tasks/navigation';
describe('Fleet startup', () => {
// skipping Fleet Server enroll, to enable, comment out runner.ts line 23
describe.skip('Fleet Server', () => {
it('should display Add agent button and Healthy agent once Fleet Agent page loaded', () => {
navigateTo(FLEET);
cy.get('.euiBadge').contains('Healthy');
verifyPolicy('Fleet Server policy', ['Fleet Server']);
});
after(() => {
unenrollAgent();
cleanupAgentPolicies();
});
});
describe('Create policies', () => {
before(() => {
unenrollAgent();
cleanupAgentPolicies();
deleteFleetServer();
setFleetServerHost();
});
after(() => {
@ -49,11 +38,12 @@ describe('Fleet startup', () => {
});
beforeEach(() => {
login();
navigateTo(FLEET);
});
it('should have no agent policy by default', () => {
cy.request('/api/fleet/agent_policies?full=true').then((response: any) => {
request({ url: '/api/fleet/agent_policies?full=true' }).then((response: any) => {
expect(response.body.items.length).to.equal(0);
});
});

View file

@ -9,9 +9,12 @@ import type { Interception } from 'cypress/types/net-stubbing';
import { CONFIRM_MODAL } from '../screens/navigation';
import { SETTINGS } from '../screens/integrations';
import { login } from '../tasks/login';
describe('Install unverified package assets', () => {
beforeEach(() => {
login();
cy.intercept('POST', '/api/fleet/epm/packages/fleet_server/*', (req) => {
if (!req.body.force) {
return req.reply({

View file

@ -7,11 +7,16 @@
import { navigateTo } from '../tasks/navigation';
import { UPDATE_PACKAGE_BTN } from '../screens/integrations';
import { LOADING_SPINNER, TOAST_CLOSE_BTN } from '../screens/navigation';
import { LOADING_SPINNER } from '../screens/navigation';
import { AGENT_POLICY_SAVE_INTEGRATION } from '../screens/fleet';
import { INSTALLED_VERSION, INTEGRATION_POLICIES_UPGRADE_CHECKBOX } from '../screens/integrations';
import { login } from '../tasks/login';
describe('Add Integration - Mock API', () => {
beforeEach(() => {
login();
});
describe('upgrade package and upgrade package policy', () => {
const oldVersion = '0.3.3';
const newVersion = '1.3.4';
@ -143,7 +148,6 @@ describe('Add Integration - Mock API', () => {
'/app/fleet/policies/package-1/upgrade-package-policy/apache-2?from=integrations-policy-list'
);
cy.getBySel(TOAST_CLOSE_BTN).click();
cy.getBySel(AGENT_POLICY_SAVE_INTEGRATION).click();
cy.wait('@updateApachePolicy').then((interception) => {

View file

@ -31,7 +31,8 @@ import {
import { LOADING_SPINNER, CONFIRM_MODAL } from '../screens/navigation';
import { ADD_PACKAGE_POLICY_BTN } from '../screens/fleet';
import { cleanupAgentPolicies } from '../tasks/cleanup';
import { API_VERSIONS } from '../../common/constants';
import { request } from '../tasks/common';
import { login } from '../tasks/login';
function setupIntegrations() {
cy.intercept(
@ -73,30 +74,31 @@ function getAllIntegrations() {
});
}
it('should install integration without policy', () => {
cy.visit('/app/integrations/detail/tomcat/settings');
cy.getBySel(SETTINGS.INSTALL_ASSETS_BTN).click();
cy.get('.euiCallOut').contains('This action will install 1 assets');
cy.getBySel(CONFIRM_MODAL.CONFIRM_BUTTON).click();
cy.getBySel(LOADING_SPINNER).should('not.exist');
cy.getBySel(SETTINGS.UNINSTALL_ASSETS_BTN).click();
cy.getBySel(CONFIRM_MODAL.CONFIRM_BUTTON).click();
cy.getBySel(LOADING_SPINNER).should('not.exist');
cy.getBySel(SETTINGS.INSTALL_ASSETS_BTN).should('exist');
});
describe('Add Integration - Real API', () => {
const integration = 'apache';
after(() => {
beforeEach(() => {
login();
cleanupAgentPolicies();
deleteIntegrations();
});
afterEach(() => {
cleanupAgentPolicies();
afterEach(() => {});
it('should install integration without policy', () => {
cy.visit('/app/integrations/detail/tomcat/settings');
cy.getBySel(SETTINGS.INSTALL_ASSETS_BTN).click();
cy.get('.euiCallOut').contains('This action will install 1 assets');
cy.getBySel(CONFIRM_MODAL.CONFIRM_BUTTON).click();
cy.getBySel(LOADING_SPINNER).should('not.exist');
cy.getBySel(SETTINGS.UNINSTALL_ASSETS_BTN).click();
cy.getBySel(CONFIRM_MODAL.CONFIRM_BUTTON).click();
cy.getBySel(LOADING_SPINNER).should('not.exist');
cy.getBySel(SETTINGS.INSTALL_ASSETS_BTN).should('exist');
});
it('should install integration without policy', () => {
@ -126,7 +128,7 @@ describe('Add Integration - Real API', () => {
it('should add integration to policy', () => {
const agentPolicyId = 'policy_1';
cy.request({
request({
method: 'POST',
url: `/api/fleet/agent_policies`,
body: {
@ -136,10 +138,9 @@ describe('Add Integration - Real API', () => {
namespace: 'default',
monitoring_enabled: ['logs', 'metrics'],
},
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
cy.request('/api/fleet/agent_policies').then((response: any) => {
request({ url: '/api/fleet/agent_policies' }).then((response: any) => {
cy.visit(`/app/fleet/policies/${agentPolicyId}`);
cy.intercept(

View file

@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { TOAST_CLOSE_BTN } from '../screens/navigation';
import { login } from '../tasks/login';
describe('Edit package policy', () => {
const policyConfig = {
@ -32,6 +32,8 @@ describe('Edit package policy', () => {
],
};
beforeEach(() => {
login();
cy.intercept('/api/fleet/package_policies/policy-1', {
item: policyConfig,
});
@ -110,7 +112,6 @@ describe('Edit package policy', () => {
it('should edit package policy', () => {
cy.visit('/app/fleet/policies/fleet-server-policy/edit-integration/policy-1');
cy.getBySel(TOAST_CLOSE_BTN).click();
cy.getBySel('packagePolicyDescriptionInput').clear().type('desc');
cy.intercept('PUT', '/api/fleet/package_policies/policy-1', {

View file

@ -18,8 +18,15 @@ const INTEGRATION_TEST_PACKAGE = 'logs_integration-1.0.0';
const INTEGRATION_TEST_PACKAGE_NO_DATASET = 'logs_int_no_dataset-1.0.0';
import { API_VERSIONS } from '../../common/constants';
import { request } from '../tasks/common';
import { login } from '../tasks/login';
import { cleanupAgentPolicies } from '../tasks/cleanup';
describe('Input package create and edit package policy', () => {
beforeEach(() => {
login();
});
const agentPolicyId = 'test-input-package-policy';
const agentPolicyName = 'Test input package policy';
const packagePolicyName = 'input-package-policy';
@ -37,7 +44,7 @@ describe('Input package create and edit package policy', () => {
before(() => {
cy.task('installTestPackage', INPUT_TEST_PACKAGE);
cy.request({
request({
method: 'POST',
url: `/api/fleet/agent_policies`,
body: {
@ -50,18 +57,12 @@ describe('Input package create and edit package policy', () => {
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
after(() => {
// delete agent policy
cy.request({
method: 'POST',
url: `/api/fleet/agent_policies/delete`,
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: JSON.stringify({
agentPolicyId,
}),
});
cleanupAgentPolicies();
cy.task('uninstallTestPackage', INPUT_TEST_PACKAGE);
});
it('should successfully create a package policy', () => {
cy.visit(`/app/integrations/detail/${INPUT_TEST_PACKAGE}/overview`);
cy.getBySel(ADD_INTEGRATION_POLICY_BTN).click();
@ -104,6 +105,10 @@ describe('Input package create and edit package policy', () => {
});
describe('Integration package with custom dataset create and edit package policy', () => {
beforeEach(() => {
login();
});
const agentPolicyId = 'test-logs-integration-package-policy';
const agentPolicyName = 'Test integration with custom dataset package policy';
const packagePolicyName = 'logs-integration-package-policy';
@ -112,7 +117,7 @@ describe('Integration package with custom dataset create and edit package policy
before(() => {
cy.task('installTestPackage', INTEGRATION_TEST_PACKAGE);
cy.request({
request({
method: 'POST',
url: `/api/fleet/agent_policies`,
body: {
@ -125,18 +130,12 @@ describe('Integration package with custom dataset create and edit package policy
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
after(() => {
// delete agent policy
cy.request({
method: 'POST',
url: `/api/fleet/agent_policies/delete`,
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: JSON.stringify({
agentPolicyId,
}),
});
cleanupAgentPolicies();
cy.task('uninstallTestPackage', INTEGRATION_TEST_PACKAGE);
});
it('should successfully create a package policy', () => {
cy.visit(`/app/integrations/detail/${INTEGRATION_TEST_PACKAGE}/overview`);
cy.getBySel(ADD_INTEGRATION_POLICY_BTN).click();
@ -169,6 +168,10 @@ describe('Integration package with custom dataset create and edit package policy
});
describe('Integration package with fixed dataset create and edit package policy', () => {
beforeEach(() => {
login();
});
const agentPolicyId = 'test-integration-package-policy';
const agentPolicyName = 'Test integration package policy';
const packagePolicyName = 'integration-package-policy';
@ -176,7 +179,7 @@ describe('Integration package with fixed dataset create and edit package policy'
before(() => {
cy.task('installTestPackage', INTEGRATION_TEST_PACKAGE_NO_DATASET);
cy.request({
request({
method: 'POST',
url: `/api/fleet/agent_policies`,
body: {
@ -189,18 +192,12 @@ describe('Integration package with fixed dataset create and edit package policy'
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
after(() => {
// delete agent policy
cy.request({
method: 'POST',
url: `/api/fleet/agent_policies/delete`,
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: JSON.stringify({
agentPolicyId,
}),
});
cleanupAgentPolicies();
cy.task('uninstallTestPackage', INTEGRATION_TEST_PACKAGE_NO_DATASET);
});
it('should successfully create a package policy', () => {
cy.visit(`/app/integrations/detail/${INTEGRATION_TEST_PACKAGE_NO_DATASET}/overview`);
cy.getBySel(ADD_INTEGRATION_POLICY_BTN).click();

View file

@ -7,7 +7,7 @@
import { FLEET, INTEGRATIONS, navigateTo } from '../tasks/navigation';
import { createUsers, BuiltInEditorUser, deleteUsers } from '../tasks/privileges';
import { loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { login, loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { getIntegrationCard } from '../screens/integrations';
@ -27,6 +27,10 @@ describe('When the user has Editor built-in role', () => {
createUsers(usersToCreate);
});
beforeEach(() => {
login();
});
afterEach(() => {
logout();
});

View file

@ -12,7 +12,7 @@ import {
FleetAllIntegrNoneUser,
deleteUsersAndRoles,
} from '../tasks/privileges';
import { loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { login, loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { MISSING_PRIVILEGES } from '../screens/fleet';
const rolesToCreate = [FleetAllIntegrNoneRole];
@ -23,6 +23,10 @@ describe('When the user has All privilege for Fleet but None for integrations',
createUsersAndRoles(usersToCreate, rolesToCreate);
});
beforeEach(() => {
login();
});
afterEach(() => {
logout();
});

View file

@ -12,7 +12,7 @@ import {
FleetAllIntegrReadUser,
deleteUsersAndRoles,
} from '../tasks/privileges';
import { loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { login, loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { navigateToTab, createAgentPolicy } from '../tasks/fleet';
import { cleanupAgentPolicies, unenrollAgent } from '../tasks/cleanup';
import { getIntegrationCard } from '../screens/integrations';
@ -32,6 +32,7 @@ const usersToCreate = [FleetAllIntegrReadUser];
describe('When the user has All privilege for Fleet but Read for integrations', () => {
before(() => {
login();
createUsersAndRoles(usersToCreate, rolesToCreate);
});

View file

@ -7,7 +7,7 @@
import { FLEET, INTEGRATIONS } from '../tasks/navigation';
import { createUsers, BuiltInViewerUser, deleteUsers } from '../tasks/privileges';
import { loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { login, loginWithUserAndWaitForPage, logout } from '../tasks/login';
import { getIntegrationCard } from '../screens/integrations';
@ -23,6 +23,10 @@ describe('When the user has Viewer built-in role', () => {
createUsers(usersToCreate);
});
beforeEach(() => {
login();
});
afterEach(() => {
logout();
});

View file

@ -12,6 +12,8 @@ import { UNINSTALL_TOKENS } from '../screens/fleet';
import type { GetUninstallTokenResponse } from '../../common/types/rest_spec/uninstall_token';
import { API_VERSIONS } from '../../common/constants';
import { request } from '../tasks/common';
import { login } from '../tasks/login';
describe('Uninstall token page', () => {
before(() => {
@ -20,6 +22,8 @@ describe('Uninstall token page', () => {
});
beforeEach(() => {
login();
cy.visit('app/fleet/uninstall-tokens');
cy.intercept('GET', 'api/fleet/uninstall_tokens/*').as('getTokenRequest');
@ -76,7 +80,7 @@ describe('Uninstall token page', () => {
const generatePolicies = () => {
for (let i = 1; i <= 3; i++) {
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
body: { name: `Agent policy ${i}00`, namespace: 'default', id: `agent-policy-${i}00` },

View file

@ -67,6 +67,7 @@ const plugin: Cypress.PluginConfig = (on, config) => {
index,
query,
ignore_unavailable: ignoreUnavailable,
allow_no_indices: true,
refresh: true,
conflicts: 'proceed',
});

View file

@ -5,9 +5,7 @@
* 2.0.
*/
import { request } from '@kbn/osquery-plugin/cypress/tasks/common';
import { visit } from '../tasks/common';
import { request, visit } from '../tasks/common';
import {
getSpecificSelectorId,
@ -39,10 +37,9 @@ export const interceptOutputId = (cb: (caseId: string) => void) => {
};
export const cleanupOutput = (outputId: string) => {
cy.request({
request({
method: 'DELETE',
url: `/api/fleet/outputs/${outputId}`,
headers: { 'kbn-xsrf': 'xx' },
});
};
@ -51,7 +48,6 @@ const loadOutput = (body: Record<string, unknown>) =>
method: 'POST',
body,
url: `/api/fleet/outputs`,
headers: { 'kbn-xsrf': 'xx' },
}).then((response) => response.body);
export const kafkaOutputBody = {

View file

@ -23,6 +23,7 @@
// ***********************************************************
// Import commands.js using ES2015 syntax:
import { request } from '../tasks/common';
import './commands';
declare global {
@ -40,7 +41,7 @@ function getBySel(selector: string, ...args: any[]) {
}
function getKibanaVersion() {
return cy.request('/api/status').then(({ body }) => {
return request<{ version: { number: string } }>({ url: '/api/status' }).then(({ body }) => {
return body.version.number;
});
}

View file

@ -4,47 +4,45 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { API_VERSIONS } from '../../common/constants';
import { request } from './common';
export function cleanupAgentPolicies() {
cy.request('/api/fleet/agent_policies').then((response: any) => {
request({ url: '/api/fleet/agent_policies' }).then((response: any) => {
response.body.items
.filter((policy: any) => policy.agents === 0)
.forEach((policy: any) => {
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies/delete',
body: { agentPolicyId: policy.id },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
});
}
export function unenrollAgent() {
cy.request('/api/fleet/agents?page=1&perPage=20&showInactive=false&showUpgradeable=false').then(
(response: any) => {
response.body.items.forEach((agent: any) => {
cy.request({
method: 'POST',
url: `api/fleet/agents/${agent.id}/unenroll`,
body: { revoke: true },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
request({
url: '/api/fleet/agents?page=1&perPage=20&showInactive=false&showUpgradeable=false',
}).then((response: any) => {
response.body.items.forEach((agent: any) => {
request({
method: 'POST',
url: `api/fleet/agents/${agent.id}/unenroll`,
body: { revoke: true },
});
}
);
});
});
}
export function cleanupDownloadSources() {
cy.request('/api/fleet/agent_download_sources').then((response: any) => {
request({ url: '/api/fleet/agent_download_sources' }).then((response: any) => {
response.body.items
.filter((ds: any) => !ds.is_default)
.forEach((ds: any) => {
cy.request({
request({
method: 'DELETE',
url: `/api/fleet/agent_download_sources/${ds.id}`,
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
});

View file

@ -7,6 +7,8 @@
import { encode } from '@kbn/rison';
import { API_VERSIONS } from '../../common';
import type { ROLES } from './privileges';
import { getUrlWithRoute } from './login';
@ -14,6 +16,30 @@ import { getUrlWithRoute } from './login';
const LOADING_INDICATOR = '[data-test-subj="globalLoadingIndicator"]';
const LOADING_INDICATOR_HIDDEN = '[data-test-subj="globalLoadingIndicator-hidden"]';
// Grab username + password from environment variables
export const API_AUTH = Object.freeze({
user: Cypress.env('KIBANA_USERNAME') ?? Cypress.env('ELASTICSEARCH_USERNAME'),
pass: Cypress.env('KIBANA_PASSWORD') ?? Cypress.env('ELASTICSEARCH_PASSWORD'),
});
export const COMMON_API_HEADERS = Object.freeze({
'kbn-xsrf': 'cypress',
'x-elastic-internal-origin': 'fleet',
'Elastic-Api-Version': API_VERSIONS.public.v1,
});
// Replaces request - adds baseline authentication + global headers
export const request = <T = unknown>({
headers,
...options
}: Partial<Cypress.RequestOptions>): Cypress.Chainable<Cypress.Response<T>> => {
return cy.request<T>({
auth: API_AUTH,
headers: { ...COMMON_API_HEADERS, ...headers },
...options,
});
};
/**
* For all the new features tours we show in the app, this method disables them
* by setting their configs in the local storage. It prevents the tours from appearing

View file

@ -4,9 +4,9 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { API_VERSIONS } from '../../common/constants';
import { createAgentDoc } from './agents';
import { request } from './common';
const FLEET_SERVER_POLICY_ID = 'fleet-server-policy';
@ -15,7 +15,7 @@ export async function setupFleetServer() {
const policyId: string = FLEET_SERVER_POLICY_ID;
let kibanaVersion: string;
cy.request({
request({
method: 'POST',
url: '/api/fleet/agent_policies',
headers: { 'kbn-xsrf': 'xx' },
@ -30,7 +30,7 @@ export async function setupFleetServer() {
// 409 is expected if the policy already exists
// this allows the test to be run repeatedly in dev
if (response.status > 299 && response.status !== 409) {
throw new Error(`Failed to create Fleet Server policy: ${response.body.message}`);
throw new Error(`Failed to create Fleet Server policy: ${JSON.stringify(response.body)}`);
}
});
@ -65,10 +65,9 @@ export function deleteFleetServer() {
}
export function setFleetServerHost(host = 'https://fleetserver:8220') {
cy.request({
request({
method: 'POST',
url: '/api/fleet/fleet_server_hosts',
headers: { 'kbn-xsrf': 'xx', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: {
name: 'Default host',
host_urls: [host],

View file

@ -13,9 +13,9 @@ import {
} from '../screens/integrations';
import { AGENT_POLICY_SYSTEM_MONITORING_CHECKBOX, EXISTING_HOSTS_TAB } from '../screens/fleet';
import { TOAST_CLOSE_BTN, CONFIRM_MODAL } from '../screens/navigation';
import { CONFIRM_MODAL } from '../screens/navigation';
import { API_VERSIONS } from '../../common/constants';
import { request } from './common';
export const addIntegration = ({ useExistingPolicy } = { useExistingPolicy: false }) => {
cy.getBySel(ADD_INTEGRATION_POLICY_BTN).click();
@ -33,7 +33,6 @@ export const addIntegration = ({ useExistingPolicy } = { useExistingPolicy: fals
force: true,
});
}
cy.getBySel(TOAST_CLOSE_BTN).click();
cy.getBySel(CREATE_PACKAGE_POLICY_SAVE_BTN).click();
// sometimes agent is assigned to default policy, sometimes not
cy.getBySel(CONFIRM_MODAL.CONFIRM_BUTTON).click();
@ -50,23 +49,37 @@ export function clickIfVisible(selector: string) {
});
}
export const deleteIntegrations = async () => {
const ids: string[] = [];
cy.request('/api/fleet/package_policies').then((response: any) => {
response.body.items.forEach((policy: any) => ids.push(policy.id));
cy.request({
url: `/api/fleet/package_policies/delete`,
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: `{ "packagePolicyIds": ${JSON.stringify(ids)}, "force": true }`,
method: 'POST',
export const deleteIntegrations = () => {
request({ url: '/api/fleet/package_policies' })
.then((packagePoliciesResponse: any) => {
const packagePolicyIds = packagePoliciesResponse.body.items.map((policy: any) => policy.id);
request({
url: `/api/fleet/package_policies/delete`,
body: `{ "packagePolicyIds": ${JSON.stringify(packagePolicyIds)}, "force": true }`,
method: 'POST',
});
})
.then(() => {
request({ url: '/api/fleet/epm/packages' }).then((packagesResponse: any) => {
for (const pkg of packagesResponse.body.items.filter(
(item: any) => item.status === 'installed'
)) {
request({
url: `/api/fleet/epm/packages/${pkg.name}/${pkg.version}`,
method: 'DELETE',
body: {
force: true,
},
});
}
});
});
});
};
export const installPackageWithVersion = (integration: string, version: string) => {
cy.request({
request({
url: `/api/fleet/epm/packages/${integration}/${version}`,
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: '{ "force": true }',
method: 'POST',
});

View file

@ -12,6 +12,7 @@ import * as yaml from 'js-yaml';
import type { ROLES } from './privileges';
import { hostDetailsUrl, LOGOUT_URL } from './navigation';
import { request } from './common';
/**
* Credentials in the `kibana.dev.yml` config file will be used to authenticate
@ -135,7 +136,7 @@ export const deleteRoleAndUser = (role: ROLES) => {
};
export const loginWithUser = (user: User) => {
cy.request({
request({
body: {
providerType: 'basic',
providerName: 'basic',
@ -145,7 +146,6 @@ export const loginWithUser = (user: User) => {
password: user.password,
},
},
headers: { 'kbn-xsrf': 'cypress-creds-via-config' },
method: 'POST',
url: constructUrlWithUser(user, LOGIN_API_ENDPOINT),
});
@ -162,7 +162,7 @@ export const loginWithRole = async (role: ROLES) => {
port: Cypress.env('configport'),
} as UrlObject);
cy.log(`origin: ${theUrl}`);
cy.request({
request({
body: {
providerType: 'basic',
providerName: 'basic',
@ -200,8 +200,9 @@ export const login = (role?: ROLES) => {
* Returns `true` if the credentials used to login to Kibana are provided
* via environment variables
*/
const credentialsProvidedByEnvironment = (): boolean =>
Cypress.env(ELASTICSEARCH_USERNAME) != null && Cypress.env(ELASTICSEARCH_PASSWORD) != null;
const credentialsProvidedByEnvironment = (): boolean => {
return Cypress.env(ELASTICSEARCH_USERNAME) != null && Cypress.env(ELASTICSEARCH_PASSWORD) != null;
};
/**
* Authenticates with Kibana by reading credentials from the
@ -215,7 +216,7 @@ const loginViaEnvironmentCredentials = () => {
);
// programmatically authenticate without interacting with the Kibana login page
cy.request({
request({
body: {
providerType: 'basic',
providerName: 'basic',
@ -246,7 +247,7 @@ const loginViaConfig = () => {
const config = yaml.safeLoad(kibanaDevYml);
// programmatically authenticate without interacting with the Kibana login page
cy.request({
request({
body: {
providerType: 'basic',
providerName: 'basic',

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import { request } from './common';
import { constructUrlWithUser, getEnvAuth } from './login';
interface User {
@ -186,7 +187,7 @@ export const createRoles = (roles: Role[]) => {
const envUser = getEnvAuth();
for (const role of roles) {
cy.log(`Creating role: ${JSON.stringify(role)}`);
cy.request({
request({
body: role.privileges,
headers: { 'kbn-xsrf': 'cypress-creds-via-config' },
method: 'PUT',
@ -202,7 +203,7 @@ export const deleteRoles = (roles: Role[]) => {
for (const role of roles) {
cy.log(`Deleting role: ${JSON.stringify(role)}`);
cy.request({
request({
headers: { 'kbn-xsrf': 'cypress-creds-via-config' },
method: 'DELETE',
url: constructUrlWithUser(envUser, `/api/security/role/${role.name}`),
@ -221,7 +222,7 @@ export const createUsers = (users: User[]) => {
for (const user of users) {
const userInfo = getUserInfo(user);
cy.log(`Creating user: ${JSON.stringify(user)}`);
cy.request({
request({
body: {
username: user.username,
password: user.password,
@ -242,7 +243,7 @@ export const deleteUsers = (users: User[]) => {
const envUser = getEnvAuth();
for (const user of users) {
cy.log(`Deleting user: ${JSON.stringify(user)}`);
cy.request({
request({
headers: { 'kbn-xsrf': 'cypress-creds-via-config' },
method: 'DELETE',
url: constructUrlWithUser(envUser, `/internal/security/users/${user.username}`),

View file

@ -5,9 +5,11 @@
* 2.0.
*/
import { request } from './common';
// Create a Fleet server policy
export function setUISettings(settingsKey: string, settingsValue: any) {
cy.request({
request({
method: 'POST',
url: '/internal/kibana/settings',
headers: { 'kbn-xsrf': 'xx' },

View file

@ -28,6 +28,5 @@
"force": true
},
"@kbn/rison",
"@kbn/osquery-plugin/cypress"
]
}

View file

@ -5,12 +5,10 @@
"private": true,
"license": "Elastic License 2.0",
"scripts": {
"cypress": "../../../node_modules/.bin/cypress",
"cypress:open": "yarn cypress open --config-file ./cypress.config.ts",
"cypress:open-as-ci": "node ../../../scripts/functional_tests --config ../../test/fleet_cypress/visual_config.ts",
"cypress:run": "yarn cypress:run:reporter --browser chrome --spec './cypress/e2e/**/*.cy.ts'; status=$?; yarn junit:merge && exit $status",
"cypress:run-as-ci": "node ../../../scripts/functional_tests --config ../../test/fleet_cypress/cli_config.ts",
"cypress:run:reporter": "yarn cypress run --config-file ./cypress.config.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json",
"cypress": "NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel --config-file ../fleet/cypress.config.ts --ftr-config-file ../../../x-pack/test/fleet_cypress/cli_config",
"cypress:open": "yarn cypress open",
"cypress:run": "yarn cypress run",
"cypress:run:reporter": "yarn cypress run --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=../fleet/cypress/reporter_config.json",
"junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-fleet/cypress/results/mochawesome*.json > ../../../target/kibana-fleet/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-fleet/cypress/results/output.json --reportDir ../../../target/kibana-fleet/cypress/results && mkdir -p ../../../target/junit && cp ../../../target/kibana-fleet/cypress/results/*.xml ../../../target/junit/",
"openapi:build": "npx @redocly/openapi-cli bundle --ext yaml --output ./common/openapi/bundled.yaml ./common/openapi/entrypoint.yaml && npx @redocly/openapi-cli bundle --ext json --output ./common/openapi/bundled.json ./common/openapi/entrypoint.yaml",
"openapi:lint": "npx @redocly/cli lint ./common/openapi/bundled.yaml",

View file

@ -76,7 +76,11 @@ function runTests() {
return childProcess.spawnSync('node', spawnArgs, {
cwd: e2eDir,
env: { ...process.env, CYPRESS_CLI_ARGS: JSON.stringify(cypressCliArgs) },
env: {
...process.env,
CYPRESS_CLI_ARGS: JSON.stringify(cypressCliArgs),
NODE_OPTIONS: '--openssl-legacy-provider',
},
encoding: 'utf8',
stdio: 'inherit',
});

View file

@ -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 ../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.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 ../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/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",

View file

@ -7,13 +7,13 @@
"scripts": {
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js && node ../../../scripts/eslint ./public/detections/mitre/mitre_tactics_techniques.ts --fix",
"build-beat-doc": "node scripts/beat_docs/build.js && node ../../../scripts/eslint ../timelines/server/utils/beat_schema/fields.ts --fix",
"cypress": "../../../node_modules/.bin/cypress",
"cypress": "NODE_OPTIONS=--openssl-legacy-provider ../../../node_modules/.bin/cypress",
"cypress:burn": "yarn cypress:dw run --env burn=2 --headed",
"cypress:changed-specs-only": "yarn cypress:dw run --changed-specs-only --env burn=2",
"cypress:dw": "node ./scripts/start_cypress_parallel --config-file ./public/management/cypress.config.ts ts --ftr-config-file ../../test/defend_workflows_cypress/cli_config",
"cypress:dw": "NODE_OPTIONS=--openssl-legacy-provider node ./scripts/start_cypress_parallel --config-file ./public/management/cypress.config.ts ts --ftr-config-file ../../test/defend_workflows_cypress/cli_config",
"cypress:dw:open": "yarn cypress:dw open",
"cypress:dw:run": "yarn cypress:dw run",
"cypress:dw:endpoint": "node ./scripts/start_cypress_parallel --config-file ./public/management/cypress_endpoint.config.ts --ftr-config-file ../../test/defend_workflows_cypress/endpoint_config",
"cypress:dw:endpoint": "NODE_OPTIONS=--openssl-legacy-provider node ./scripts/start_cypress_parallel --config-file ./public/management/cypress_endpoint.config.ts --ftr-config-file ../../test/defend_workflows_cypress/endpoint_config",
"cypress:dw:endpoint:run": "yarn cypress:dw:endpoint run",
"cypress:dw:endpoint:open": "yarn cypress:dw:endpoint open ",
"junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-security-solution/cypress/results/mochawesome*.json > ../../../target/kibana-security-solution/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-security-solution/cypress/results/output.json --reportDir ../../../target/kibana-security-solution/cypress/results && yarn junit:transform && mkdir -p ../../../target/junit && cp ../../../target/kibana-security-solution/cypress/results/*.xml ../../../target/junit/",

View file

@ -5,11 +5,11 @@
"license": "Elastic License 2.0",
"scripts": {
"cypress": "../../../node_modules/.bin/cypress",
"cypress:open": "TZ=UTC node ../security_solution/scripts/start_cypress_parallel open --spec './cypress/e2e/**/*.cy.ts' --config-file ../../plugins/threat_intelligence/cypress/cypress.config.ts --ftr-config-file ../../test/threat_intelligence_cypress/cli_config_parallel",
"cypress:open": "TZ=UTC NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel open --spec './cypress/e2e/**/*.cy.ts' --config-file ../../plugins/threat_intelligence/cypress/cypress.config.ts --ftr-config-file ../../test/threat_intelligence_cypress/cli_config_parallel",
"cypress:run": "yarn cypress:run:reporter --browser chrome --spec './cypress/e2e/**/*.cy.ts'; status=$?; yarn junit:merge && exit $status",
"cypress:run:spec": "yarn cypress:run:reporter --browser chrome --spec ${SPEC_LIST:-'./cypress/e2e/**/*.cy.ts'}; status=$?; yarn junit:merge && exit $status",
"cypress:run:cases": "yarn cypress:run:reporter --browser chrome --spec './cypress/e2e/cases/*.cy.ts' --ftr-config-file ../../test/security_solution_cypress/cli_config; status=$?; yarn junit:merge && exit $status",
"cypress:run:reporter": "TZ=UTC node ../security_solution/scripts/start_cypress_parallel run --config-file ../../plugins/threat_intelligence/cypress/cypress.config.ts --ftr-config-file ../../test/threat_intelligence_cypress/cli_config_parallel --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json",
"cypress:run:reporter": "TZ=UTC NODE_OPTIONS=--openssl-legacy-provider node ../security_solution/scripts/start_cypress_parallel run --config-file ../../plugins/threat_intelligence/cypress/cypress.config.ts --ftr-config-file ../../test/threat_intelligence_cypress/cli_config_parallel --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json",
"cypress:run:respops": "yarn cypress:run:reporter --browser chrome --spec ./cypress/e2e/detection_alerts/*.cy.ts,./cypress/e2e/detection_rules/*.cy.ts,./cypress/e2e/exceptions/*.cy.ts --ftr-config-file ../../x-pack/test/security_solution_cypress/cli_config; status=$?; yarn junit:merge && exit $status",
"junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-threat-intelligence/cypress/results/mochawesome*.json > ../../../target/kibana-threat-intelligence/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-threat-intelligence/cypress/results/output.json --reportDir ../../../target/kibana-threat-intelligence/cypress/results && mkdir -p ../../../target/junit && cp ../../../target/kibana-threat-intelligence/cypress/results/*.xml ../../../target/junit/"
}

View file

@ -35,6 +35,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
...xpackFunctionalTestsConfig.get('kbnTestServer'),
serverArgs: [
...xpackFunctionalTestsConfig.get('kbnTestServer.serverArgs'),
'--csp.warnLegacyBrowsers=false',
'--csp.strict=false',
// define custom kibana server args here
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,

View file

@ -5,108 +5,38 @@
* 2.0.
*/
import { resolve } from 'path';
import Url from 'url';
import { withProcRunner } from '@kbn/dev-proc-runner';
import { FtrProviderContext } from './ftr_provider_context';
import { AgentManager, AgentManagerParams } from './agent';
import { FleetManager } from './fleet_server';
export async function FleetCypressCliTestRunner(context: FtrProviderContext) {
await startFleetCypress(context, 'run');
}
async function withFleetAgent(
{ getService }: FtrProviderContext,
runner: (runnerEnv: Record<string, string>) => Promise<void>
) {
// skipping fleet server enroll for now, as it is not a functionality of Fleet UI itself. are there any existing e2e tests for enroll?
return await runner({});
export async function FleetCypressVisualTestRunner(context: FtrProviderContext) {
await startFleetCypress(context, 'open');
}
const log = getService('log');
const config = getService('config');
function startFleetCypress(context: FtrProviderContext, cypressCommand: string) {
const config = context.getService('config');
const esHost = Url.format(config.get('servers.elasticsearch'));
const params: AgentManagerParams = {
user: config.get('servers.elasticsearch.username'),
password: config.get('servers.elasticsearch.password'),
esHost,
esPort: config.get('servers.elasticsearch.port'),
kibanaUrl: Url.format({
return {
FORCE_COLOR: '1',
baseUrl: Url.format({
protocol: config.get('servers.kibana.protocol'),
hostname: config.get('servers.kibana.hostname'),
port: config.get('servers.kibana.port'),
}),
protocol: config.get('servers.kibana.protocol'),
hostname: config.get('servers.kibana.hostname'),
configport: config.get('servers.kibana.port'),
ELASTICSEARCH_URL: Url.format(config.get('servers.elasticsearch')),
ELASTICSEARCH_USERNAME: config.get('servers.kibana.username'),
ELASTICSEARCH_PASSWORD: config.get('servers.kibana.password'),
KIBANA_URL: Url.format({
protocol: config.get('servers.kibana.protocol'),
hostname: config.get('servers.kibana.hostname'),
port: config.get('servers.kibana.port'),
}),
};
const requestOptions = {
headers: {
'kbn-xsrf': 'kibana',
},
auth: {
username: params.user,
password: params.password,
},
};
const fleetManager = new FleetManager(params, log, requestOptions);
const agentManager = new AgentManager(params, log, requestOptions);
// Since the managers will create uncaughtException event handlers we need to exit manually
process.on('uncaughtException', (err) => {
// eslint-disable-next-line no-console
console.error('Encountered error; exiting after cleanup.', err);
process.exit(1);
});
await agentManager.setup();
await fleetManager.setup();
try {
await runner({});
} finally {
fleetManager.cleanup();
agentManager.cleanup();
}
}
export async function FleetCypressCliTestRunner(context: FtrProviderContext) {
await startFleetAgent(context, 'run');
}
export async function FleetCypressVisualTestRunner(context: FtrProviderContext) {
await startFleetAgent(context, 'open');
}
function startFleetAgent(context: FtrProviderContext, cypressCommand: string) {
const log = context.getService('log');
const config = context.getService('config');
return withFleetAgent(context, (runnerEnv) =>
withProcRunner(log, async (procs) => {
await procs.run('cypress', {
cmd: 'yarn',
args: [`cypress:${cypressCommand}`],
cwd: resolve(__dirname, '../../plugins/fleet'),
env: {
FORCE_COLOR: '1',
// eslint-disable-next-line @typescript-eslint/naming-convention
CYPRESS_baseUrl: Url.format(config.get('servers.kibana')),
// eslint-disable-next-line @typescript-eslint/naming-convention
CYPRESS_protocol: config.get('servers.kibana.protocol'),
// eslint-disable-next-line @typescript-eslint/naming-convention
CYPRESS_hostname: config.get('servers.kibana.hostname'),
// eslint-disable-next-line @typescript-eslint/naming-convention
CYPRESS_configport: config.get('servers.kibana.port'),
CYPRESS_ELASTICSEARCH_URL: Url.format(config.get('servers.elasticsearch')),
CYPRESS_ELASTICSEARCH_USERNAME: config.get('servers.elasticsearch.username'),
CYPRESS_ELASTICSEARCH_PASSWORD: config.get('servers.elasticsearch.password'),
CYPRESS_KIBANA_URL: Url.format({
protocol: config.get('servers.kibana.protocol'),
hostname: config.get('servers.kibana.hostname'),
port: config.get('servers.kibana.port'),
}),
...runnerEnv,
...process.env,
},
wait: true,
});
})
);
}

View file

@ -5,11 +5,11 @@
"private": true,
"license": "Elastic License 2.0",
"scripts": {
"cypress": "../../../node_modules/.bin/cypress",
"cypress:open:ess": "TZ=UTC node ../../plugins/security_solution/scripts/start_cypress_parallel open --spec './cypress/e2e/**/*.cy.ts' --config-file ../../test/security_solution_cypress/cypress/cypress.config.ts --ftr-config-file ../../test/security_solution_cypress/cli_config",
"cypress": "NODE_OPTIONS=--openssl-legacy-provider ../../../node_modules/.bin/cypress",
"cypress:open:ess": "TZ=UTC NODE_OPTIONS=--openssl-legacy-provider node ../../plugins/security_solution/scripts/start_cypress_parallel open --spec './cypress/e2e/**/*.cy.ts' --config-file ../../test/security_solution_cypress/cypress/cypress.config.ts --ftr-config-file ../../test/security_solution_cypress/cli_config",
"cypress:run:ess": "yarn cypress:ess --spec './cypress/e2e/!(investigations|explore)/**/*.cy.ts'",
"cypress:run:cases:ess": "yarn cypress:ess --spec './cypress/e2e/explore/cases/*.cy.ts'",
"cypress:ess": "TZ=UTC node ../../plugins/security_solution/scripts/start_cypress_parallel run --config-file ../../test/security_solution_cypress/cypress/cypress_ci.config.ts --ftr-config-file ../../test/security_solution_cypress/cli_config",
"cypress:ess": "TZ=UTC NODE_OPTIONS=--openssl-legacy-provider node ../../plugins/security_solution/scripts/start_cypress_parallel run --config-file ../../test/security_solution_cypress/cypress/cypress_ci.config.ts --ftr-config-file ../../test/security_solution_cypress/cli_config",
"cypress:run:respops:ess": "yarn cypress:ess --spec './cypress/e2e/(detection_alerts|detection_rules|exceptions)/*.cy.ts'",
"cypress:investigations:run:ess": "yarn cypress:ess --spec './cypress/e2e/investigations/**/*.cy.ts'",
"cypress:explore:run:ess": "yarn cypress:ess --spec './cypress/e2e/explore/**/*.cy.ts'",
@ -17,7 +17,7 @@
"cypress:burn:ess": "yarn cypress:ess --env burn=2",
"junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-security-solution/cypress/results/mochawesome*.json > ../../../target/kibana-security-solution/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-security-solution/cypress/results/output.json --reportDir ../../../target/kibana-security-solution/cypress/results && yarn junit:transform && mkdir -p ../../../target/junit && cp ../../../target/kibana-security-solution/cypress/results/*.xml ../../../target/junit/",
"junit:transform": "node ../../plugins/security_solution/scripts/junit_transformer --pathPattern '../../../target/kibana-security-solution/cypress/results/*.xml' --rootDirectory ../../../ --reportName 'Security Solution Cypress' --writeInPlace",
"cypress:serverless": "TZ=UTC node ../../plugins/security_solution/scripts/start_cypress_parallel --config-file ../../test/security_solution_cypress/cypress/cypress_ci_serverless.config.ts --ftr-config-file ../../test/security_solution_cypress/serverless_config",
"cypress:serverless": "TZ=UTC NODE_OPTIONS=--openssl-legacy-provider node ../../plugins/security_solution/scripts/start_cypress_parallel --config-file ../../test/security_solution_cypress/cypress/cypress_ci_serverless.config.ts --ftr-config-file ../../test/security_solution_cypress/serverless_config",
"cypress:open:serverless": "yarn cypress:serverless open --config-file ../../test/security_solution_cypress/cypress/cypress_serverless.config.ts --spec './cypress/e2e/**/*.cy.ts'",
"cypress:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/!(investigations|explore)/**/*.cy.ts'",
"cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/**/*.cy.ts'",

View file

@ -5,9 +5,9 @@
"private": true,
"license": "Elastic License 2.0",
"scripts": {
"cypress:open": "../../../../../../node_modules/.bin/cypress open --config-file ./cypress.config.ts",
"cypress:run": "../../../../../../node_modules/.bin/cypress run --browser chrome --config-file ./cypress.config.ts",
"cypress:serverless:open": "node ../../../../../../scripts/functional_tests --config ./config_runner.ts",
"cypress:serverless:run": "node ../../../../../../scripts/functional_tests --config ./config_server.ts"
"cypress:open": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../../node_modules/.bin/cypress open --config-file ./cypress.config.ts",
"cypress:run": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../../node_modules/.bin/cypress run --browser chrome --config-file ./cypress.config.ts",
"cypress:serverless:open": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../../scripts/functional_tests --config ./config_runner.ts",
"cypress:serverless:run": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../../scripts/functional_tests --config ./config_server.ts"
}
}

View file

@ -5,9 +5,9 @@
"private": true,
"license": "Elastic License 2.0",
"scripts": {
"cypress": "../../../../../../node_modules/.bin/cypress",
"cypress:open": "node ../../../../../plugins/security_solution/scripts/start_cypress_parallel open --config-file ../../../x-pack/test_serverless/functional/test_suites/security/cypress/cypress.config.ts --ftr-config-file ../../../../../../x-pack/test_serverless/functional/test_suites/security/cypress/security_config",
"cypress:run": "node ../../../../../plugins/security_solution/scripts/start_cypress_parallel run --browser chrome --config-file ../../../x-pack/test_serverless/functional/test_suites/security/cypress/cypress.config.ts --ftr-config-file ../../../../../../x-pack/test_serverless/functional/test_suites/security/cypress/security_config --reporter ../../../../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; yarn junit:merge && exit $status",
"cypress": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../../node_modules/.bin/cypress",
"cypress:open": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../plugins/security_solution/scripts/start_cypress_parallel open --config-file ../../../x-pack/test_serverless/functional/test_suites/security/cypress/cypress.config.ts --ftr-config-file ../../../../../../x-pack/test_serverless/functional/test_suites/security/cypress/security_config",
"cypress:run": "NODE_OPTIONS=--openssl-legacy-provider node ../../../../../plugins/security_solution/scripts/start_cypress_parallel run --browser chrome --config-file ../../../x-pack/test_serverless/functional/test_suites/security/cypress/cypress.config.ts --ftr-config-file ../../../../../../x-pack/test_serverless/functional/test_suites/security/cypress/security_config --reporter ../../../../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; yarn junit:merge && exit $status",
"junit:merge": "../../../../../../node_modules/.bin/mochawesome-merge ../../../../../../target/kibana-security-serverless/cypress/results/mochawesome*.json > ../../../../../../target/kibana-security-serverless/cypress/results/output.json && ../../../../../../node_modules/.bin/marge ../../../../../../target/kibana-security-serverless/cypress/results/output.json --reportDir ../../../../../../target/kibana-security-serverless/cypress/results && mkdir -p ../../../../../../target/junit && cp ../../../../../../target/kibana-security-serverless/cypress/results/*.xml ../../../../../../target/junit/"
}
}

View file

@ -1374,7 +1374,7 @@
find-test-names "^1.19.0"
globby "^11.0.4"
"@cypress/request@^2.88.10":
"@cypress/request@2.88.12":
version "2.88.12"
resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590"
integrity sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA==
@ -9414,7 +9414,7 @@
dependencies:
"@types/node" "*"
"@types/node@*", "@types/node@18.17.1", "@types/node@>= 8", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@>=8.9.0", "@types/node@^10.1.0", "@types/node@^14.0.10 || ^16.0.0", "@types/node@^14.14.20 || ^16.0.0", "@types/node@^14.14.31", "@types/node@^18.11.18":
"@types/node@*", "@types/node@18.17.1", "@types/node@>= 8", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@>=8.9.0", "@types/node@^10.1.0", "@types/node@^14.0.10 || ^16.0.0", "@types/node@^14.14.20 || ^16.0.0", "@types/node@^16.18.39", "@types/node@^18.11.18":
version "18.17.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.1.tgz#84c32903bf3a09f7878c391d31ff08f6fe7d8335"
integrity sha512-xlR1jahfizdplZYRU59JlUx9uzF1ARa8jbhM11ccpCJya8kvos5jwdm2ZAgxSCwOl0fq21svP18EVwPBXMQudw==
@ -13868,14 +13868,14 @@ cypress-recurse@^1.35.1:
dependencies:
humanize-duration "^3.27.3"
cypress@^12.13.0:
version "12.13.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.13.0.tgz#725b6617ea19e41e5c59cc509fc3e08097142b01"
integrity sha512-QJlSmdPk+53Zhy69woJMySZQJoWfEWun3X5OOenGsXjRPVfByVTHorxNehbzhZrEzH9RDUDqVcck0ahtlS+N/Q==
cypress@^12.17.4:
version "12.17.4"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.4.tgz#b4dadf41673058493fa0d2362faa3da1f6ae2e6c"
integrity sha512-gAN8Pmns9MA5eCDFSDJXWKUpaL3IDd89N9TtIupjYnzLSmlpVr+ZR+vb4U/qaMp+lB6tBvAmt7504c3Z4RU5KQ==
dependencies:
"@cypress/request" "^2.88.10"
"@cypress/request" "2.88.12"
"@cypress/xvfb" "^1.2.4"
"@types/node" "^14.14.31"
"@types/node" "^16.18.39"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
arch "^2.2.0"
@ -13908,9 +13908,10 @@ cypress@^12.13.0:
minimist "^1.2.8"
ospath "^1.2.2"
pretty-bytes "^5.6.0"
process "^0.11.10"
proxy-from-env "1.0.0"
request-progress "^3.0.0"
semver "^7.3.2"
semver "^7.5.3"
supports-color "^8.1.1"
tmp "~0.2.1"
untildify "^4.0.0"