Skip to content

Commit

Permalink
Consume changes from main, fixes linter and fixes tests
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Mar 14, 2024
1 parent 942b2f7 commit e33907e
Show file tree
Hide file tree
Showing 20 changed files with 528 additions and 31 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/cypress-test-multidatasources-disabled-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: E2E multi datasources disabled workflow

on: [ push, pull_request ]

env:
OPENSEARCH_VERSION: '3.0.0'
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
PLUGIN_NAME: opensearch-security
OPENSEARCH_INITIAL_ADMIN_PASSWORD: myStrongPassword123!

jobs:
tests:
name: Run Cypress multidatasources tests
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Branch
uses: actions/checkout@v3

# Configure the Dashboard for multi datasources disabled (default)
- name: Create OpenSearch Dashboards Config
if: ${{ runner.os == 'Linux' }}
run: |
cat << 'EOT' > opensearch_dashboards_multidatasources.yml
server.host: "localhost"
opensearch.hosts: ["https://localhost:9200"]
opensearch.ssl.verificationMode: none
opensearch.username: "kibanaserver"
opensearch.password: "kibanaserver"
opensearch.requestHeadersWhitelist: [ authorization,securitytenant ]
opensearch_security.multitenancy.enabled: false
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"]
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
opensearch_security.cookie.secure: false
data_source.enabled: false
home.disableWelcomeScreen: true
EOT
- name: Run Cypress Tests
uses: ./.github/actions/run-cypress-tests
with:
dashboards_config_file: opensearch_dashboards_multidatasources.yml
yarn_command: 'yarn cypress:run --browser chrome --headless --spec "test/cypress/e2e/multi-datasources/multi_datasources_disabled.spec.js"'
120 changes: 120 additions & 0 deletions .github/workflows/cypress-test-multidatasources-enabled-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: E2E multi datasources enabled workflow

on: [ push, pull_request ]

env:
OPENSEARCH_VERSION: '3.0.0'
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
PLUGIN_NAME: opensearch-security
OPENSEARCH_INITIAL_ADMIN_PASSWORD: myStrongPassword123!

jobs:
tests:
name: Run Cypress multidatasources tests
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Branch
uses: actions/checkout@v3

- name: Set env
run: |
opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version")
plugin_version=$(node -p "require('./package.json').version")
echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV
shell: bash

- name: Create remote OpenSearch Config
if: ${{ runner.os == 'Linux' }}
run: |
cat << 'EOT' > remote_opensearch.yml
http.port: 9202
plugins.security.ssl.transport.pemcert_filepath: esnode.pem
plugins.security.ssl.transport.pemkey_filepath: esnode-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
plugins.security.ssl.transport.enforce_hostname_verification: false
plugins.security.ssl.http.pemcert_filepath: esnode.pem
plugins.security.ssl.http.pemkey_filepath: esnode-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem
plugins.security.allow_unsafe_democertificates: true
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn:
- 'CN=A,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'
plugins.security.nodes_dn:
- 'CN=node1.dns.a-record,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'
- 'CN=node2.dns.a-record,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
# TODO: change this back to true/just append to the created opensearch.yml the new port
# after the self-signed certs issue is fixed
plugins.security.ssl.http.enabled: false
plugins.security.restapi.roles_enabled: [all_access, security_rest_api_access]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [.plugins-ml-config, .plugins-ml-connector,
.plugins-ml-model-group, .plugins-ml-model, .plugins-ml-task, .plugins-ml-conversation-meta,
.plugins-ml-conversation-interactions, .plugins-ml-memory-meta, .plugins-ml-memory-message,
.opendistro-alerting-config, .opendistro-alerting-alert*, .opendistro-anomaly-results*,
.opendistro-anomaly-detector*, .opendistro-anomaly-checkpoints, .opendistro-anomaly-detection-state,
.opendistro-reports-*, .opensearch-notifications-*, .opensearch-notebooks, .opensearch-observability,
.ql-datasources, .opendistro-asynchronous-search-response*, .replication-metadata-store,
.opensearch-knn-models, .geospatial-ip2geo-data*, .plugins-flow-framework-config,
.plugins-flow-framework-templates, .plugins-flow-framework-state]
node.max_local_storage_nodes: 3
EOT
- name: Download security plugin and create setup scripts
uses: ./.github/actions/download-plugin
with:
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugin-name: ${{ env.PLUGIN_NAME }}
plugin-version: ${{ env.PLUGIN_VERSION }}

