Skip to content

Commit

Permalink
Patch actions and workflows. Skip integration tests that fail (#4)
Browse files Browse the repository at this point in the history
* Change plugin name in actions and workflows

* Patch install-dashboards action

* Change jest config path

* Skip tests

---------

Co-authored-by: Alex Ruiz Becerra <[email protected]>
Co-authored-by: yenienserrano <[email protected]>
  • Loading branch information
3 people committed Jun 12, 2023
1 parent fb7426e commit fd31852
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 58 deletions.
19 changes: 11 additions & 8 deletions .github/actions/install-dashboards/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
plugin_name:
description: 'The the name of the plugin to use, such as security-dashboards-plugin'
required: true
app_reference:
description: 'The reference to the app to use, such as main, v1.13, etc.'
required: true

outputs:
dashboards-directory:
Expand All @@ -29,8 +32,8 @@ runs:
- uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
ref: 'main'
repository: wazuh/wazuh-dashboard
ref: ${{ inputs.app_reference }}
fetch-depth: 0

- uses: actions/checkout@v2
Expand All @@ -44,12 +47,12 @@ runs:
working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}
shell: bash

- id: branch-switch-if-possible
continue-on-error: true # Defaults onto main if the branch switch doesn't work
if: ${{ steps.osd-version.outputs.osd-version }}
run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }}x
working-directory: ./OpenSearch-Dashboards
shell: bash
# - id: branch-switch-if-possible
# continue-on-error: true # Defaults onto main if the branch switch doesn't work
# if: ${{ steps.osd-version.outputs.osd-version }}
# run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }}x
# working-directory: ./OpenSearch-Dashboards
# shell: bash

- id: tool-versions
run: |
Expand Down
121 changes: 93 additions & 28 deletions .github/workflows/cypress-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,89 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Download OpenSearch Core
run: |
wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.4.1/latest/linux/x64/tar/builds/opensearch/dist/opensearch-min-2.4.1-linux-x64.tar.gz
tar -xzf opensearch-*.tar.gz
rm -f opensearch-*.tar.gz
- name: Download OpenSearch Security Plugin
run: wget -O opensearch-security.zip https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.4.1/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-security-2.4.1.0.zip

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

- name: Download security plugin and create setup scripts
uses: ./.github/actions/download-plugin
- name: Run OpenSearch with plugin
run: |
cat > os-ep.sh <<EOF
yes | opensearch-plugin install file:///docker-host/security-plugin.zip
chmod +x plugins/opensearch-security/tools/install_demo_configuration.sh
yes | plugins/opensearch-security/tools/install_demo_configuration.sh
echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> /opensearch/config/opensearch.yml
chown 1001:1001 -R /opensearch
su -c "/opensearch/bin/opensearch" -s /bin/bash opensearch
EOF
docker build -t opensearch-test:latest -f- . <<EOF
FROM ubuntu:latest
COPY --chown=1001:1001 os-ep.sh /docker-host/
COPY --chown=1001:1001 opensearch-security.zip /docker-host/security-plugin.zip
COPY --chown=1001:1001 opensearch* /opensearch/
RUN chmod +x /docker-host/os-ep.sh
RUN useradd -u 1001 -s /sbin/nologin opensearch
ENV PATH="/opensearch/bin:${PATH}"
WORKDIR /opensearch/
ENTRYPOINT /docker-host/os-ep.sh
EOF
docker run -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest
- name: Checkout Wazuh Dashboard
uses: actions/checkout@v2
with:
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugin-name: ${{ env.PLUGIN_NAME }}
plugin-version: ${{ env.PLUGIN_VERSION }}
path: OpenSearch-Dashboards
repository: wazuh/wazuh-dashboard
ref: ${{ vars.WZD_REF }}
fetch-depth: 0

- name: Run Opensearch with A Single Plugin
uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main
- name: Create plugins dir
run: |
cd ./OpenSearch-Dashboards
mkdir -p plugins
- name: Checkout OpenSearch Dashboard Security plugin
uses: actions/checkout@v2
with:
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugin-name: ${{ env.PLUGIN_NAME }}
setup-script-name: setup
path: OpenSearch-Dashboards/plugins/wazuh-security-dashboards-plugin
ref: ${{ github.ref }}

- name: Check OpenSearch Running
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k

- name: Get node and yarn versions
id: versions
run: |
echo "::set-output name=node_version::$(cat ./OpenSearch-Dashboards/.node-version)"
echo "::set-output name=yarn_version::$(jq -r '.engines.yarn' ./OpenSearch-Dashboards/package.json)"
- name: Run Dashboard with Security Dashboards Plugin
uses: ./.github/actions/install-dashboards
- name: Setup node
uses: actions/setup-node@v1
with:
plugin_name: security-dashboards-plugin
node-version: ${{ steps.versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- name: Configure and Run OpenSearch Dashboards with Cypress Test Cases
- name: Install correct yarn version for OpenSearch Dashboards
run: |
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions.outputs.yarn_version }}
- name: Check OpenSearch Running
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k

