Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch actions and workflows. Skip integration tests that fail #4

Merged
merged 4 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 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 @@ -15,7 +18,6 @@ outputs:
description: "The directory where the plugin has been configured"
value: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}


runs:
using: "composite"
steps:
Expand All @@ -31,8 +33,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

- run: mkdir -p plugins
Expand All @@ -52,12 +54,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
24 changes: 12 additions & 12 deletions .github/workflows/cypress-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
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: Run OpenSearch with plugin
run: |
Expand All @@ -48,23 +48,23 @@ jobs:
EOF
docker run -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest

- name: Checkout OpenSearch Dashboard
- name: Checkout Wazuh Dashboard
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
ref: '2.4'
repository: wazuh/wazuh-dashboard
ref: ${{ vars.WZD_REF }}
fetch-depth: 0

- name: Create plugins dir
run: |
cd ./OpenSearch-Dashboards
mkdir -p plugins

- name: Checkout OpenSearch Dashboard Security plugin
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/security-dashboards-plugin
path: OpenSearch-Dashboards/plugins/wazuh-security-dashboards-plugin
ref: ${{ github.ref }}

- name: Check OpenSearch Running
Expand All @@ -76,19 +76,19 @@ jobs:
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: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ steps.versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- 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
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
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:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
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: Run OpenSearch with plugin
run: |
Expand Down Expand Up @@ -49,7 +48,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 @@ -21,7 +21,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,21 +17,21 @@ 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')
),
setupFilesAfterEnv: ['<rootDir>/src/dev/jest/setup/after_env.integration.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 @@ -236,7 +236,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 @@ -264,7 +269,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 @@ -283,7 +293,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