- name: Run Opensearch with A Single Plugin
uses: derek-ho/start-opensearch@9202
with:
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugins: "file:$(pwd)/opensearch-security.zip"
security-enabled: true
admin-password: ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }}
security_config_file: ${{ inputs.security_config_file }}
opensearch_yml_file: remote_opensearch.yml
opensearch_port: 9202

- name: Check OpenSearch is running
# Verify that the server is operational
run: |
curl http://localhost:9202/_cat/plugins -v -u admin:myStrongPassword123!
shell: bash

# Configure the Dashboard for multi datasources
- name: Create OpenSearch Dashboards Config
if: ${{ runner.os == 'Linux' }}
run: |
cat << 'EOT' > opensearch_dashboards_multidatasources.yml
server.host: "localhost"
opensearch.hosts: ["https://localhost:9200"]
opensearch.ssl.verificationMode: none
opensearch.username: "kibanaserver"
opensearch.password: "kibanaserver"
opensearch.requestHeadersWhitelist: [ authorization,securitytenant ]
opensearch_security.multitenancy.enabled: true
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"]
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
opensearch_security.cookie.secure: false
data_source.enabled: true
home.disableWelcomeScreen: true
EOT
- name: Run Cypress Tests
uses: ./.github/actions/run-cypress-tests
with:
dashboards_config_file: opensearch_dashboards_multidatasources.yml
yarn_command: 'yarn cypress:run --browser chrome --headless --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"'
4 changes: 3 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"savedObjectsManagement"
],
"optionalPlugins": [
"managementOverview"
"managementOverview",
"dataSource",
"dataSourceManagement"
],
"server": true,
"ui": true
Expand Down
18 changes: 15 additions & 3 deletions public/apps/configuration/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { EuiBreadcrumb, EuiPage, EuiPageBody, EuiPageSideBar } from '@elastic/eui';
import { flow, map, mapValues, partial } from 'lodash';
import React from 'react';
import React, { useState } from 'react';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { AppDependencies } from '../types';
import { AuditLogging } from './panels/audit-logging/audit-logging';
Expand All @@ -40,6 +40,8 @@ import { Action, RouteItem, SubAction } from './types';
import { ResourceType } from '../../../common';
import { buildHashUrl, buildUrl } from './utils/url-builder';
import { CrossPageToast } from './cross-page-toast';
import { useOpenSearchDashboards } from '../../../../../src/plugins/opensearch_dashboards_react/public';
import { SecurityPluginTopNavMenu, TopNavMenu } from './top-nav-menu';

const LANDING_PAGE_URL = '/getstarted';