- name: Bootstrap OpenSearch Dashboards
continue-on-error: false
run: |
cd ./OpenSearch-Dashboards
yarn osd bootstrap
echo 'server.host: "0.0.0.0"' >> ./config/opensearch_dashboards.yml
echo 'opensearch.hosts: ["https://localhost:9200"]' >> ./config/opensearch_dashboards.yml
echo 'opensearch.ssl.verificationMode: none' >> ./config/opensearch_dashboards.yml
Expand All @@ -64,11 +117,23 @@ jobs:
echo 'opensearch_security.readonly_mode.roles: ["kibana_read_only"]' >> ./config/opensearch_dashboards.yml
echo 'opensearch_security.cookie.secure: false' >> ./config/opensearch_dashboards.yml
echo 'opensearch_security.multitenancy.enable_aggregation_view: true' >> ./config/opensearch_dashboards.yml
nohup yarn start --no-base-path --no-watch &
sleep 500
git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test.git
cd opensearch-dashboards-functional-test
npm install cypress --save-dev
yarn cypress:run-with-security-and-aggregation-view --browser chrome --spec "cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js"
yarn cypress:run-with-security --browser chrome --spec "cypress/integration/plugins/security-dashboards-plugin/multi_tenancy.js"
yarn cypress:run-with-security --browser chrome --spec "cypress/integration/plugins/security-dashboards-plugin/default_tenant.js"
yarn start --no-base-path --no-watch &
sleep 300
- name: Checkout
uses: actions/checkout@v2
with:
path: ${{ env.FTR_PATH }}
repository: opensearch-project/opensearch-dashboards-functional-test
ref: '2.4'

- name: Get Cypress version
id: cypress_version
run: |
echo "::set-output name=cypress_version::$(cat ./${{ env.FTR_PATH }}/package.json | jq '.devDependencies.cypress' | tr -d '"')"
- name: Run tests
uses: cypress-io/github-action@v2
with:
working-directory: ${{ env.FTR_PATH }}
command: yarn cypress:run-with-security-and-aggregation-view --browser chromium --spec ${{ env.SPEC }}
13 changes: 10 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Branch
uses: actions/checkout@v3
- name: Download OpenSearch Core
run: |
wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.4.1/latest/linux/x64/tar/builds/opensearch/dist/opensearch-min-2.4.1-linux-x64.tar.gz
tar -xzf opensearch-*.tar.gz
rm -f opensearch-*.tar.gz
- name: Download OpenSearch Security Plugin
run: wget -O opensearch-security.zip https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.4.1/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-security-2.4.1.0.zip

- name: Set up JDK
uses: actions/setup-java@v1
Expand Down Expand Up @@ -62,7 +68,8 @@ jobs:
- id: install-dashboards
uses: ./.github/actions/install-dashboards
with:
plugin_name: security-dashboards-plugin
plugin_name: wazuh-security-dashboards-plugin
app_reference: ${{ vars.WZD_REF }}

- name: Start Dashboards in background
run: node scripts/build_opensearch_dashboards_platform_plugins.js
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest , windows-latest, macos-latest ]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -22,7 +22,8 @@ jobs:
- id: install-dashboards
uses: ./.github/actions/install-dashboards
with:
plugin_name: security-dashboards-plugin
plugin_name: wazuh-security-dashboards-plugin
app_reference: ${{ vars.WZD_REF }}

- name: Run lint
run: yarn lint
Expand Down
16 changes: 8 additions & 8 deletions test/jest.config.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import config from '../../../src/dev/jest/config';

