diff --git a/e2e-tests/cypress/e2e/Allowed-api-paths.cy.ts b/e2e-tests/cypress/e2e/Allowed-api-paths.cy.ts index 6bcde67e..b24a6e55 100644 --- a/e2e-tests/cypress/e2e/Allowed-api-paths.cy.ts +++ b/e2e-tests/cypress/e2e/Allowed-api-paths.cy.ts @@ -15,8 +15,8 @@ const apiOnlyInternalUser = 'api_only_internal_user:dev'; const apiOnlyRorUser = 'api_only_ror_user:dev'; describe('allowed_api_paths enforcement for api_only users', () => { - before(() => rorApiClient.configureRorIndexMainSettings('allowedApiPathsSettings.yaml')); - after(() => rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml')); + before(() => rorApiClient.configureRorIndexMainSettingsFromFixture('allowedApiPathsSettings.yaml')); + after(() => rorApiClient.configureRorIndexMainSettingsFromFixture('defaultReadonlyRestEsAndKbnSettings.yaml')); describe('exact /api/ path', () => { it('allows direct API calls to paths listed in allowed_api_paths', () => { diff --git a/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts b/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts index ef464b3c..f0900fe6 100644 --- a/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts +++ b/e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts @@ -2,7 +2,7 @@ import * as semver from 'semver'; import { getKibanaVersion, userCredentials } from '../support/helpers'; import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient'; import { kbnApiClient } from '../support/helpers/KbnApiClient'; -import { rorApiClient } from '../support/helpers/RorApiClient'; +import { Settings } from '../support/page-objects/Settings'; describe('Direct kibana request', () => { const user1 = 'user1:dev'; @@ -10,12 +10,12 @@ describe('Direct kibana request', () => { beforeEach(() => { clearDirectKibanaRequestState(); - rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); }); afterEach(() => { clearDirectKibanaRequestState(); - rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); }); it('should check direct kibana request', () => { @@ -84,7 +84,7 @@ describe('Direct kibana request', () => { }); it('should create short URL with x-ror-tenancy-id header', () => { - rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); const createShortUrl = semver.gte(getKibanaVersion(), '8.0.0') ? kbnApiClient.createShortUrl( diff --git a/e2e-tests/cypress/e2e/Discover.cy.ts b/e2e-tests/cypress/e2e/Discover.cy.ts index d96697e8..b1e342f1 100644 --- a/e2e-tests/cypress/e2e/Discover.cy.ts +++ b/e2e-tests/cypress/e2e/Discover.cy.ts @@ -8,7 +8,7 @@ import { getKibanaVersion } from '../support/helpers'; import { esApiAdvancedClient } from '../support/helpers/EsApiAdvancedClient'; import { SearchSessions } from '../support/page-objects/SearchSessions'; -const userCredentials = 'user4:dev'; +const userCredentials = 'user2:dev'; const tenantIndex = '.kibana_admins_group'; const indexWithSearchSessions = semver.lt(getKibanaVersion(), '8.0.0') ? `${tenantIndex}_${getKibanaVersion()}_001` diff --git a/e2e-tests/cypress/e2e/Forbidden-login.cy.ts b/e2e-tests/cypress/e2e/Forbidden-login.cy.ts index 161abcb4..d33bf2de 100644 --- a/e2e-tests/cypress/e2e/Forbidden-login.cy.ts +++ b/e2e-tests/cypress/e2e/Forbidden-login.cy.ts @@ -3,7 +3,7 @@ import { Settings } from '../support/page-objects/Settings'; describe('Forbidden login test', () => { before(() => { - Settings.setSettingsData('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); }); beforeEach(() => { diff --git a/e2e-tests/cypress/e2e/Hide_apps.cy.ts b/e2e-tests/cypress/e2e/Hide_apps.cy.ts index 000e23f7..7b7c4f55 100644 --- a/e2e-tests/cypress/e2e/Hide_apps.cy.ts +++ b/e2e-tests/cypress/e2e/Hide_apps.cy.ts @@ -12,7 +12,7 @@ import { Home } from '../support/page-objects/Home'; describe('hidden apps', () => { afterEach(() => { - Settings.setSettingsData('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); }); context('Stack Management navigation', () => { diff --git a/e2e-tests/cypress/e2e/Kibana-config.cy.ts b/e2e-tests/cypress/e2e/Kibana-config.cy.ts index 9fb25fb9..e2a5b863 100644 --- a/e2e-tests/cypress/e2e/Kibana-config.cy.ts +++ b/e2e-tests/cypress/e2e/Kibana-config.cy.ts @@ -1,15 +1,16 @@ import * as semver from 'semver'; -import { rorApiInternalKbnClient } from '../support/helpers/RorApiInternalKbnClient'; -import { Login } from '../support/page-objects/Login'; -import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient'; -import { RorMenu } from '../support/page-objects/RorMenu'; import { getKibanaVersion, requiredBaseUrl } from '../support/helpers'; -import { Discover } from '../support/page-objects/Discover'; +import { esApiAdvancedClient } from '../support/helpers/EsApiAdvancedClient'; +import { esApiClient } from '../support/helpers/EsApiClient'; +import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient'; +import { rorApiInternalKbnClient } from '../support/helpers/RorApiInternalKbnClient'; +import { SampleData } from '../support/helpers/SampleData'; import { Dashboard } from '../support/page-objects/Dashboard'; +import { Discover } from '../support/page-objects/Discover'; +import { Login } from '../support/page-objects/Login'; import { Reporting } from '../support/page-objects/Reporting'; -import { SampleData } from '../support/helpers/SampleData'; -import { esApiClient } from '../support/helpers/EsApiClient'; -import { esApiAdvancedClient } from '../support/helpers/EsApiAdvancedClient'; +import { RorMenu } from '../support/page-objects/RorMenu'; +import { Settings } from '../support/page-objects/Settings'; import { Tenancy } from '../support/page-objects/Tenancy'; const customKibanaIndexName = '.kibana_custom'; @@ -29,6 +30,7 @@ describe.skip('Kibana-config', () => { after(() => { rorApiInternalKbnClient.changeKibanaConfig('defaultKibanaConfig.yml'); kbnApiAdvancedClient.waitForKibanaHealth(requiredBaseUrl()); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); esApiAdvancedClient.deleteIndicesByPattern(customKibanaIndexName); esApiAdvancedClient.deleteDataStreamsByPattern(customKibanaIndexName); }); @@ -38,6 +40,10 @@ describe.skip('Kibana-config', () => { const customSessionIndex = `test_index`; before(() => { + // Without an explicit value this stack runs with no session clearing, and a previous + // spec's tenancy survives login. Clearing on login and tenancy hop keeps the specs + // independent of each other. + Settings.setReadonlyRestKbnSettings(customReadonlyRestKbnSettings); rorApiInternalKbnClient.changeKibanaConfig('customKibanaConfig.yml'); kbnApiAdvancedClient.waitForKibanaHealth(requiredBaseUrl()); }); @@ -45,8 +51,8 @@ describe.skip('Kibana-config', () => { afterEach(() => { kbnApiAdvancedClient.deleteSavedObjects(adminCredentials, 'template_group'); - // deleteSavedObjects will return 404 error because, thanks to resetKibanaIndexToTemplate: true, ROR KBN plugin will reset all data to template_group deleted above, first - kbnApiAdvancedClient.getSavedObjects(adminCredentials); + // This GET returns 404/403 because, thanks to resetKibanaIndexToTemplate: true, ROR KBN plugin will reset all data to template_group deleted above, first + kbnApiAdvancedClient.getSavedObjects(adminCredentials, undefined, { failOnStatusCode: false }); esApiClient.deleteIndex(customSessionIndex); }); @@ -61,7 +67,7 @@ describe.skip('Kibana-config', () => { Login.initialization(); Discover.openDataViewPage(); - Discover.verifyIndexPatternSwitchLink('readonlyrest_audit-*'); + Discover.verifyIndexPatternSwitchLink('AUDIT_INDEX_PATTERN'); Dashboard.openDashboard(); Dashboard.verifyDashboardExists('ReadonlyREST Audit Dashboard'); @@ -85,7 +91,16 @@ describe.skip('Kibana-config', () => { Dashboard.verifyDashboardNotExist('Look at my dashboard'); }); - it('should verify index based session', () => { + // FIXME: the session cleanup task never runs against this fixture. server/SessionCleanupTaskManager.ts + // (setup()/start(), registerTaskDefinitions()/ensureScheduled()) only registers and schedules the + // 'ror_session_cleanup' task when `KibanaConfigManager.getKibanaConfig().readonlyrest_kbn` is truthy — + // i.e. only when readonlyrest_kbn is declared inline in kibana.yml (the deprecated path). This describe + // block now pushes readonlyrest_kbn through Settings.setReadonlyRestKbnSettings (the ES settings index) + // instead, so that file-based field is empty and both guards bail out before the task is ever created. + // The mechanism needs to read storeInIndex/indexName/cleanupInterval from RorSettingsStore (the same + // resolved index-or-file source RorSettingsManager already exposes) instead of the raw file config, + // otherwise anyone configuring readonlyrest_kbn purely through the index silently loses session cleanup. + it.skip('should verify index based session', () => { Login.initialization(); esApiAdvancedClient.waitForDocsCount(customSessionIndex, 1).then(() => { // Backdate the session instead of waiting out the 1-minute timeout: the cleanup task @@ -137,6 +152,9 @@ describe.skip('Kibana-config', () => { describe('Default tenant middleware', () => { before(() => { + // Reset index-stored readonlyrest_kbn settings left over from the previous describe block, + // matching the sibling reset at the 'xpack.reporting.index' block below. + Settings.setReadonlyRestKbnSettings(); rorApiInternalKbnClient.changeKibanaConfig('customMiddlewareDefaultTenantKibanaConfig.yml'); kbnApiAdvancedClient.waitForKibanaHealth(requiredBaseUrl()); }); @@ -155,6 +173,9 @@ describe.skip('Kibana-config', () => { describe('Custom kibana config multitenancy disabled', () => { before(() => { + Settings.setReadonlyRestKbnSettings(` + multiTenancyEnabled: false + `); rorApiInternalKbnClient.changeKibanaConfig('customKibanaConfigMultitenancyDisabled.yml'); kbnApiAdvancedClient.waitForKibanaHealth(requiredBaseUrl()); }); @@ -169,21 +190,20 @@ describe.skip('Kibana-config', () => { it('should verify custom Kibana index', () => { const customIndex = `${customKibanaIndexName}_${getKibanaVersion()}_001`; - esApiClient.findIndicesByPattern(customIndex).then(result => { - const foundIndex = result.find(({ index }) => index === customIndex); - if (!foundIndex) throw new Error(`Expected to find an index matching ${customIndex}`); - expect(foundIndex.index).to.equal(customIndex); - expect(foundIndex.health).to.equal('green'); - expect(Number.parseInt(foundIndex['docs.count'], 10)).to.be.greaterThan(0); - }); + esApiAdvancedClient.waitForIndexReady(customIndex); }); }); // xpack.reporting.index was removed in Kibana 8.0, so this only applies to the 7.x leg. if (semver.lt(getKibanaVersion(), '8.0.0')) { describe('Custom kibana config custom xpack.reporting.index', () => { before(() => { + // changeKibanaConfig must run first: the preceding describe block leaves kibana.yml with + // a custom kibana.index, and RorKbnSettingsPolicy rejects a custom kibana.index together + // with multiTenancyEnabled: true (the default here) — posting settings before switching + // configs makes that POST fail, silently leaving multi-tenancy disabled from the prior test. rorApiInternalKbnClient.changeKibanaConfig('customKibanaConfigXpackReportingIndex.yml'); kbnApiAdvancedClient.waitForKibanaHealth(requiredBaseUrl()); + Settings.setReadonlyRestKbnSettings(``); }); it('should verify custom reporting index', () => { @@ -213,9 +233,40 @@ describe.skip('Kibana-config', () => { kbnApiAdvancedClient.deleteSavedObjects('admin:dev'); }); }); - } else { - describe.skip('Custom kibana config custom xpack.reporting.index', () => { - // Tests are skipped - }); } }); + +const customReadonlyRestKbnSettings = ` + clearSessionOnEvents: [login, tenancyHop] + kibanaIndexTemplate: ".kibana_template_group" + resetKibanaIndexToTemplate: true + store_sessions_in_index: true + sessions_index_name: 'test_index' + session_timeout_minutes: 1 + sessions_cleanup_interval: '1s' + sessions_probe_interval_seconds: 180 + whitelistedPaths: [".*/api/status$", ".*/api/index_management/indices$"] + kibana_custom_css_inject: 'h1 { color: rgb(0,128,0) !important;}' + kibana_custom_js_inject: "if (window.ROR_METADATA.customMetadata && window.ROR_METADATA.customMetadata.alert_message) { + const div = document.createElement('div'); + div.setAttribute('data-testid', 'metadata-alert-message'); + div.textContent = window.ROR_METADATA.customMetadata.alert_message; + document.body.appendChild(div); + }; + if (window.ROR_METADATA.enrichedData) { + const div = document.createElement('div'); + div.setAttribute('data-testid', 'metadata-enriched-data'); + div.textContent = window.ROR_METADATA.enrichedData; + document.body.appendChild(div); + };" + custom_middleware_inject: "async function customMiddleware(req, res, next) { + const metadata = + req.rorRequest && req.rorRequest.getIdentitySession() && req.rorRequest.getIdentitySession().metadata; + if (metadata && metadata.username === 'admin') { + req.rorRequest.enrichIdentitySessionMetadata({ + enrichedData: 'custom enriched data', + }); + } + return next(); + }" + `; diff --git a/e2e-tests/cypress/e2e/Readonlyrest-settings.cy.ts b/e2e-tests/cypress/e2e/Readonlyrest-settings.cy.ts new file mode 100644 index 00000000..9567d8ed --- /dev/null +++ b/e2e-tests/cypress/e2e/Readonlyrest-settings.cy.ts @@ -0,0 +1,198 @@ +import { esApiAdvancedClient } from '../support/helpers/EsApiAdvancedClient'; +import { esApiClient } from '../support/helpers/EsApiClient'; +import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient'; +import { Dashboard } from '../support/page-objects/Dashboard'; +import { Discover } from '../support/page-objects/Discover'; +import { Login } from '../support/page-objects/Login'; +import { RorMenu } from '../support/page-objects/RorMenu'; +import { Settings } from '../support/page-objects/Settings'; +import { Tenancy } from '../support/page-objects/Tenancy'; + +describe('Readonlyrest-settings', () => { + const customSessionIndex = `test_index`; + const adminCredentials = 'admin:dev'; + + afterEach(() => { + Settings.setReadonlyRestKbnSettings(); + esApiClient.deleteIndex(customSessionIndex); + kbnApiAdvancedClient.deleteSavedObjects(adminCredentials); + kbnApiAdvancedClient.deleteSavedObjects(adminCredentials, 'template_group'); + }); + + it('should disable multitenancy', () => { + Settings.setReadonlyRestKbnSettings(` + multiTenancyEnabled: false + `); + Login.initialization({ finishUrl: '/app/home' }); + RorMenu.openRorMenu(); + RorMenu.verifyNoTenantAvailable(); + }); + + // The docker env (elk-ror) runs 2 kbn-ror replicas behind kbn-proxy's round robin (see + // base.docker-compose.yml). resetKibanaIndexToTemplate is only applied once, at tenant-index + // creation time (TenantIndexBasedOnTemplateApplier, called from abstractIndexCreator.ts) - unlike + // the CSS/JS/middleware injections elsewhere in this spec, which re-evaluate on every request and + // so self-correct if an early request lands on a stale replica. If the one request that creates + // .kibana_admins_group lands on a replica that has not yet picked up the settings POSTed above, + // the reset never happens and nothing later can retrigger it. The eck-* environments run a single + // Kibana node (kind-cluster/ror/base/kbn.yml: count: 1) and are unaffected. + (Cypress.env().envName === 'elk-ror' ? it.skip : it)('should verify kibanaIndexTemplate functionality', () => { + Settings.setReadonlyRestKbnSettings(` + kibanaIndexTemplate: ".kibana_template_group" + resetKibanaIndexToTemplate: true + `); + + cy.kbnImport({ + endpoint: 'api/saved_objects/_import?overwrite=true', + credentials: adminCredentials, + fixtureFilename: 'audit_dashboard.ndjson', + currentGroupHeader: 'template_group' + }); + + Login.initialization(); + Discover.openDataViewPage(); + Discover.verifyIndexPatternSwitchLink('AUDIT_INDEX_PATTERN'); + Dashboard.openDashboard(); + Dashboard.verifyDashboardExists('ReadonlyREST Audit Dashboard'); + + // Verify that the index is reset to the template + cy.kbnImport({ + endpoint: 'api/saved_objects/_import?overwrite=true', + credentials: adminCredentials, + fixtureFilename: 'file.ndjson', + currentGroupHeader: 'admins_group' + }); + + cy.reload(); + Dashboard.openDashboard(); + Dashboard.verifyDashboardNotExist('Look at my dashboard'); + }); + + it('should verify index based session', () => { + Settings.setReadonlyRestKbnSettings(` + store_sessions_in_index: true + sessions_index_name: ${customSessionIndex} + `); + + Login.initialization(); + esApiAdvancedClient.waitForDocsCount(customSessionIndex, 1); + }); + + it('should verify custom Kibana CSS', () => { + Login.initialization(); + + Settings.setReadonlyRestKbnSettings(` + kibana_custom_css_inject: 'h1 { color: rgb(0,128,0) !important;}' + `); + + cy.reload(); + + cy.get('h1').shouldHaveStyle('color', 'rgb(0,128,0)'); + }); + + it('should verify custom Kibana JS', () => { + Login.initialization(); + + Settings.setReadonlyRestKbnSettings(` + kibana_custom_js_inject: "if (window.ROR_METADATA.customMetadata && window.ROR_METADATA.customMetadata.alert_message) { + const div = document.createElement('div'); + div.setAttribute('data-testid', 'metadata-alert-message'); + div.textContent = window.ROR_METADATA.customMetadata.alert_message; + document.body.appendChild(div); + };" + `); + + cy.reload(); + + cy.get('[data-testid="metadata-alert-message"]') + .should('exist') + .then($el => { + cy.log(`Alert message: ${$el.text()}`); + + cy.wrap($el).should('contain', 'Dear admin'); + }); + }); + + it('should verify custom middleware', () => { + Login.initialization(); + + Settings.setReadonlyRestKbnSettings(` + kibana_custom_js_inject: "if (window.ROR_METADATA.enrichedData) { + const div = document.createElement('div'); + div.setAttribute('data-testid', 'metadata-enriched-data'); + div.textContent = window.ROR_METADATA.enrichedData; + document.body.appendChild(div); + };" + custom_middleware_inject: "async function customMiddleware(req, res, next) { + const metadata = + req.rorRequest && req.rorRequest.getIdentitySession() && req.rorRequest.getIdentitySession().metadata; + + if (metadata && metadata.username === 'admin') { + req.rorRequest.enrichIdentitySessionMetadata({ + enrichedData: 'custom enriched data', + }); + } + + return next(); + }" + `); + + cy.reload(); + + cy.get('[data-testid="metadata-enriched-data"]') + .should('exist') + .then($el => { + cy.log(`Entiched data: ${$el.text()}`); + + cy.wrap($el).should('contain', 'custom enriched data'); + }); + }); + + it('should verify whitelisted Urls', () => { + Settings.setReadonlyRestKbnSettings(` + whitelistedPaths: [".*/api/status$", ".*/api/index_management/indices$"] + `); + + cy.request(`${Cypress.config().baseUrl}/api/index_management/indices`).then(response => { + expect(response.status).to.equal(200); + }); + + cy.request({ url: `${Cypress.config().baseUrl}/api/spaces/space`, failOnStatusCode: false }).then(response => { + expect(response.status).to.equal(403); + expect(response.body.error).to.equal('Unauthorized'); + }); + }); + + it('should open correct tenancy after login when custom middleware sets defaultGroup', () => { + Settings.setReadonlyRestKbnSettings(` + custom_middleware_inject: "async function customMiddleware(req, res, next) { + const rorRequest = req.rorRequest; + const userRequest = rorRequest && (await req.rorRequest.getUserRequestIdentity()); + const metadata = userRequest && userRequest.metadata; + const defaultGroup = 'infosec_group'; + + if (rorRequest.getPath() === '/login' && rorRequest.getMethod() === 'post') { + if (rorRequest.getBody().username === 'admin') { + rorRequest.setQuery('defaultGroup', defaultGroup); + } + } + + if (metadata && rorRequest.getPath() === '/pkp/api/info') { + const availableGroups = metadata.availableGroups; + if (availableGroups.some(availableGroup => availableGroup.id === defaultGroup)) { + const reorderedGroups = [...availableGroups].sort((a, b) => + a.id === defaultGroup ? -1 : b.id === defaultGroup ? 1 : 0 + ); + rorRequest.enrichIdentitySessionMetadata({ availableGroups: reorderedGroups }); + } + } + + return next(); + }" + `); + + Login.initialization(); + + Tenancy.checkTenancyNameInBadge('infosec', 'a'); + }); +}); diff --git a/e2e-tests/cypress/e2e/Reporting-index.cy.ts b/e2e-tests/cypress/e2e/Reporting-index.cy.ts index 6a9e5aaf..56c431e6 100644 --- a/e2e-tests/cypress/e2e/Reporting-index.cy.ts +++ b/e2e-tests/cypress/e2e/Reporting-index.cy.ts @@ -21,7 +21,7 @@ describe('Reporting index', () => { if (semver.gte(getKibanaVersion(), '8.0.0')) { kbnApiAdvancedClient.deleteDataViews(admin, 'infosec_group'); } - Settings.setSettingsData('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); }); it('should correctly match index pattern when audit index_template contains .reporting', () => { diff --git a/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts b/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts index 0dc38643..22a1de71 100644 --- a/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts +++ b/e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts @@ -5,7 +5,7 @@ import { userCredentials } from '../support/helpers'; describe('sanity check ro kibana access', () => { afterEach(() => { - Settings.setSettingsData('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); kbnApiClient.deleteSampleData('ecommerce', userCredentials, 'template_group'); }); diff --git a/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts b/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts index 0975ba09..0f9abd34 100644 --- a/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts +++ b/e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts @@ -5,7 +5,7 @@ import { userCredentials } from '../support/helpers'; describe('sanity check ro_strict kibana access', () => { afterEach(() => { - Settings.setSettingsData('defaultSettings.yaml'); + Settings.setSettingsData('defaultReadonlyRestEsAndKbnSettings.yaml'); kbnApiClient.deleteSampleData('ecommerce', userCredentials, 'template_group'); }); diff --git a/e2e-tests/cypress/e2e/Settings.cy.ts b/e2e-tests/cypress/e2e/Settings.cy.ts index 9728507e..50283931 100644 --- a/e2e-tests/cypress/e2e/Settings.cy.ts +++ b/e2e-tests/cypress/e2e/Settings.cy.ts @@ -32,13 +32,17 @@ describe('settings', () => { // Settings.currentSettingsAlreadyLoadedToast().should('be.visible'); cy.log('should check save changes functionality when malformed settings provided'); - Editor.changeConfig('readonlyrest:'); + Editor.changeConfig( + 'readonlyrest_kbn:\n cookiePass: 12312313123213123213123adadasdasdasd \n{backspace} readonlyrest:' + ); Settings.clickSaveButton(); + Settings.confirmSaveModal(); // Settings.malformedSavedConfigurationToast().should('be.visible'); cy.log('should check save changes functionality when success'); Editor.replaceValues('PERSONAL_GRP', `PERSONAL_GRP${Cypress._.random(0, 1e6)}`); Settings.clickSaveButton(); + Settings.confirmSaveModal(); // Settings.successfulSavedConfigurationToast().should('be.visible'); }); @@ -47,9 +51,9 @@ describe('settings', () => { Login.initialization({ credentials: { username, password } }); Settings.open(); - cy.intercept('POST', '/pkp/api/settings').as('saveSettings'); + cy.intercept({ method: 'POST', pathname: '/pkp/api/settings' }).as('saveSettings'); Settings.clickSaveButton(); - + Settings.confirmSaveModal(); cy.wait('@saveSettings').its('response.statusCode').should('equal', 200); }); }); diff --git a/e2e-tests/cypress/e2e/Test-settings.cy.ts b/e2e-tests/cypress/e2e/Test-settings.cy.ts index 3b764105..f51541d9 100644 --- a/e2e-tests/cypress/e2e/Test-settings.cy.ts +++ b/e2e-tests/cypress/e2e/Test-settings.cy.ts @@ -9,6 +9,7 @@ describe('Test ACL', () => { Settings.open(); Settings.reloadFromFileSettings(); Settings.clickSaveButton(); + Settings.confirmSaveModal(); TestSettings.setDefaultData(); }); diff --git a/e2e-tests/cypress/e2e/ror-config.cy.ts b/e2e-tests/cypress/e2e/ror-config.cy.ts deleted file mode 100644 index dc35b8c9..00000000 --- a/e2e-tests/cypress/e2e/ror-config.cy.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Login } from '../support/page-objects/Login'; -import { RorMenu } from '../support/page-objects/RorMenu'; -import { Settings } from '../support/page-objects/Settings'; -import { Editor } from '../support/page-objects/Editor'; -import { rorApiInternalKbnClient } from '../support/helpers/RorApiInternalKbnClient'; - -// TODO: Uncomment when functionality enabled -describe.skip('Ror config', () => { - beforeEach(() => { - Login.initialization(); - }); - - afterEach(() => { - // const RORSettingsIndex = '.readonlyrest'; - - // FIXME: For some reason delete index freeze cypress, let's investigate later - // esApiClient.deleteIndex(RORSettingsIndex); - rorApiInternalKbnClient.changeKibanaConfig('defaultKibanaConfig.yml'); - }); - - it('should save ReadonlyREST Kibana config to the index', () => { - RorMenu.openRorMenu(); - RorMenu.openEditSecuritySettings(); - // // Fixme: This is workaround for the Es plugin validation when no index is present - Settings.clickSaveButton(); - cy.fixture('settingsWithReadonlyRestKbn.yml').then(data => { - Editor.pasteConfig(data); - }); - cy.intercept({ pathname: '/pkp/api/settings', method: 'POST' }).as('saveSettings'); - Settings.clickSaveButton(); - cy.wait('@saveSettings'); - RorMenu.openRorMenu(); - RorMenu.pressLogoutButton(); - Login.verifyLoginPageTitle('Loaded from index!'); - }); -}); diff --git a/e2e-tests/cypress/fixtures/allowedApiPathsSettings.yaml b/e2e-tests/cypress/fixtures/allowedApiPathsSettings.yaml index ac564894..2e7ea844 100644 --- a/e2e-tests/cypress/fixtures/allowedApiPathsSettings.yaml +++ b/e2e-tests/cypress/fixtures/allowedApiPathsSettings.yaml @@ -1,73 +1,62 @@ readonlyrest: + ssl: + enable: true + keystore_file: '/etc/elasticsearch/ror-keystore.jks' + keystore_pass: readonlyrest + key_pass: readonlyrest + access_control_rules: + - name: 'Kibana service account - user/pass' + verbosity: error + auth_key: kibana:kibana - access_control_rules: - - - name: "Kibana service account - user/pass" - verbosity: error - auth_key: kibana:kibana - - # <-- related to ECK environment --> - - name: "Kibana service account - token" - verbosity: error - token_authentication: - token: "Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}" - username: service_account + # api_only user restricted to a single exact Kibana API path. + - name: API_ONLY_RESTRICTED + auth_key: api_only_restricted_user:dev + kibana: + access: api_only + index: '.kibana_api_restricted' + allowed_api_paths: + - http_method: GET + http_path: '^/api/spaces/space$' - - name: "PROBE" - verbosity: error - auth_key: "elastic-internal-probe:${INTERNAL_PROBE_PASS}" + # api_only user restricted via regexp — allows all /api/spaces/* paths. + - name: API_ONLY_RESTRICTED_REGEXP + auth_key: api_only_restricted_regexp_user:dev + kibana: + access: api_only + index: '.kibana_api_restricted' + allowed_api_paths: + - http_method: GET + http_path: '^/api/spaces.*$' - - name: "ELASTIC-INTERNAL" - verbosity: error - auth_key: "elastic-internal:${INTERNAL_USR_PASS}" - # - - # api_only user restricted to a single exact Kibana API path. - - name: API_ONLY_RESTRICTED - auth_key: api_only_restricted_user:dev - kibana: - access: api_only - index: '.kibana_api_restricted' - allowed_api_paths: - - http_method: GET - http_path: '^/api/spaces/space$' + # api_only user restricted to a space-aware path — only /s/default/api/spaces/space. + - name: API_ONLY_SPACE_RESTRICTED + auth_key: api_only_space_restricted_user:dev + kibana: + access: api_only + index: '.kibana_api_restricted' + allowed_api_paths: + - http_method: GET + http_path: '^/s/default/api/spaces/space$' - # api_only user restricted via regexp — allows all /api/spaces/* paths. - - name: API_ONLY_RESTRICTED_REGEXP - auth_key: api_only_restricted_regexp_user:dev - kibana: - access: api_only - index: '.kibana_api_restricted' - allowed_api_paths: - - http_method: GET - http_path: '^/api/spaces.*$' + # api_only user restricted to Kibana internal API paths (/internal/*). + - name: API_ONLY_INTERNAL_RESTRICTED + auth_key: api_only_internal_user:dev + kibana: + access: api_only + index: '.kibana_api_restricted' + allowed_api_paths: + - http_method: GET + http_path: '^/internal/spaces/get_all.*$' - # api_only user restricted to a space-aware path — only /s/default/api/spaces/space. - - name: API_ONLY_SPACE_RESTRICTED - auth_key: api_only_space_restricted_user:dev - kibana: - access: api_only - index: '.kibana_api_restricted' - allowed_api_paths: - - http_method: GET - http_path: '^/s/default/api/spaces/space$' - - # api_only user restricted to Kibana internal API paths (/internal/*). - - name: API_ONLY_INTERNAL_RESTRICTED - auth_key: api_only_internal_user:dev - kibana: - access: api_only - index: '.kibana_api_restricted' - allowed_api_paths: - - http_method: GET - http_path: '^/internal/spaces/get_all.*$' - - # api_only user restricted to ReadonlyREST public API paths (/api/ror/*). - - name: API_ONLY_ROR_RESTRICTED - auth_key: api_only_ror_user:dev - kibana: - access: api_only - index: '.kibana_api_restricted' - allowed_api_paths: - - http_method: GET - http_path: '^/api/ror/user/tenants$' + # api_only user restricted to ReadonlyREST public API paths (/api/ror/*). + - name: API_ONLY_ROR_RESTRICTED + auth_key: api_only_ror_user:dev + kibana: + access: api_only + index: '.kibana_api_restricted' + allowed_api_paths: + - http_method: GET + http_path: '^/api/ror/user/tenants$' +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/audit_dashboard.ndjson b/e2e-tests/cypress/fixtures/audit_dashboard.ndjson index 02b2e741..6a74901e 100644 --- a/e2e-tests/cypress/fixtures/audit_dashboard.ndjson +++ b/e2e-tests/cypress/fixtures/audit_dashboard.ndjson @@ -1,5 +1,5 @@ -{"attributes":{"fields":"[{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"acl_history\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"acl_history.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"action\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"action.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"block\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"block.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"content_len\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"content_len_kb\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"destination.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"final_state\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"final_state.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"headers\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"headers.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"id.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"indices\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"indices.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"match\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"origin\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"origin.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"path\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"path.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"processingMillis\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"req_method\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"req_method.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"task_id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"type.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user\",\"type\":\"string\",\"count\":1,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"user.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]","timeFieldName":"@timestamp","title":"readonlyrest_audit-*"},"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","migrationVersion":{"index-pattern":"7.6.0"},"references":[],"type":"index-pattern","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwNzUsNV0="} -{"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"final_state.keyword\",\"params\":{\"query\":\"ALLOWED\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"final_state.keyword\":{\"query\":\"ALLOWED\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Who uses what indices?","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Who uses what indices?\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":false,\"labels\":{\"show\":true,\"values\":true,\"last_level\":true,\"truncate\":100},\"dimensions\":{\"metric\":{\"accessor\":1,\"format\":{\"id\":\"number\"},\"params\":{},\"aggType\":\"count\"},\"buckets\":[{\"accessor\":0,\"format\":{\"id\":\"terms\",\"params\":{\"id\":\"string\",\"otherBucketLabel\":\"Other\",\"missingBucketLabel\":\"user not logged\"}},\"params\":{},\"aggType\":\"terms\"},{\"accessor\":2,\"format\":{\"id\":\"terms\",\"params\":{\"id\":\"string\",\"otherBucketLabel\":\"Other\",\"missingBucketLabel\":\"no index specified\"}},\"params\":{},\"aggType\":\"terms\"}]}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"user.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":true,\"missingBucketLabel\":\"user not logged\",\"customLabel\":\"user\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"indices.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":true,\"missingBucketLabel\":\"no index specified\",\"customLabel\":\"index\"}}]}"},"id":"4c826180-1d00-11ea-ab6c-ad5cb00364d9","references":[{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"},{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwNzYsNV0="} +{"attributes":{"fields":"[{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"acl_history\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"acl_history.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"action\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"action.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"block\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"block.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"content_len\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"content_len_kb\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"destination.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"final_state\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"final_state.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"headers\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"headers.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"id.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"indices\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"indices.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"match\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"origin\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"origin.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"path\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"path.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"processingMillis\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"req_method\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"req_method.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"task_id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"type.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user\",\"type\":\"string\",\"count\":1,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"user.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"indices_with_fallback\",\"type\":\"string\",\"count\":0,\"scripted\":true,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false,\"script\":\"if (doc.containsKey('indices.keyword') && doc['indices.keyword'].size() > 0) { return doc['indices.keyword'].value } return 'index not specified'\"}]","timeFieldName":"@timestamp","title":"AUDIT_INDEX_PATTERN"},"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","migrationVersion":{"index-pattern":"7.6.0"},"references":[],"type":"index-pattern","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwNzUsNV0="} +{"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"final_state.keyword\",\"params\":{\"query\":\"ALLOWED\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"final_state.keyword\":{\"query\":\"ALLOWED\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Who uses what indices?","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Who uses what indices?\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":false,\"labels\":{\"show\":true,\"values\":true,\"last_level\":true,\"truncate\":100},\"dimensions\":{\"metric\":{\"accessor\":1,\"format\":{\"id\":\"number\"},\"params\":{},\"aggType\":\"count\"},\"buckets\":[{\"accessor\":0,\"format\":{\"id\":\"terms\",\"params\":{\"id\":\"string\",\"otherBucketLabel\":\"Other\",\"missingBucketLabel\":\"user not logged\"}},\"params\":{},\"aggType\":\"terms\"},{\"accessor\":2,\"format\":{\"id\":\"terms\",\"params\":{\"id\":\"string\",\"otherBucketLabel\":\"Other\",\"missingBucketLabel\":\"no index specified\"}},\"params\":{},\"aggType\":\"terms\"}]}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"user.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":true,\"missingBucketLabel\":\"user not logged\",\"customLabel\":\"user\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"indices_with_fallback\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":true,\"missingBucketLabel\":\"no index specified\",\"customLabel\":\"index\"}}]}"},"id":"4c826180-1d00-11ea-ab6c-ad5cb00364d9","references":[{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"},{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwNzYsNV0="} {"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"title":"Description","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Description\",\"type\":\"markdown\",\"params\":{\"markdown\":\"# ReadonlyREST Dashboard\\nCluster security and performance dashboard powered by [ReadonlyREST](https://readonlyrest.com) audit.\\n\",\"openLinksInNewTab\":false,\"fontSize\":12},\"aggs\":[]}"},"id":"682b5530-3480-11ea-8c6e-1d63c8a03168","references":[],"type":"visualization","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwNzcsNV0="} {"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Who uses most cluster resources?","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Who uses most cluster resources?\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":false,\"labels\":{\"show\":true,\"values\":true,\"last_level\":true,\"truncate\":100},\"dimensions\":{\"metric\":{\"accessor\":1,\"format\":{\"id\":\"number\"},\"params\":{},\"aggType\":\"sum\"},\"buckets\":[{\"accessor\":0,\"format\":{\"id\":\"terms\",\"params\":{\"id\":\"string\",\"otherBucketLabel\":\"Other\",\"missingBucketLabel\":\"\"}},\"params\":{},\"aggType\":\"terms\"}]}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"processingMillis\",\"customLabel\":\"Processing time\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"user.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":true,\"missingBucketLabel\":\"\",\"customLabel\":\"User\"}}]}"},"id":"c5089bd0-3482-11ea-8c6e-1d63c8a03168","references":[{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwNzgsNV0="} {"attributes":{"description":"Failed login attemps per user.","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"final_state.keyword\",\"params\":{\"query\":\"FORBIDDEN\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"final_state.keyword\":{\"query\":\"FORBIDDEN\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Who has most difficulty to remember their password?","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Who has most difficulty to remember their password?\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":false,\"labels\":{\"show\":true,\"values\":true,\"last_level\":true,\"truncate\":100},\"dimensions\":{\"metric\":{\"accessor\":1,\"format\":{\"id\":\"number\"},\"params\":{},\"aggType\":\"count\"},\"buckets\":[{\"accessor\":0,\"format\":{\"id\":\"terms\",\"params\":{\"id\":\"string\",\"otherBucketLabel\":\"Other\",\"missingBucketLabel\":\"\"}},\"params\":{},\"aggType\":\"terms\"}]}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"user.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":true,\"missingBucketLabel\":\"\",\"customLabel\":\"user_not_logged\"}}]}"},"id":"26a02890-1cff-11ea-ab6c-ad5cb00364d9","references":[{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"},{"id":"fac6af10-1cfd-11ea-ab6c-ad5cb00364d9","name":"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-05-28T20:01:48.958Z","version":"WzMwODAsNV0="} diff --git a/e2e-tests/cypress/fixtures/customKibanaConfig.yml b/e2e-tests/cypress/fixtures/customKibanaConfig.yml index 641bd112..579e7298 100644 --- a/e2e-tests/cypress/fixtures/customKibanaConfig.yml +++ b/e2e-tests/cypress/fixtures/customKibanaConfig.yml @@ -1,69 +1,16 @@ server.host: 0.0.0.0 server.port: 5601 - +server.ssl.enabled: true +server.ssl.certificate: /etc/cert/localhost.cer +server.ssl.key: /etc/cert/localhost.key +elasticsearch.ssl.verificationMode: none +elasticsearch.pingTimeout: 3000 # default: 30000 +elasticsearch.requestTimeout: 30000 # csp needs to be disabled to let cypress e2e tests works csp.strict: false csp.warnLegacyBrowsers: false - -elasticsearch.hosts: [ "${ES_API_URL}" ] +elasticsearch.hosts: [ "https://localhost:9200" ] elasticsearch.username: kibana elasticsearch.password: kibana -elasticsearch.ssl.verificationMode: none -elasticsearch.pingTimeout: 3000 # default: 30000 -elasticsearch.requestTimeout: 30000 - -# generated with: -# $ openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 -keyout kibana.key -out kibana.crt -server.ssl.enabled: true -server.ssl.certificate: /usr/share/kibana/config/kibana.crt -server.ssl.key: /usr/share/kibana/config/kibana.key -server.ssl.redirectHttpFromPort: 80 - xpack.encryptedSavedObjects.encryptionKey: "19+230i1902i310293213i109312i31209302193219039120i3j23h31h3h213h123!" -xpack.reporting.encryptionKey: "321421321211231241232132132132132" - telemetry.enabled: false - -readonlyrest_kbn: - # Without an explicit value this stack runs with no session clearing, and a previous - # spec's tenancy survives login. Clearing on login and tenancy hop keeps the specs - # independent of each other. - clearSessionOnEvents: [login, tenancyHop] - cookiePass: '12312313123213123213123adadasdasdasd' - kibanaIndexTemplate: ".kibana_template_group" - resetKibanaIndexToTemplate: true - store_sessions_in_index: true - sessions_index_name: 'test_index' - session_timeout_minutes: 0.05 - sessions_cleanup_interval: '1s' - # Every probe refreshes the session; keep probes clear of the timeout so a session can expire. - sessions_probe_interval_seconds: 180 - whitelistedPaths: [".*/api/status$", ".*/api/index_management/indices$"] - tenantIndex: - number_of_shards: 2 - number_of_replicas: 2 - kibana_custom_css_inject: 'h1 { color: rgb(0,128,0) !important;}' - kibana_custom_js_inject: "if (window.ROR_METADATA.customMetadata && window.ROR_METADATA.customMetadata.alert_message) { - const div = document.createElement('div'); - div.setAttribute('data-testid', 'metadata-alert-message'); - div.textContent = window.ROR_METADATA.customMetadata.alert_message; - document.body.appendChild(div); - }; - if (window.ROR_METADATA.enrichedData) { - const div = document.createElement('div'); - div.setAttribute('data-testid', 'metadata-enriched-data'); - div.textContent = window.ROR_METADATA.enrichedData; - document.body.appendChild(div); - };" - custom_middleware_inject: "async function customMiddleware(req, res, next) { - const metadata = - req.rorRequest && req.rorRequest.getIdentitySession() && req.rorRequest.getIdentitySession().metadata; - - if (metadata && metadata.username === 'admin') { - req.rorRequest.enrichIdentitySessionMetadata({ - enrichedData: 'custom enriched data', - }); - } - - return next(); - }" diff --git a/e2e-tests/cypress/fixtures/customKibanaConfigMultitenancyDisabled.yml b/e2e-tests/cypress/fixtures/customKibanaConfigMultitenancyDisabled.yml index c9f7d31b..17f1c528 100644 --- a/e2e-tests/cypress/fixtures/customKibanaConfigMultitenancyDisabled.yml +++ b/e2e-tests/cypress/fixtures/customKibanaConfigMultitenancyDisabled.yml @@ -1,31 +1,17 @@ -server.name: "elk-ror-kbn-node-${HOSTNAME}" server.host: 0.0.0.0 server.port: 5601 - +server.ssl.enabled: true +server.ssl.certificate: /etc/cert/localhost.cer +server.ssl.key: /etc/cert/localhost.key +elasticsearch.ssl.verificationMode: none +elasticsearch.pingTimeout: 3000 # default: 30000 +elasticsearch.requestTimeout: 30000 # csp needs to be disabled to let cypress e2e tests works csp.strict: false csp.warnLegacyBrowsers: false - -elasticsearch.hosts: [ "${ES_API_URL}" ] +elasticsearch.hosts: [ "https://localhost:9200" ] elasticsearch.username: kibana elasticsearch.password: kibana -elasticsearch.ssl.verificationMode: none -elasticsearch.pingTimeout: 3000 # default: 30000 -elasticsearch.requestTimeout: 30000 - -# generated with: -# $ openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 -keyout kibana.key -out kibana.crt -server.ssl.enabled: true -server.ssl.certificate: /usr/share/kibana/config/kibana.crt -server.ssl.key: /usr/share/kibana/config/kibana.key -server.ssl.redirectHttpFromPort: 80 - xpack.encryptedSavedObjects.encryptionKey: "19+230i1902i310293213i109312i31209302193219039120i3j23h31h3h213h123!" -xpack.reporting.encryptionKey: "321421321211231241232132132132132" - telemetry.enabled: false - kibana.index: .kibana_custom -readonlyrest_kbn: - cookiePass: '12312313123213123213123adadasdasdasd' - multiTenancyEnabled: false diff --git a/e2e-tests/cypress/fixtures/customKibanaConfigXpackReportingIndex.yml b/e2e-tests/cypress/fixtures/customKibanaConfigXpackReportingIndex.yml index ea5072b3..ea1517b1 100644 --- a/e2e-tests/cypress/fixtures/customKibanaConfigXpackReportingIndex.yml +++ b/e2e-tests/cypress/fixtures/customKibanaConfigXpackReportingIndex.yml @@ -1,30 +1,17 @@ -server.name: "elk-ror-kbn-node-${HOSTNAME}" server.host: 0.0.0.0 server.port: 5601 - +server.ssl.enabled: true +server.ssl.certificate: /etc/cert/localhost.cer +server.ssl.key: /etc/cert/localhost.key +elasticsearch.ssl.verificationMode: none +elasticsearch.pingTimeout: 3000 # default: 30000 +elasticsearch.requestTimeout: 30000 # csp needs to be disabled to let cypress e2e tests works csp.strict: false csp.warnLegacyBrowsers: false - -elasticsearch.hosts: [ "${ES_API_URL}" ] +elasticsearch.hosts: [ "https://localhost:9200" ] elasticsearch.username: kibana elasticsearch.password: kibana -elasticsearch.ssl.verificationMode: none -elasticsearch.pingTimeout: 3000 # default: 30000 -elasticsearch.requestTimeout: 30000 - -# generated with: -# $ openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 -keyout kibana.key -out kibana.crt -server.ssl.enabled: true -server.ssl.certificate: /usr/share/kibana/config/kibana.crt -server.ssl.key: /usr/share/kibana/config/kibana.key -server.ssl.redirectHttpFromPort: 80 - xpack.encryptedSavedObjects.encryptionKey: "19+230i1902i310293213i109312i31209302193219039120i3j23h31h3h213h123!" -xpack.reporting.encryptionKey: "321421321211231241232132132132132" -xpack.reporting.index: '.reporting-test-index' - telemetry.enabled: false - -readonlyrest_kbn: - cookiePass: '12312313123213123213123adadasdasdasd' +xpack.reporting.index: '.reporting-test-index' diff --git a/e2e-tests/cypress/fixtures/customMiddlewareDefaultTenantKibanaConfig.yml b/e2e-tests/cypress/fixtures/customMiddlewareDefaultTenantKibanaConfig.yml index b9869d54..26eef5d2 100644 --- a/e2e-tests/cypress/fixtures/customMiddlewareDefaultTenantKibanaConfig.yml +++ b/e2e-tests/cypress/fixtures/customMiddlewareDefaultTenantKibanaConfig.yml @@ -1,61 +1,50 @@ -server.name: "elk-ror-kbn-node-${HOSTNAME}" server.host: 0.0.0.0 server.port: 5601 - +server.ssl.enabled: true +server.ssl.certificate: /etc/cert/localhost.cer +server.ssl.key: /etc/cert/localhost.key +elasticsearch.ssl.verificationMode: none +elasticsearch.pingTimeout: 3000 # default: 30000 +elasticsearch.requestTimeout: 30000 # csp needs to be disabled to let cypress e2e tests works csp.strict: false csp.warnLegacyBrowsers: false - -elasticsearch.hosts: [ "${ES_API_URL}" ] +elasticsearch.hosts: [ "https://localhost:9200" ] elasticsearch.username: kibana elasticsearch.password: kibana -elasticsearch.ssl.verificationMode: none -elasticsearch.pingTimeout: 3000 # default: 30000 -elasticsearch.requestTimeout: 30000 - -# generated with: -# $ openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 -keyout kibana.key -out kibana.crt -server.ssl.enabled: true -server.ssl.certificate: /usr/share/kibana/config/kibana.crt -server.ssl.key: /usr/share/kibana/config/kibana.key -server.ssl.redirectHttpFromPort: 80 - xpack.encryptedSavedObjects.encryptionKey: "19+230i1902i310293213i109312i31209302193219039120i3j23h31h3h213h123!" -xpack.reporting.encryptionKey: "321421321211231241232132132132132" - telemetry.enabled: false - readonlyrest_kbn: - # Without an explicit value this stack runs with no session clearing, and a previous - # spec's tenancy survives login. Clearing on login and tenancy hop keeps the specs - # independent of each other. - clearSessionOnEvents: [login, tenancyHop] - cookiePass: '12312313123213123213123adadasdasdasd' - store_sessions_in_index: true - tenantIndex: - number_of_shards: 2 - number_of_replicas: 2 - custom_middleware_inject: "async function customMiddleware(req, res, next) { - const rorRequest = req.rorRequest; - const userRequest = rorRequest && (await req.rorRequest.getUserRequestIdentity()); - const metadata = userRequest && userRequest.metadata; - const defaultGroup = 'infosec_group'; - - if (rorRequest.getPath() === '/login' && rorRequest.getMethod() === 'post') { - if (rorRequest.getBody().username === 'admin') { - rorRequest.setQuery('defaultGroup', defaultGroup); + # Without an explicit value this stack runs with no session clearing, and a previous + # spec's tenancy survives login. Clearing on login and tenancy hop keeps the specs + # independent of each other. + clearSessionOnEvents: [login, tenancyHop] + cookiePass: '12312313123213123213123adadasdasdasd' + store_sessions_in_index: true + tenantIndex: + number_of_shards: 2 + number_of_replicas: 2 + custom_middleware_inject: "async function customMiddleware(req, res, next) { + const rorRequest = req.rorRequest; + const userRequest = rorRequest && (await req.rorRequest.getUserRequestIdentity()); + const metadata = userRequest && userRequest.metadata; + const defaultGroup = 'infosec_group'; + + if (rorRequest.getPath() === '/login' && rorRequest.getMethod() === 'post') { + if (rorRequest.getBody().username === 'admin') { + rorRequest.setQuery('defaultGroup', defaultGroup); + } } - } - if (metadata && rorRequest.getPath() === '/pkp/api/info') { - const availableGroups = metadata.availableGroups; - if (availableGroups.some(availableGroup => availableGroup.id === defaultGroup)) { - const reorderedGroups = [...availableGroups].sort((a, b) => - a.id === defaultGroup ? -1 : b.id === defaultGroup ? 1 : 0 - ); - rorRequest.enrichIdentitySessionMetadata({ availableGroups: reorderedGroups }); + if (metadata && rorRequest.getPath() === '/pkp/api/info') { + const availableGroups = metadata.availableGroups; + if (availableGroups.some(availableGroup => availableGroup.id === defaultGroup)) { + const reorderedGroups = [...availableGroups].sort((a, b) => + a.id === defaultGroup ? -1 : b.id === defaultGroup ? 1 : 0 + ); + rorRequest.enrichIdentitySessionMetadata({ availableGroups: reorderedGroups }); + } } - } - return next(); - }" + return next(); + }" diff --git a/e2e-tests/cypress/fixtures/defaultKibanaConfig.yml b/e2e-tests/cypress/fixtures/defaultKibanaConfig.yml index 170c4be9..a3eba27f 100644 --- a/e2e-tests/cypress/fixtures/defaultKibanaConfig.yml +++ b/e2e-tests/cypress/fixtures/defaultKibanaConfig.yml @@ -1,31 +1,22 @@ -server.name: "elk-ror-kbn-node-${HOSTNAME}" server.host: 0.0.0.0 server.port: 5601 - +#server.basePath: '/kibana' +#server.rewriteBasePath: true +#logging.dest: /var/log/kibana/kibana.log +#kibana.index: .kibana_custom +server.ssl.enabled: true +server.ssl.certificate: /etc/cert/localhost.cer +server.ssl.key: /etc/cert/localhost.key +elasticsearch.ssl.verificationMode: none +elasticsearch.pingTimeout: 3000 # default: 30000 +elasticsearch.requestTimeout: 30000 # csp needs to be disabled to let cypress e2e tests works csp.strict: false csp.warnLegacyBrowsers: false - -elasticsearch.hosts: [ "${ES_API_URL}" ] +#elasticsearch.hosts: [ "http://localhost:9201", "http://localhost:9202" ] # USE FAKENODE CLUSTER SIMULATOR +elasticsearch.hosts: [ "https://localhost:9200" ] elasticsearch.username: kibana elasticsearch.password: kibana -elasticsearch.ssl.verificationMode: none -elasticsearch.pingTimeout: 3000 # default: 30000 -elasticsearch.requestTimeout: 30000 - -# generated with: -# $ openssl req -x509 -batch -nodes -days 3650 -newkey rsa:2048 -keyout kibana.key -out kibana.crt -server.ssl.enabled: true -server.ssl.certificate: /usr/share/kibana/config/kibana.crt -server.ssl.key: /usr/share/kibana/config/kibana.key -server.ssl.redirectHttpFromPort: 80 - xpack.encryptedSavedObjects.encryptionKey: "19+230i1902i310293213i109312i31209302193219039120i3j23h31h3h213h123!" -xpack.reporting.encryptionKey: "321421321211231241232132132132132" - +#xpack.reporting.index: '.reporting-test-index' telemetry.enabled: false - -readonlyrest_kbn: - cookiePass: '12312313123213123213123adadasdasdasd' - logLevel: info - store_sessions_in_index: true diff --git a/e2e-tests/cypress/fixtures/defaultReadonlyRestEsAndKbnSettings.yaml b/e2e-tests/cypress/fixtures/defaultReadonlyRestEsAndKbnSettings.yaml new file mode 100644 index 00000000..2cbbc2eb --- /dev/null +++ b/e2e-tests/cypress/fixtures/defaultReadonlyRestEsAndKbnSettings.yaml @@ -0,0 +1,128 @@ +helpers: + ckr: &common-kibana-rules + access: rw + hide_apps: ['Enterprise Search|Overview', 'Observability'] + index: '.kibana_@{acl:current_group}' + + ag: &all-groups + groups: + - id: admins_group + name: administrators + - id: infosec_group + name: infosec + - id: template_group + name: template + +readonlyrest: + response_if_req_forbidden: You shall not pass! + audit: + enabled: true + outputs: + - type: index + index_template: "'readonlyrest_audit_'yyyy-MM-dd" + + access_control_rules: + - name: 'Kibana service account - user/pass' + verbosity: error + auth_key: kibana:kibana + + - name: JWT_AUTH + jwt_auth: + name: 'jwt1' + groups_any_of: ['administrators', 'infosec', 'template'] + kibana: + access: admin + + - name: USER_DEFAULT + auth_key: user2:dev + verbosity: error + indices: ['kibana_sample_data_*'] + kibana: + access: rw + index: '.default_index' + + - name: PERSONAL_GRP + groups: [Personal] + kibana: + <<: *common-kibana-rules + index: '.kibana_@{user}' + + - name: ADMIN_GRP + groups: [admins_group] + kibana: + <<: *common-kibana-rules + access: admin + hide_apps: ['Enterprise Search|Overview', 'Management'] + metadata: + alert_message: 'Dear @{acl:user}' + - name: infosec + groups: [infosec_group] + kibana: + <<: *common-kibana-rules + access: admin + hide_apps: ['Enterprise Search|Overview', 'Observability', 'Management'] + + - name: Template Tenancy + groups: [template_group] + kibana: + <<: *common-kibana-rules + + - name: 'ReadonlyREST Enterprise instance #1' + kibana_index: '.kibana_external_auth' + ror_kbn_auth: + name: 'kbn1' + + users: + - username: admin + auth_key: admin:dev + <<: *all-groups + + - username: user1 + auth_key: user1:dev + <<: *all-groups + + - username: '*' + jwt_auth: + name: 'jwt1' + groups: + - local_group: + id: admins_group + name: administrators + external_group_ids: ['administrators'] + - local_group: + id: infosec_group + name: infosec + external_group_ids: ['infosec'] + - local_group: + id: template_group + name: template + external_group_ids: ['template'] + + jwt: + - name: jwt1 + signature_key: 'a-string-secret-at-least-256-bits-long' + group_ids_claim: group + user_claim: sub + header_name: Authorization + + ror_kbn: + - name: kbn1 + signature_key: '9yzBfnLaTYLfGPzyKW9es76RKYhUVgmuv6ZtehaScj5msGpBpa5FWpwk295uJYaaffTFnQC5tsknh2AguVDaTrqCLfM5zCTqdE4UGNL73h28Bg4dPrvTAFQyygQqv4xfgnevBED6VZYdfjXAQLc8J8ywaHQQSmprZqYCWGE6sM3vzNUEWWB3kmGrEKa4sGbXhmXZCvL6NDnEJhXPDJAzu9BMQxn8CzVLqrx6BxDgPYF8gZCxtyxMckXwCaYXrxAGbjkYH69F4wYhuAdHSWgRAQCuWwYmWCA6g39j4VPge5pv962XYvxwJpvn23Y5KvNZ5S5c6crdG4f4gTCXnU36x92fKMQzsQV9K4phcuNvMWkpqVB6xMA5aPzUeHcGytD93dG8D52P5BxsgaJJE6QqDrk3Y2vyLw9ZEbJhPRJxbuBKVCBtVx26Ldd46dq5eyyzmNEyQGLrjQ4qd978VtG8TNT5rkn4ETJQEju5HfCBbjm3urGLFVqxhGVawecT4YM9Rry4EqXWkRJGTFQWQRnweUFbKNbVTC9NxcXEp6K5rSPEy9trb5UYLYhhMJ9fWSBMuenGRjNSJxeurMRCaxPpNppBLFnp8qW5ezfHgCBpEjkSNNzP4uXMZFAXmdUfJ8XQdPTWuYfdHYc5TZWnzrdq9wcfFQRDpDB2zX5Myu96krDt9vA7wNKfYwkSczA6qUQV66jA8nV4Cs38cDAKVBXnxz22ddAVrPv8ajpu7hgBtULMURjvLt94Nc5FDKw79CTTQxffWEj9BJCDCpQnTufmT8xenywwVJvtj49yv2MP2mGECrVDRmcGUAYBKR8G6ZnFAYDVC9UhY46FGWDcyVX3HKwgtHeb45Ww7dsW8JdMnZYctaEU585GZmqTJp2LcAWRcQPH25JewnPX8pjzVpJNcy7avfA2bcU86bfASvQBDUCrhjgRmK2ECR6vzPwTsYKRgFrDqb62FeMdrKgJ9vKs435T5ACN7MNtdRXHQ4fj5pNpUMDW26Wd7tt9bkBTqEGf' + + impersonation: + - impersonator: admin + users: ['*'] + auth_key: admin:dev + +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' + logLevel: 'trace' + logPrettyPrintEnabled: true + whitelistedPaths: [".*/api/status$"] + clearSessionOnEvents: [login, tenancyHop] + sessions_probe_interval_seconds: 60 + store_sessions_in_index: true + login_title: Loaded from index! + login_subtitle: 'PRO/Enterprise: You should see a red border, a tiny unicorn logo, a two column page, and this text. You should see none of these customisation when testing ROR Free.' + login_custom_logo: 'https://i.imgur.com/MdRBUfV.gif' + login_html_head_inject: '' diff --git a/e2e-tests/cypress/fixtures/defaultReadonlyRestEsSettings.yaml b/e2e-tests/cypress/fixtures/defaultReadonlyRestEsSettings.yaml new file mode 100644 index 00000000..40d30e2e --- /dev/null +++ b/e2e-tests/cypress/fixtures/defaultReadonlyRestEsSettings.yaml @@ -0,0 +1,114 @@ +helpers: + ckr: &common-kibana-rules + access: rw + hide_apps: ['Enterprise Search|Overview', 'Observability'] + index: '.kibana_@{acl:current_group}' + + ag: &all-groups + groups: + - id: admins_group + name: administrators + - id: infosec_group + name: infosec + - id: template_group + name: template + +readonlyrest: + response_if_req_forbidden: You shall not pass! + audit: + enabled: true + outputs: + - type: index + index_template: "'readonlyrest_audit_'yyyy-MM-dd" + + access_control_rules: + - name: 'Kibana service account - user/pass' + verbosity: error + auth_key: kibana:kibana + + - name: JWT_AUTH + jwt_auth: + name: 'jwt1' + groups_any_of: ['administrators', 'infosec', 'template'] + kibana: + access: admin + + - name: USER_DEFAULT + auth_key: user2:dev + verbosity: error + indices: ['kibana_sample_data_*'] + kibana: + access: rw + index: '.default_index' + + - name: PERSONAL_GRP + groups: [Personal] + kibana: + <<: *common-kibana-rules + index: '.kibana_@{user}' + + - name: ADMIN_GRP + groups: [admins_group] + kibana: + <<: *common-kibana-rules + access: admin + metadata: + alert_message: 'Dear @{acl:user}' + - name: infosec + groups: [infosec_group] + kibana: + <<: *common-kibana-rules + access: admin + hide_apps: ['Enterprise Search|Overview', 'Observability', 'Management'] + + - name: Template Tenancy + groups: [template_group] + kibana: + <<: *common-kibana-rules + + - name: 'ReadonlyREST Enterprise instance #1' + kibana_index: '.kibana_external_auth' + ror_kbn_auth: + name: 'kbn1' + + users: + - username: admin + auth_key: admin:dev + <<: *all-groups + + - username: user1 + auth_key: user1:dev + <<: *all-groups + + - username: '*' + jwt_auth: + name: 'jwt1' + groups: + - local_group: + id: admins_group + name: administrators + external_group_ids: ['administrators'] + - local_group: + id: infosec_group + name: infosec + external_group_ids: ['infosec'] + - local_group: + id: template_group + name: template + external_group_ids: ['template'] + + jwt: + - name: jwt1 + signature_key: 'a-string-secret-at-least-256-bits-long' + group_ids_claim: group + user_claim: sub + header_name: Authorization + + ror_kbn: + - name: kbn1 + signature_key: '9yzBfnLaTYLfGPzyKW9es76RKYhUVgmuv6ZtehaScj5msGpBpa5FWpwk295uJYaaffTFnQC5tsknh2AguVDaTrqCLfM5zCTqdE4UGNL73h28Bg4dPrvTAFQyygQqv4xfgnevBED6VZYdfjXAQLc8J8ywaHQQSmprZqYCWGE6sM3vzNUEWWB3kmGrEKa4sGbXhmXZCvL6NDnEJhXPDJAzu9BMQxn8CzVLqrx6BxDgPYF8gZCxtyxMckXwCaYXrxAGbjkYH69F4wYhuAdHSWgRAQCuWwYmWCA6g39j4VPge5pv962XYvxwJpvn23Y5KvNZ5S5c6crdG4f4gTCXnU36x92fKMQzsQV9K4phcuNvMWkpqVB6xMA5aPzUeHcGytD93dG8D52P5BxsgaJJE6QqDrk3Y2vyLw9ZEbJhPRJxbuBKVCBtVx26Ldd46dq5eyyzmNEyQGLrjQ4qd978VtG8TNT5rkn4ETJQEju5HfCBbjm3urGLFVqxhGVawecT4YM9Rry4EqXWkRJGTFQWQRnweUFbKNbVTC9NxcXEp6K5rSPEy9trb5UYLYhhMJ9fWSBMuenGRjNSJxeurMRCaxPpNppBLFnp8qW5ezfHgCBpEjkSNNzP4uXMZFAXmdUfJ8XQdPTWuYfdHYc5TZWnzrdq9wcfFQRDpDB2zX5Myu96krDt9vA7wNKfYwkSczA6qUQV66jA8nV4Cs38cDAKVBXnxz22ddAVrPv8ajpu7hgBtULMURjvLt94Nc5FDKw79CTTQxffWEj9BJCDCpQnTufmT8xenywwVJvtj49yv2MP2mGECrVDRmcGUAYBKR8G6ZnFAYDVC9UhY46FGWDcyVX3HKwgtHeb45Ww7dsW8JdMnZYctaEU585GZmqTJp2LcAWRcQPH25JewnPX8pjzVpJNcy7avfA2bcU86bfASvQBDUCrhjgRmK2ECR6vzPwTsYKRgFrDqb62FeMdrKgJ9vKs435T5ACN7MNtdRXHQ4fj5pNpUMDW26Wd7tt9bkBTqEGf' + + impersonation: + - impersonator: admin + users: ['*'] + auth_key: admin:dev diff --git a/e2e-tests/cypress/fixtures/defaultSettings.yaml b/e2e-tests/cypress/fixtures/defaultSettings.yaml deleted file mode 100644 index 1b2265de..00000000 --- a/e2e-tests/cypress/fixtures/defaultSettings.yaml +++ /dev/null @@ -1,149 +0,0 @@ -helpers: - cr: &common-rules - verbosity: error - ckr: &common-kibana-rules - access: rw - hide_apps: ["Enterprise Search|Overview"] - index: ".kibana_@{acl:current_group}" - - ag: &all-groups - groups: - - id: admins_group - name: administrators - - id: infosec_group - name: infosec - - id: template_group - name: template - -readonlyrest: - response_if_req_forbidden: You shall not pass! - audit: - enabled: true - outputs: - - type: index - index_template: "'readonlyrest_audit_'yyyy-MM-dd" - - access_control_rules: - - - name: "Kibana service account - user/pass" - verbosity: error - auth_key: kibana:kibana - - - name: 'APM' - type: allow - auth_key: apm:test - - # <-- related to ECK environment --> - - name: 'Kibana service account - token' - verbosity: error - token_authentication: - token: 'Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}' - username: service_account - - - name: 'PROBE' - verbosity: error - auth_key: 'elastic-internal-probe:${INTERNAL_PROBE_PASS}' - - - name: 'ELASTIC-INTERNAL' - verbosity: error - auth_key: 'elastic-internal:${INTERNAL_USR_PASS}' - # - - - name: JWT_AUTH - jwt_auth: - name: "jwt1" - groups_any_of: [ "administrators", "infosec", "template" ] - kibana: - access: admin - - - name: PERSONAL_GRP - groups: [ Personal ] - <<: *common-rules - kibana: - <<: *common-kibana-rules - index: '.kibana_@{user}' - - - name: ADMIN_GRP - groups: [ admins_group ] - <<: *common-rules - kibana: - <<: *common-kibana-rules - access: admin - metadata: - alert_message: "Dear @{acl:user}" - - - name: infosec - groups: [ infosec_group ] - kibana: - <<: *common-kibana-rules - access: admin - hide_apps: [ "Enterprise Search|Overview", "Management" ] - - - name: Template Tenancy - groups: [ template_group ] - kibana: - <<: *common-kibana-rules - - - name: "Reporting tests: user2" - auth_key: user2:dev - kibana: - index: ".kibana_user2" - access: rw - indices: ["invoices"] - - - name: "Reporting tests: user3" - auth_key: user3:dev - kibana: - index: ".kibana_user3" - access: rw - indices: ["invoices"] - - - name: "defined indices: user 4" - auth_key: user4:dev - verbosity: error - indices: [ "kibana_sample_data_*" ] - kibana: - access: rw - index: '.default_index' - - users: - - username: admin - auth_key: admin:dev - <<: *all-groups - - - username: user1 - auth_key: user1:dev - <<: *all-groups - - - username: "*" - jwt_auth: - name: "jwt1" - groups: - - local_group: - id: admins_group - name: administrators - external_group_ids: ["administrators"] - - local_group: - id: infosec_group - name: infosec - external_group_ids: ["infosec"] - - local_group: - id: template_group - name: template - external_group_ids: ["template"] - - jwt: - - name: jwt1 - signature_key: "a-string-secret-at-least-256-bits-long" - group_ids_claim: group - user_claim: sub - header_name: Authorization - - ror_kbn: - - name: kbn1 - signature_key: "9yzBfnLaTYLfGPzyKW9es76RKYhUVgmuv6ZtehaScj5msGpBpa5FWpwk295uJYaaffTFnQC5tsknh2AguVDaTrqCLfM5zCTqdE4UGNL73h28Bg4dPrvTAFQyygQqv4xfgnevBED6VZYdfjXAQLc8J8ywaHQQSmprZqYCWGE6sM3vzNUEWWB3kmGrEKa4sGbXhmXZCvL6NDnEJhXPDJAzu9BMQxn8CzVLqrx6BxDgPYF8gZCxtyxMckXwCaYXrxAGbjkYH69F4wYhuAdHSWgRAQCuWwYmWCA6g39j4VPge5pv962XYvxwJpvn23Y5KvNZ5S5c6crdG4f4gTCXnU36x92fKMQzsQV9K4phcuNvMWkpqVB6xMA5aPzUeHcGytD93dG8D52P5BxsgaJJE6QqDrk3Y2vyLw9ZEbJhPRJxbuBKVCBtVx26Ldd46dq5eyyzmNEyQGLrjQ4qd978VtG8TNT5rkn4ETJQEju5HfCBbjm3urGLFVqxhGVawecT4YM9Rry4EqXWkRJGTFQWQRnweUFbKNbVTC9NxcXEp6K5rSPEy9trb5UYLYhhMJ9fWSBMuenGRjNSJxeurMRCaxPpNppBLFnp8qW5ezfHgCBpEjkSNNzP4uXMZFAXmdUfJ8XQdPTWuYfdHYc5TZWnzrdq9wcfFQRDpDB2zX5Myu96krDt9vA7wNKfYwkSczA6qUQV66jA8nV4Cs38cDAKVBXnxz22ddAVrPv8ajpu7hgBtULMURjvLt94Nc5FDKw79CTTQxffWEj9BJCDCpQnTufmT8xenywwVJvtj49yv2MP2mGECrVDRmcGUAYBKR8G6ZnFAYDVC9UhY46FGWDcyVX3HKwgtHeb45Ww7dsW8JdMnZYctaEU585GZmqTJp2LcAWRcQPH25JewnPX8pjzVpJNcy7avfA2bcU86bfASvQBDUCrhjgRmK2ECR6vzPwTsYKRgFrDqb62FeMdrKgJ9vKs435T5ACN7MNtdRXHQ4fj5pNpUMDW26Wd7tt9bkBTqEGf" - - impersonation: - - impersonator: admin - users: ["*"] - auth_key: admin:dev diff --git a/e2e-tests/cypress/fixtures/hiddenAllAppsSettings.yaml b/e2e-tests/cypress/fixtures/hiddenAllAppsSettings.yaml index b05d7df4..142cc3c8 100644 --- a/e2e-tests/cypress/fixtures/hiddenAllAppsSettings.yaml +++ b/e2e-tests/cypress/fixtures/hiddenAllAppsSettings.yaml @@ -1,33 +1,20 @@ readonlyrest: - access_control_rules: - - name: "Kibana service account - user/pass" - verbosity: error - auth_key: kibana:kibana - - - name: ADMIN_GRP - groups: [admins_group] - kibana_hide_apps: [ "Enterprise Search", "Observability", "Elasticsearch", "Analytics", "Management"] - kibana_access: admin + access_control_rules: - # <-- related to ECK environment --> - - name: 'Kibana service account - token' - verbosity: error - token_authentication: - token: 'Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}' - username: service_account + - name: "Kibana service account - user/pass" + verbosity: error + auth_key: kibana:kibana - - name: 'PROBE' - verbosity: error - auth_key: 'elastic-internal-probe:${INTERNAL_PROBE_PASS}' + - name: ADMIN_GRP + groups: [admins_group] + kibana_hide_apps: [ "Enterprise Search", "Observability", "Elasticsearch", "Analytics", "Management"] + kibana_access: admin - - name: 'ELASTIC-INTERNAL' - verbosity: error - auth_key: 'elastic-internal:${INTERNAL_USR_PASS}' - # - - users: - - username: admin - auth_key: admin:dev - groups: - - id: admins_group - name: administrators + users: + - username: admin + auth_key: admin:dev + groups: + - id: admins_group + name: administrators +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/hiddenHomePageSettings.yaml b/e2e-tests/cypress/fixtures/hiddenHomePageSettings.yaml index 8465af65..c40f315e 100644 --- a/e2e-tests/cypress/fixtures/hiddenHomePageSettings.yaml +++ b/e2e-tests/cypress/fixtures/hiddenHomePageSettings.yaml @@ -1,32 +1,20 @@ readonlyrest: + access_control_rules: - access_control_rules: - - name: "Kibana service account - user/pass" - verbosity: error - auth_key: kibana:kibana - - - name: ADMIN_GRP - groups: [admins_group] - kibana_hide_apps: [ "Home"] - kibana_access: admin - # <-- related to ECK environment --> - - name: 'Kibana service account - token' - verbosity: error - token_authentication: - token: 'Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}' - username: service_account + - name: "Kibana service account - user/pass" + verbosity: error + auth_key: kibana:kibana - - name: 'PROBE' - verbosity: error - auth_key: 'elastic-internal-probe:${INTERNAL_PROBE_PASS}' + - name: ADMIN_GRP + groups: [admins_group] + kibana_hide_apps: [ "Home"] + kibana_access: admin - - name: 'ELASTIC-INTERNAL' - verbosity: error - auth_key: 'elastic-internal:${INTERNAL_USR_PASS}' - # - users: - - username: admin - auth_key: admin:dev - groups: - - id: admins_group - name: administrators \ No newline at end of file + users: + - username: admin + auth_key: admin:dev + groups: + - id: admins_group + name: administrators +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/hiddenSpaceManagementSettings.yaml b/e2e-tests/cypress/fixtures/hiddenSpaceManagementSettings.yaml index 5174cff2..4fcd1d2a 100644 --- a/e2e-tests/cypress/fixtures/hiddenSpaceManagementSettings.yaml +++ b/e2e-tests/cypress/fixtures/hiddenSpaceManagementSettings.yaml @@ -1,32 +1,19 @@ readonlyrest: - access_control_rules: - - name: 'Kibana service account - user/pass' - verbosity: error - auth_key: kibana:kibana - - - name: ADMIN_GRP - groups: [admins_group] - kibana_hide_apps: ['Management|Stack Management'] - kibana_access: admin - # <-- related to ECK environment --> - - name: 'Kibana service account - token' - verbosity: error - token_authentication: - token: 'Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}' - username: service_account + access_control_rules: + - name: 'Kibana service account - user/pass' + verbosity: error + auth_key: kibana:kibana - - name: 'PROBE' - verbosity: error - auth_key: 'elastic-internal-probe:${INTERNAL_PROBE_PASS}' + - name: ADMIN_GRP + groups: [admins_group] + kibana_hide_apps: ['Management|Stack Management'] + kibana_access: admin - - name: 'ELASTIC-INTERNAL' - verbosity: error - auth_key: 'elastic-internal:${INTERNAL_USR_PASS}' - # - - users: - - username: admin - auth_key: admin:dev - groups: - - id: admins_group - name: administrators \ No newline at end of file + users: + - username: admin + auth_key: admin:dev + groups: + - id: admins_group + name: administrators +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/reportingSettings.yaml b/e2e-tests/cypress/fixtures/reportingSettings.yaml index b5f11de1..d98cce6d 100644 --- a/e2e-tests/cypress/fixtures/reportingSettings.yaml +++ b/e2e-tests/cypress/fixtures/reportingSettings.yaml @@ -26,22 +26,6 @@ readonlyrest: - name: "Kibana service account - user/pass" verbosity: error auth_key: kibana:kibana - - # <-- related to ECK environment --> - - name: "Kibana service account - token" - verbosity: error - token_authentication: - token: "Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}" - username: service_account - - - name: "PROBE" - verbosity: error - auth_key: "elastic-internal-probe:${INTERNAL_PROBE_PASS}" - - - name: "ELASTIC-INTERNAL" - verbosity: error - auth_key: "elastic-internal:${INTERNAL_USR_PASS}" - # - name: PERSONAL_GRP groups: [personal_group] @@ -85,3 +69,5 @@ readonlyrest: - impersonator: admin users: ["*"] auth_key: admin:dev +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/roSettings.yaml b/e2e-tests/cypress/fixtures/roSettings.yaml index bf23f6f1..798e99a2 100644 --- a/e2e-tests/cypress/fixtures/roSettings.yaml +++ b/e2e-tests/cypress/fixtures/roSettings.yaml @@ -26,22 +26,6 @@ readonlyrest: - name: "Kibana service account - user/pass" verbosity: error auth_key: kibana:kibana - - # <-- related to ECK environment --> - - name: "Kibana service account - token" - verbosity: error - token_authentication: - token: "Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}" - username: service_account - - - name: "PROBE" - verbosity: error - auth_key: "elastic-internal-probe:${INTERNAL_PROBE_PASS}" - - - name: "ELASTIC-INTERNAL" - verbosity: error - auth_key: "elastic-internal:${INTERNAL_USR_PASS}" - # - name: PERSONAL_GRP groups: [personal_group] @@ -85,3 +69,5 @@ readonlyrest: - impersonator: admin users: ["*"] auth_key: admin:dev +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/roStrictSettings.yaml b/e2e-tests/cypress/fixtures/roStrictSettings.yaml index 198d4273..204193a6 100644 --- a/e2e-tests/cypress/fixtures/roStrictSettings.yaml +++ b/e2e-tests/cypress/fixtures/roStrictSettings.yaml @@ -26,23 +26,7 @@ readonlyrest: - name: "Kibana service account - user/pass" verbosity: error auth_key: kibana:kibana - - # <-- related to ECK environment --> - - name: "Kibana service account - token" - verbosity: error - token_authentication: - token: "Bearer ${KIBANA_SERVICE_ACCOUNT_TOKEN}" - username: service_account - - - name: "PROBE" - verbosity: error - auth_key: "elastic-internal-probe:${INTERNAL_PROBE_PASS}" - - name: "ELASTIC-INTERNAL" - verbosity: error - auth_key: "elastic-internal:${INTERNAL_USR_PASS}" - # - - name: PERSONAL_GRP groups: [personal_group] <<: *common-rules @@ -85,3 +69,5 @@ readonlyrest: - impersonator: admin users: ["*"] auth_key: admin:dev +readonlyrest_kbn: + cookiePass: '12312313123213123213123adadasdasdasd' diff --git a/e2e-tests/cypress/fixtures/settingsWithReadonlyRestKbn.yml b/e2e-tests/cypress/fixtures/settingsWithReadonlyRestKbn.yml deleted file mode 100644 index 46a94527..00000000 --- a/e2e-tests/cypress/fixtures/settingsWithReadonlyRestKbn.yml +++ /dev/null @@ -1,76 +0,0 @@ -helpers: - ckr: &common-kibana-rules - access: rw - hide_apps: ["Enterprise Search|Overview", "Observability"] - index: ".kibana_@{acl:current_group}" - - ag: &all-groups - groups: - - id: admins_group - name: administrators - - id: infosec_group - name: infosec - - id: template_group - name: template - -readonlyrest: - response_if_req_forbidden: Forbidden by ReadonlyREST ES plugin - audit: - enabled: true - outputs: - - type: index - index_template: "'readonlyrest_audit_'yyyy-MM-dd" - - access_control_rules: - - - name: "Kibana service account - user/pass" - verbosity: error - auth_key: kibana:kibana - - - name: PERSONAL_GRP - groups: [Personal] - kibana: - <<: *common-kibana-rules - index: ".kibana_@{user}" - - - name: ADMIN_GRP - groups: [admins_group] - kibana: - <<: *common-kibana-rules - access: admin - metadata: - alert_message: "Dear @{acl:user}" - - - name: infosec - groups: [infosec_group] - kibana: - <<: *common-kibana-rules - hide_apps: ["Enterprise Search|Overview", "Observability", "Management"] - - - name: Template Tenancy - groups: [template_group] - kibana: - <<: *common-kibana-rules - - users: - - username: admin - auth_key: admin:dev - <<: *all-groups - - - username: user1 - auth_key: user1:dev - <<: *all-groups - -readonlyrest_kbn: - cookiePass: '12312313123213123213123adadasdasdasd' - logLevel: 'trace' - logPrettyPrintEnabled: true - whitelistedPaths: [.*/api/status$] - clearSessionOnEvents: [login, tenancyHop] - sessions_probe_interval_seconds: 60 - store_sessions_in_index: true - login_title: Loaded from index! - login_subtitle: 'PRO/Enterprise: You should see a red border, a tiny unicorn logo, a two column page, and this text. You should see none of these customisation when testing ROR Free.' - login_custom_logo: 'https://i.imgur.com/MdRBUfV.gif' - login_html_head_inject: '' - login_custom_js_inject_file: '/usr/share/kibana/custom_login.js' diff --git a/e2e-tests/cypress/plugins/index.ts b/e2e-tests/cypress/plugins/index.ts index 7a60a0ca..61323bc9 100644 --- a/e2e-tests/cypress/plugins/index.ts +++ b/e2e-tests/cypress/plugins/index.ts @@ -29,6 +29,47 @@ const formatLoggerData = (data: unknown) => compact: true }); +const NON_JSON_RETRY_ATTEMPTS = 5; +const NON_JSON_RETRY_DELAY_MS = 2000; + +const sleep = (ms: number): Promise => new Promise(resolve => setTimeout(resolve, ms)); + +// Right after a Kibana restart, ROR-KBN can still be finishing its own settings load (an ES +// round trip) while Kibana's core HTTP server already answers requests - a request landing in +// that window gets served the plain Kibana login page instead of the expected JSON API response. +// Retrying a few times rides out that window instead of failing the whole run on it. Only the +// content-type is inspected here (not the body), so the response stream is left untouched for +// the caller to read exactly as before. +// `createInit` is a factory (not a static object) because a retried attempt needs its own +// request body - a FormData upload's underlying stream can only be read once. +const fetchWithJsonRetry = async (url: string, createInit: () => Parameters[1]): Promise => { + let response: Response; + for (let attempt = 1; attempt <= NON_JSON_RETRY_ATTEMPTS; attempt++) { + // eslint-disable-next-line no-await-in-loop + response = await fetch(url, createInit()); + const contentType = response.headers.get('content-type') || ''; + + // The startup race serves Kibana's login page (text/html) in place of the expected + // response - that's the only shape worth retrying. Endpoints legitimately answer with + // all sorts of non-JSON content (204 empty, application/octet-stream, plain text, ...), + // and retrying those turns an already-succeeded call (e.g. DELETE) into a second request + // that 404s once the first one already took effect. + const looksLikeStartupRace = contentType.includes('text/html'); + + if (!looksLikeStartupRace || attempt === NON_JSON_RETRY_ATTEMPTS) { + return response; + } + + console.log( + `Got HTML response (content-type: ${contentType || 'none'}) for ${url} - ROR-KBN might still be starting up. Retrying (${attempt}/${NON_JSON_RETRY_ATTEMPTS})...` + ); + // eslint-disable-next-line no-await-in-loop + await sleep(NON_JSON_RETRY_DELAY_MS); + } + + return response!; +}; + module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => { on('task', { async httpCall(options: HttpCallOptions): Promise { @@ -40,7 +81,12 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) }); try { - const response: Response = await fetch(url, { method, headers, body: body ?? undefined, agent }); + const response: Response = await fetchWithJsonRetry(url, () => ({ + method, + headers, + body: body ?? undefined, + agent + })); if (!response.ok && failOnStatusCode) { throw new Error( @@ -81,25 +127,22 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) secureProtocol: 'TLSv1_2_method' }); - const form = new FormData(); - form.append('file', file.fileBinaryContent, { - filename: file.fileName, - contentType: 'application/octet-stream' - }); + const buildForm = (): { form: FormData; combinedHeaders: { [key: string]: string } } => { + const form = new FormData(); + form.append('file', file.fileBinaryContent, { + filename: file.fileName, + contentType: 'application/ndjson' + }); - const combinedHeaders: { [key: string]: string } = { - ...headers, - ...form.getHeaders() + return { form, combinedHeaders: { ...headers, ...form.getHeaders() } }; }; const method = 'POST'; try { - const response: Response = await fetch(url, { - method, - headers: combinedHeaders, - body: form, - agent + const response: Response = await fetchWithJsonRetry(url, () => { + const { form, combinedHeaders } = buildForm(); + return { method, headers: combinedHeaders, body: form, agent }; }); if (!response.ok) { @@ -117,7 +160,7 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) console.error('HTTP Request failed:', { error: (error as Error).message, url, - combinedHeaders, + headers, file }); throw error; diff --git a/e2e-tests/cypress/support/commands.ts b/e2e-tests/cypress/support/commands.ts index 8d3d5bc3..1ddecf5a 100644 --- a/e2e-tests/cypress/support/commands.ts +++ b/e2e-tests/cypress/support/commands.ts @@ -1,10 +1,12 @@ import '@testing-library/cypress/add-commands'; import 'cypress-network-idle'; +import * as semver from 'semver'; +import { getKibanaVersion } from './helpers'; import { capture as clipboardCapture } from './clipboardCapture'; Cypress.Commands.add( 'kbnPost', - ({ endpoint, credentials, payload, currentGroupHeader, impersonating, headers }, ...args) => { + ({ endpoint, credentials, payload, currentGroupHeader, impersonating, headers }, ...args) => cy.kbnRequest({ method: 'POST', endpoint, @@ -13,8 +15,7 @@ Cypress.Commands.add( currentGroupHeader, headers, impersonating - }); - } + }) as Cypress.Chainable ); Cypress.Commands.add('esPost', ({ endpoint, credentials, payload }, ...args) => @@ -47,6 +48,7 @@ Cypress.Commands.add('esPut', ({ endpoint, credentials, payload }, ...args) => Cypress.Commands.add('kbnImport', ({ endpoint, credentials, fixtureFilename, currentGroupHeader }, ...args) => uploadFile(`${Cypress.config().baseUrl}/${endpoint}`, credentials, fixtureFilename, { 'kbn-xsrf': 'true', + 'elastic-api-version': '2023-10-31', ...(currentGroupHeader ? { 'x-ror-tenancy-id': currentGroupHeader } : {}) }) ); @@ -65,14 +67,12 @@ Cypress.Commands.add( }) as Cypress.Chainable ); -Cypress.Commands.add( - 'esGet', - ({ endpoint, credentials }, ...args) => - cy.esRequest({ - method: 'GET', - endpoint, - credentials - }) as Cypress.Chainable +Cypress.Commands.add('esGet', ({ endpoint, credentials }, ...args) => + cy.esRequest({ + method: 'GET', + endpoint, + credentials + }) as Cypress.Chainable ); Cypress.Commands.add( @@ -135,7 +135,7 @@ function httpCall( authorization: `Basic ${btoa(credentials)}`, ...headers }, - body: payload ? JSON.stringify(payload) : null, + body: payload ? (typeof payload === 'string' ? payload : JSON.stringify(payload)) : null, failOnStatusCode }; @@ -203,21 +203,23 @@ Cypress.Commands.add('urlShouldMatch', (urlPattern: string) => { return cy.url().should('match', new RegExp(`${baseUrl}${escapedPath}${suffix}$`)); }); -// .its() re-reads the property on every retry, which .then() would not - see clipboardCapture.ts. +// .its() re-reads the property on every retry, which .then() would not — see clipboardCapture.ts. Cypress.Commands.add('getValueFromClipboard', () => cy.wrap(clipboardCapture, { log: false }).its('text')); -// Cypress 15 types cy.wait's alias parameter as `@${string}`; mirroring it here means a forgotten -// '@' prefix is a compile error instead of a silent numeric wait. -Cypress.Commands.add( - 'waitForResponse', - (alias: `@${string}`) => - cy.wait(alias).then(({ response }) => { - if (!response) throw new Error(`Expected a response for ${alias}`); - return response; - }) as unknown as Cypress.Chainable<{ statusCode: number }> +// Cypress 15 types cy.wait's alias parameter as `@${string}`; mirroring it here means a +// forgotten '@' prefix is a compile error instead of a silent numeric-wait. +Cypress.Commands.add('waitForResponse', (alias: `@${string}`) => + cy.wait(alias).then(({ response }) => { + if (!response) throw new Error(`Expected a response for ${alias}`); + return response; + }) as unknown as Cypress.Chainable<{ statusCode: number }> ); Cypress.on('uncaught:exception', (err, runnable, promise) => { + const kibanaVersion = getKibanaVersion(); + const isKibana8x = semver.satisfies(kibanaVersion, '>=8.0.0 <9.0.0'); + const isKibana819 = semver.satisfies(kibanaVersion, '>=8.19.0 <8.20.0'); + /** * Kibana keeps polling in the background (task manager, alerting, telemetry) while a test tears * down. When the previous attempt's page is being logged out, one of those fetches can answer @@ -246,9 +248,12 @@ Cypress.on('uncaught:exception', (err, runnable, promise) => { err.message.includes('Markdown content is required in [readOnly] mode') || // kibana 8.13.0 throws this error on sample data canvas open err.message.includes('e.toSorted is not a function') || // kibana 8.15.0 throws this error on report generation err.message.includes('Not Found') || // kibana 9.0.0-beta1 throws: Uncaught (in promise) http_fetch_error_HttpFetchError: Not Found - err.message.includes('Loading chunk') || // kibana 9.3.2 fails to fetch lazily loaded plugin chunks; affects every spec, so it stays global err.message.includes("Cannot read properties of undefined (reading 'id')") || // kibana 9.x Discover throws when opening with no data views in the tenant - err.message.includes('endpoint is ignored by ReadonlyREST plugin') // unsupportedEndpointsFilter.ts intercepts Kibana security endpoints with 501; some callers lack try-catch + err.message.includes('endpoint is ignored by ReadonlyREST plugin') || // unsupportedEndpointsFilter.ts intercepts Kibana security endpoints with 501; some callers lack try-catch + err.message.includes('Loading chunk') || // kibana 9.3.2 fails to fetch lazily loaded plugin chunks; affects every spec, so it stays global + (isKibana8x && err.message.includes('ChunkLoadError')) || // kibana 8.x lazily loads plugin chunks; a reload can interrupt that load + (isKibana8x && err.message.includes('executing a cancelled action')) || // kibana 8.x plugin lifecycle throws this on reload; can surface after the triggering test ends, so it must be suppressed globally (cy.on() inside a single it() doesn't cover afterEach) + (isKibana819 && err.message.includes('toUpperCase is not a function')) // kibana 8.19.x throws this as an unhandled promise rejection from its own notifications module after cy.reload(); reproduced via automatic-tests/run.sh loop against User-settings.cy.ts ) { return false; } diff --git a/e2e-tests/cypress/support/e2e.ts b/e2e-tests/cypress/support/e2e.ts index 20eb009b..e8a6ac82 100644 --- a/e2e-tests/cypress/support/e2e.ts +++ b/e2e-tests/cypress/support/e2e.ts @@ -19,7 +19,8 @@ import { installClipboardCapture, resetClipboardCapture } from './clipboardCaptu // Alternatively you can use CommonJS syntax: // require('./commands') -// Record what the app copies, so the specs never depend on the OS clipboard - see + +// Record what the app copies, so the specs never depend on the OS clipboard — see // clipboardCapture.ts for why Chromium 138 makes that necessary. Cypress.on('window:before:load', installClipboardCapture); beforeEach(resetClipboardCapture); @@ -52,7 +53,8 @@ declare global { endpoint, credentials, currentGroupHeader, - failOnStatusCode + failOnStatusCode, + headers }: { endpoint: string; credentials: string; diff --git a/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts b/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts index 11f2c3c1..e7c3aff3 100644 --- a/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts +++ b/e2e-tests/cypress/support/helpers/EsApiAdvancedClient.ts @@ -1,5 +1,5 @@ import { recurse } from 'cypress-recurse'; -import { EsApiClient } from './EsApiClient'; +import { EsApiClient, GetIndices } from './EsApiClient'; export class EsApiAdvancedClient extends EsApiClient { public pruneAllReportingIndices(): void { @@ -120,6 +120,26 @@ export class EsApiAdvancedClient extends EsApiClient { return this.indices().then(result => result.filter(index => index.index.startsWith('.reporting'))); } + // A tenant/custom Kibana index (e.g. under multiTenancyEnabled: false) is provisioned lazily, + // on the first authenticated interaction after Kibana restarts into that config - checking for + // it immediately after login is a timing race, not a guarantee. + public waitForIndexReady(pattern: string, timeout = 40000, interval = 1000): Cypress.Chainable { + // Not findIndicesByPattern: _cat/indices/ 404s (and throws) while the index doesn't + // exist yet, which is exactly the state being waited out here. Listing all indices and + // filtering client-side never 404s, so recurse actually gets to retry. + return recurse( + () => this.indices().then(result => result.find(({ index }) => index === pattern)), + (foundIndex): boolean => + Boolean(foundIndex && foundIndex.health === 'green' && Number.parseInt(foundIndex['docs.count'], 10) > 0), + { + timeout, + delay: interval, + log: foundIndex => cy.log(`Waiting for index ${pattern} to be ready: ${JSON.stringify(foundIndex)}`), + error: `Index ${pattern} never became ready (green with docs)` + } + ); + } + public getAllReportingDataStreamSegments(indexName: string) { cy.log('Getting all reporting data stream segments...'); return this.indices().then(result => diff --git a/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts b/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts index 84b946c5..3ddefdd3 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts @@ -3,11 +3,12 @@ import { KbnApiClient } from './KbnApiClient'; export class KbnApiAdvancedClient extends KbnApiClient { public deleteSavedObjects(credentials: string, group?: string): void { cy.log(`Get all saved objects for the ${credentials}`); - this.getSavedObjects(credentials, group).then(result => { + this.getSavedObjects(credentials, group, { failOnStatusCode: false }).then(result => { // This cleanup races the stack it cleans: under resetKibanaIndexToTemplate the tenancy // index can be mid-reset, and a session sweep or config restart can log the request out, - // in which case the _find answers with a login page instead of the find JSON. An index - // that is already resetting has nothing left to clean, so treat that as the empty list. + // in which case the _find answers with a login page instead of the find JSON (or, if the + // ACL evaluates the mid-reset tenancy index as inaccessible, a 403). An index that is + // already resetting has nothing left to clean, so treat any of that as the empty list. (result?.saved_objects ?? []).forEach(savedObject => { cy.log(`Remove ${savedObject.id} saved object for ${credentials}`); // Best effort: an object listed a moment ago can already be gone (404). Losing that @@ -54,7 +55,7 @@ export class KbnApiAdvancedClient extends KbnApiClient { cy.task('checkKibanaHealth', { url: baseUrl }).then((status): Cypress.Chainable => { if (!isServing(status)) { cy.log('⏳ Kibana went down, waiting for it to come back'); - return cy.wrap(undefined); + return cy.then(() => undefined); } if (attempts >= downRetries) { @@ -85,7 +86,7 @@ export class KbnApiAdvancedClient extends KbnApiClient { if (kibana8xAndAboveSuccessStatus || kibana7xSuccessStatus) { cy.log('✅ Kibana is healthy'); - return cy.wrap(undefined); + return cy.then(() => undefined); } if (attempts >= retries) { diff --git a/e2e-tests/cypress/support/helpers/KbnApiClient.ts b/e2e-tests/cypress/support/helpers/KbnApiClient.ts index 5a3b8525..caffbb3b 100644 --- a/e2e-tests/cypress/support/helpers/KbnApiClient.ts +++ b/e2e-tests/cypress/support/helpers/KbnApiClient.ts @@ -24,11 +24,16 @@ export class KbnApiClient { }); } - public getSavedObjects(credentials: string, group?: string): Cypress.Chainable { + public getSavedObjects( + credentials: string, + group?: string, + { failOnStatusCode = true }: { failOnStatusCode?: boolean } = {} + ): Cypress.Chainable { return cy.kbnGet({ endpoint: 'api/saved_objects/_find?type=index-pattern&type=search&type=visualization&type=dashboard&type=url', credentials, - currentGroupHeader: group + currentGroupHeader: group, + failOnStatusCode }); } diff --git a/e2e-tests/cypress/support/helpers/RorApiClient.ts b/e2e-tests/cypress/support/helpers/RorApiClient.ts index c8155a83..30629e11 100644 --- a/e2e-tests/cypress/support/helpers/RorApiClient.ts +++ b/e2e-tests/cypress/support/helpers/RorApiClient.ts @@ -1,14 +1,27 @@ export class RorApiClient { - public configureRorIndexMainSettings(fixtureYamlFileName: string): Cypress.Chainable { - return cy.fixture(fixtureYamlFileName).then(yamlContent => { - cy.esPost({ - endpoint: '_readonlyrest/admin/config', + public configureRorIndexMainSettings(yamlContent: string): Cypress.Chainable { + return cy + .kbnPost<{ status: string; message: string }>({ + endpoint: 'api/ror/settings?override=true', + headers: { + 'Content-Type': 'application/yaml' + }, credentials: Cypress.env().kibanaUserCredentials, - payload: { - settings: `${yamlContent}` + payload: yamlContent + }) + .then(response => { + // The endpoint no-ops (status: FAILURE) when the posted content is already the active + // config - e.g. two specs in a row both resetting to the same default fixture. That's + // the desired state, not an error; only a genuinely different failure should throw. + if (response.status !== 'SUCCESS' && response.message !== 'Current settings are already loaded') { + throw new Error(`Failed to configure ROR index main settings: ${JSON.stringify(response)}`); } - }); - }); + }) + .then(() => undefined); + } + + public configureRorIndexMainSettingsFromFixture(fixtureYamlFileName: string): Cypress.Chainable { + return cy.fixture(fixtureYamlFileName).then(yaml => this.configureRorIndexMainSettings(yaml)); } public configureRorIndexTestSettings(fixtureYamlFileName: string, ttlInSeconds: number): Cypress.Chainable { diff --git a/e2e-tests/cypress/support/helpers/RorApiInternalKbnClient.ts b/e2e-tests/cypress/support/helpers/RorApiInternalKbnClient.ts index 8d4102e8..6a997b0c 100644 --- a/e2e-tests/cypress/support/helpers/RorApiInternalKbnClient.ts +++ b/e2e-tests/cypress/support/helpers/RorApiInternalKbnClient.ts @@ -38,7 +38,7 @@ export class RorApiInternalKbnClient { * Rewrites kibana.yml and restarts Kibana, then waits for it to serve again. The restart resets * the connection before the reply arrives, so a transport error is a normal outcome here. */ - public changeKibanaConfig(fixtureYamlFileName: string) { + public changeKibanaConfig(fixtureYamlFileName: string): Cypress.Chainable { return cy .fixture(fixtureYamlFileName) .then(yamlContent => @@ -54,13 +54,13 @@ export class RorApiInternalKbnClient { allowTransportError: true }) ) - .then(response => { + .then((response: unknown) => { const status = (response as { status?: string } | null)?.status; const restarted = status === 'SUCCESS' || status === 'TRANSPORT_ERROR'; if (!restarted) { cy.log(`kibanaConfig answered ${status ?? 'nothing recognisable'}: no restart to wait for`); - return; + return cy.then(() => undefined); } return kbnApiAdvancedClient.waitForKibanaRestart(requiredBaseUrl()); diff --git a/e2e-tests/cypress/support/helpers/parseKibanaSettings.ts b/e2e-tests/cypress/support/helpers/parseKibanaSettings.ts new file mode 100644 index 00000000..69cc2fc9 --- /dev/null +++ b/e2e-tests/cypress/support/helpers/parseKibanaSettings.ts @@ -0,0 +1,8 @@ +import * as yaml from 'js-yaml'; + +export function parseKbnSettings(settings: string): object { + const lines = settings.split('\n').filter(l => l.trim().length > 0); + if (!lines.length) return {}; + const indent = Math.min(...lines.map(l => /^(\s*)/.exec(l)![1].length)); + return (yaml.load(lines.map(l => l.slice(indent)).join('\n')) as object) ?? {}; +} diff --git a/e2e-tests/cypress/support/page-objects/Dashboard.ts b/e2e-tests/cypress/support/page-objects/Dashboard.ts index 57c8fae8..f7c45e81 100644 --- a/e2e-tests/cypress/support/page-objects/Dashboard.ts +++ b/e2e-tests/cypress/support/page-objects/Dashboard.ts @@ -23,7 +23,7 @@ export class Dashboard { static verifyDashboardExists(dashboardName: string) { cy.log(`Verifying that dashboard "${dashboardName}" exists`); - cy.get('[data-test-subj*="dashboardListingTitleLink"]').contains(dashboardName).should('exist'); + cy.get('[data-test-subj*="dashboardListingTitleLink"]', { timeout: 20000 }).contains(dashboardName).should('exist'); } static verifyDashboardNotExist(dashboardName: string) { diff --git a/e2e-tests/cypress/support/page-objects/Settings.ts b/e2e-tests/cypress/support/page-objects/Settings.ts index b9445954..11a893d9 100644 --- a/e2e-tests/cypress/support/page-objects/Settings.ts +++ b/e2e-tests/cypress/support/page-objects/Settings.ts @@ -1,6 +1,9 @@ +import * as yaml from 'js-yaml'; + import { rorApiClient } from '../helpers/RorApiClient'; import { RorMenu } from './RorMenu'; import { SecuritySettings } from './SecuritySettings'; +import { parseKbnSettings } from '../helpers/parseKibanaSettings'; export class Settings { static open() { @@ -34,9 +37,15 @@ export class Settings { static clickSaveButton() { cy.log('Save file settings'); - cy.intercept('POST', '/pkp/api/settings').as('saveSettings'); + SecuritySettings.getIframeBody().contains('Save').click(); - cy.waitForResponse('@saveSettings').then(response => { + } + + static confirmSaveModal() { + cy.log('Confirm settings save modal'); + cy.intercept('POST', '/pkp/api/settings*').as('confirmSaveSettings'); + SecuritySettings.getIframeBody().contains('Save anyway').click(); + cy.waitForResponse('@confirmSaveSettings').then(response => { expect(response.statusCode).to.eq(200); }); } @@ -86,7 +95,20 @@ export class Settings { } static setSettingsData(fixtureYamlSettingsFileName: string) { - cy.log('Set settings data from file ' + fixtureYamlSettingsFileName); - rorApiClient.configureRorIndexMainSettings(fixtureYamlSettingsFileName); + cy.log(`Set settings data from file ${fixtureYamlSettingsFileName}`); + rorApiClient.configureRorIndexMainSettingsFromFixture(fixtureYamlSettingsFileName); + } + + static setReadonlyRestKbnSettings(readonlyRestKbnSettings = '') { + cy.fixture('defaultReadonlyRestEsSettings.yaml').then(esYamlSettings => { + const merged = { + ...(yaml.load(esYamlSettings) as object), + readonlyrest_kbn: { + cookiePass: '12312313123213123213123adadasdasdasd', + ...parseKbnSettings(readonlyRestKbnSettings) + } + }; + rorApiClient.configureRorIndexMainSettings(yaml.dump(merged)); + }); } }