Expand Down Expand Up @@ -145,6 +147,7 @@ function decodeParams(params: { [k: string]: string }): any {

export function AppRouter(props: AppDependencies) {
const setGlobalBreadcrumbs = flow(getBreadcrumbs, props.coreStart.chrome.setBreadcrumbs);
const [datasourceId, setDatasourceId] = useState(undefined);

return (
<Router basename={props.params.appBasePath}>
Expand Down Expand Up @@ -255,14 +258,23 @@ export function AppRouter(props: AppDependencies) {
path={ROUTE_MAP.tenants.href}
render={() => {
setGlobalBreadcrumbs(ResourceType.tenants);
return <TenantList tabID={'Manage'} {...props} />;
return (
<>
<TenantList tabID={'Manage'} {...props} />
</>
);
}}
/>
<Route
path={ROUTE_MAP.tenantsConfigureTab.href}
render={() => {
setGlobalBreadcrumbs(ResourceType.tenants);
return <TenantList tabID={'Configure'} {...props} />;

return (
<>
<TenantList tabID={'Configure'} {...props} />
</>
);
}}
/>
<Route
Expand Down
16 changes: 13 additions & 3 deletions public/apps/configuration/configuration-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@ import { I18nProvider } from '@osd/i18n/react';
import { AppMountParameters, CoreStart } from '../../../../../src/core/public';
import { SecurityPluginStartDependencies, ClientConfigType } from '../../types';
import { AppRouter } from './app-router';
import { DataSourceManagementPluginSetup } from '../../../../../src/plugins/data_source_management/public';

export function renderApp(
coreStart: CoreStart,
navigation: SecurityPluginStartDependencies,
securityPluginStartDeps: SecurityPluginStartDependencies,
params: AppMountParameters,
config: ClientConfigType
config: ClientConfigType,
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'],
dataSourceManagement?: DataSourceManagementPluginSetup
) {
const deps = { coreStart, navigation, params, config };
const deps = {
coreStart,
securityPluginStartDeps,
params,
config,
setHeaderActionMenu,
dataSourceManagement,
};
ReactDOM.render(
<I18nProvider>
<AppRouter {...deps} />
Expand Down
14 changes: 12 additions & 2 deletions public/apps/configuration/panels/get-started.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import {
EuiTitle,
EuiGlobalToastList,
} from '@elastic/eui';
import React from 'react';
import React, { useState } from 'react';
import { FormattedMessage } from '@osd/i18n/react';
import { setData } from 'src/plugins/vis_type_vega/public/services';
import { AppDependencies } from '../../types';
import { buildHashUrl } from '../utils/url-builder';
import { Action } from '../types';
Expand Down Expand Up @@ -159,6 +160,8 @@ const setOfSteps = [
];

export function GetStarted(props: AppDependencies) {
const [datasourceId, setDatasourceId] = useState(undefined);

let steps;
if (props.config.ui.backend_configurable) {
steps = [addBackendStep, ...setOfSteps];
Expand All @@ -170,6 +173,11 @@ export function GetStarted(props: AppDependencies) {
return (
<>
<div className="panel-restrict-width">
<SecurityPluginTopNavMenu

Check failure on line 176 in public/apps/configuration/panels/get-started.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

'SecurityPluginTopNavMenu' is not defined

Check failure on line 176 in public/apps/configuration/panels/get-started.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

'SecurityPluginTopNavMenu' is not defined

Check failure on line 176 in public/apps/configuration/panels/get-started.tsx

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

'SecurityPluginTopNavMenu' is not defined
{...props}
dataSourcePickerReadOnly={false}
random={setDatasourceId}
/>
<EuiPageHeader>
<EuiTitle size="l">
<h1>Get started</h1>
Expand Down Expand Up @@ -236,7 +244,9 @@ export function GetStarted(props: AppDependencies) {
data-test-subj="purge-cache"
onClick={async () => {
try {
await httpDelete(props.coreStart.http, API_ENDPOINT_CACHE);
await httpDelete(props.coreStart.http, API_ENDPOINT_CACHE, {
dataSourceId: datasourceId,
});
addToast(
createSuccessToast(
'cache-flush-success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ exports[`Get started (landing page) renders when backend configuration is disabl
<div
className="panel-restrict-width"
>
<SecurityPluginTopNavMenu
config={
Object {
"ui": Object {
"backend_configurable": false,
},
}
}
coreStart={
Object {
"http": 1,
}
}
dataSourcePickerReadOnly={false}
navigation={Object {}}
params={Object {}}
random={[Function]}
/>
<EuiPageHeader>
<EuiTitle
size="l"
Expand Down Expand Up @@ -258,6 +276,24 @@ exports[`Get started (landing page) renders when backend configuration is enable
<div
className="panel-restrict-width"
>
<SecurityPluginTopNavMenu
config={
Object {
"ui": Object {
"backend_configurable": true,
},
}
}
coreStart={
Object {
"http": 1,
}
}
dataSourcePickerReadOnly={false}
navigation={Object {}}
params={Object {}}
random={[Function]}
/>
<EuiPageHeader>
<EuiTitle
size="l"
Expand Down
Loading

0 comments on commit e33907e

Please sign in to comment.