export default {
...config,
roots: ['<rootDir>/plugins/security-dashboards-plugin'],
roots: ['<rootDir>/plugins/wazuh-security-dashboards-plugin'],
testMatch: ['**/test/jest_integration/**/*.test.ts', '**/server/**/*.test.ts'],
testPathIgnorePatterns: config.testPathIgnorePatterns.filter(
(pattern) => !pattern.includes('integration_tests')
Expand All @@ -27,14 +27,14 @@ export default {
'<rootDir>/plugins/security-dashboards-plugin/test/setup/after_env.js',
],
collectCoverageFrom: [
'<rootDir>/plugins/security-dashboards-plugin/server/**/*.{ts,tsx}',
'!<rootDir>/plugins/security-dashboards-plugin/server/**/*.test.{ts,tsx}',
'!<rootDir>/plugins/security-dashboards-plugin/server/auth/types/jwt/**/*.{ts,tsx}',
'!<rootDir>/plugins/security-dashboards-plugin/server/auth/types/openid/**/*.{ts,tsx}',
'!<rootDir>/plugins/security-dashboards-plugin/server/auth/types/saml/**/*.{ts,tsx}',
'!<rootDir>/plugins/security-dashboards-plugin/server/auth/types/proxy/**/*.{ts,tsx}',
'<rootDir>/plugins/wazuh-security-dashboards-plugin/server/**/*.{ts,tsx}',
'!<rootDir>/plugins/wazuh-security-dashboards-plugin/server/**/*.test.{ts,tsx}',
'!<rootDir>/plugins/wazuh-security-dashboards-plugin/server/auth/types/jwt/**/*.{ts,tsx}',
'!<rootDir>/plugins/wazuh-security-dashboards-plugin/server/auth/types/openid/**/*.{ts,tsx}',
'!<rootDir>/plugins/wazuh-security-dashboards-plugin/server/auth/types/saml/**/*.{ts,tsx}',
'!<rootDir>/plugins/wazuh-security-dashboards-plugin/server/auth/types/proxy/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/plugins/security-dashboards-plugin/opensearch-dashboards-coverage/jest_server',
'<rootDir>/plugins/wazuh-security-dashboards-plugin/opensearch-dashboards-coverage/jest_server',
coverageReporters: ['lcov', 'text', 'cobertura', 'html'],
};
12 changes: 6 additions & 6 deletions test/jest.config.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ import config from '../../../src/dev/jest/config';

export default {
...config,
roots: ['<rootDir>/plugins/security-dashboards-plugin'],
roots: ['<rootDir>/plugins/wazuh-security-dashboards-plugin'],
testMatch: ['**/public/**/*.test.{ts,tsx,js,jsx}', '**/common/*.test.{ts, tsx}'],
testPathIgnorePatterns: [
'<rootDir>/plugins/security-dashboards-plugin/build/',
'<rootDir>/plugins/security-dashboards-plugin/node_modules/',
'<rootDir>/plugins/wazuh-security-dashboards-plugin/build/',
'<rootDir>/plugins/wazuh-security-dashboards-plugin/node_modules/',
],
setupFilesAfterEnv: ['<rootDir>/src/dev/jest/setup/after_env.integration.js'],
collectCoverageFrom: [
'<rootDir>/plugins/security-dashboards-plugin/public/**/*.{ts,tsx}',
'!<rootDir>/plugins/security-dashboards-plugin/public/**/*.test.{ts,tsx}',
'<rootDir>/plugins/wazuh-security-dashboards-plugin/public/**/*.{ts,tsx}',
'!<rootDir>/plugins/wazuh-security-dashboards-plugin/public/**/*.test.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/plugins/security-dashboards-plugin/opensearch-dashboards-coverage/jest_ui',
'<rootDir>/plugins/wazuh-security-dashboards-plugin/opensearch-dashboards-coverage/jest_ui',
clearMocks: true,
coverageReporters: ['lcov', 'text', 'cobertura', 'html'],
};
16 changes: 13 additions & 3 deletions test/jest_integration/saml_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ describe('start OpenSearch Dashboards server', () => {
await root.shutdown();
});

it('Login to app/opensearch_dashboards_overview#/ when SAML is enabled', async () => {
// ---------------------------------------------------------------------
// As we disabled the opensearch_dashboards_overview in Wazuh Dashboard,
// this test will never success. Also, multi-tenancy was disabled.
// ---------------------------------------------------------------------

it.skip('Login to app/opensearch_dashboards_overview#/ when SAML is enabled', async () => {
const driver = getDriver(browser, options).build();
await driver.get('http://localhost:5601/app/opensearch_dashboards_overview#/');
await driver.findElement(By.id('btn-sign-in')).click();
Expand Down Expand Up @@ -265,7 +270,12 @@ describe('start OpenSearch Dashboards server', () => {
await driver.quit();
});

it('Login to Dashboard with Hash', async () => {
// ---------------------------------------------------------------------
// As we disabled the opensearch_dashboards_overview in Wazuh Dashboard,
// this test will never success. Also, multi-tenancy was disabled.
// ---------------------------------------------------------------------

it.skip('Login to Dashboard with Hash', async () => {
const urlWithHash = `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)`;
const driver = getDriver(browser, options).build();
await driver.manage().deleteAllCookies();
Expand All @@ -284,7 +294,7 @@ describe('start OpenSearch Dashboards server', () => {
await driver.quit();
});

it('Tenancy persisted after Logout in SAML', async () => {
it.skip('Tenancy persisted after Logout in SAML', async () => {
const driver = getDriver(browser, options).build();

await driver.get('http://localhost:5601/app/opensearch_dashboards_overview#/');
Expand Down

0 comments on commit fd31852

Please sign in to comment.