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

ROR_INTR_001 #3

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
26 changes: 6 additions & 20 deletions .github/workflows/trigger-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,11 @@ on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
# pull_request:
# types: [opened, synchronize, reopened]

# jobs:
# check-internal:
# runs-on: ubuntu-latest
# outputs:
# is_member: ${{ steps.org_member_check.outputs.member }}
# steps:
# - name: Is PR creator an organization member?
# id: org_member_check
# uses: JamesSingleton/[email protected]
# with:
# organization: beshu-tech
# username: ${{ github.actor }}
# token: ${{ secrets.GITHUB_TOKEN }}
pull_request:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see changes from my branch. For sure sth is wrong here.

types: [opened, synchronize, reopened]

jobs:
e2e-tests:
# needs: check-internal
# if: needs.check-internal.outputs.is_member == 'true' || github.event.label.name == 'run-tests'
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -34,8 +19,9 @@ on:
- name: Run tests
run: ./run-${{ matrix.version }}.sh
env:
ROR_ACTIVATION_KEY: ${{ secrets.ROR_KBN_LICENSE }}
- name: S3 Upload Videos & logs
ROR_ACTIVATION_KEY: ${{ secrets.ROR_KBN_LICENSE }}
- name: S3 Upload Videos & show logs
if: failure()
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
8 changes: 5 additions & 3 deletions e2e-tests/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ export default defineConfig({
env: {
login: 'admin',
password: 'dev',
kibanaVersion: 'NOT_SET_YET',
kibanaVersion: 'KIBANA_VERSION_NOT_SET_YET',
elasticsearchUrl: 'http://localhost:19200',
enterpriseActivationKey: 'PROVIDE_YOUR_ACTIVATION_KEY'
enterpriseActivationKey: 'PROVIDE_YOUR_ACTIVATION_KEY',
kibanaUserCredentials: "kibana:kibana"
},
video: true,
screenshotOnRunFailure: true,
Expand All @@ -31,6 +32,7 @@ export default defineConfig({
},
baseUrl: 'http://localhost:5601',
videosFolder: '../results/videos',
screenshotsFolder: '../results/screenshots'
screenshotsFolder: '../results/screenshots',
downloadsFolder: './cypress/downloads/',
coutoPL marked this conversation as resolved.
Show resolved Hide resolved
}
});
6 changes: 4 additions & 2 deletions e2e-tests/cypress/e2e/Activation-keys.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Login } from '../support/page-objects/Login';
import { ActivationKeys } from '../support/page-objects/ActivationKeys';
import { userCredentials } from '../support/helpers';

// TODO:
describe.skip('Activation key', () => {
Expand All @@ -9,8 +10,9 @@ describe.skip('Activation key', () => {
});

afterEach(() => {
cy.post({
url: `"${Cypress.config().baseUrl}/api/ror/license?overwrite=true"`,
cy.kbnPost({
endpoint: "api/ror/license?overwrite=true",
credentials: userCredentials,
payload: { license: `${Cypress.env().enterpriseActivationKey}` }
});
});
Expand Down
85 changes: 39 additions & 46 deletions e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as semver from 'semver';
import { DataViews, DirectKibanaRequest, GetObject } from '../support/page-objects/DirectKibanaRequest';
import { getKibanaVersion } from '../support/helpers';
import { getKibanaVersion, userCredentials } from '../support/helpers';
import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient';

describe('Direct kibana request', () => {
const user = 'user1:dev';

afterEach(() => {
const clearDirectKibanaRequestState = () => {
DirectKibanaRequest.deleteSavedObjects(user);
kbnApiAdvancedClient.deleteSavedObjects(user);
if (semver.gte(getKibanaVersion(), '8.0.0')) {
DirectKibanaRequest.deleteDataViews(user);
kbnApiAdvancedClient.deleteDataViews(user);
}
};

Expand All @@ -18,70 +18,63 @@ describe('Direct kibana request', () => {

it('should check direct kibana request', () => {
const verifySavedObjects = () => {
DirectKibanaRequest.deleteSavedObjects(user);
kbnApiAdvancedClient.deleteSavedObjects(user);

cy.log('Import saved objects for user1');
cy.import({
url: `${Cypress.config().baseUrl}/api/saved_objects/_import?overwrite=true`,
filename: 'cypress/fixtures/file.ndjson',
user
cy.kbnImport({
endpoint: "api/saved_objects/_import?overwrite=true",
credentials: user,
filename: 'cypress/fixtures/file.ndjson'
});

cy.log('Get imported saved objects for user1 Administrators group');
cy.getRequest({
url: DirectKibanaRequest.getObjectsUrl(),
user
}).then((result: GetObject) => {
kbnApiAdvancedClient.getSavedObjects(user).then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
});
})

cy.log('Get imported saved objects for admin Administrators group');
cy.getRequest({
url: DirectKibanaRequest.getObjectsUrl()
}).then((result: GetObject) => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(2);
});
kbnApiAdvancedClient
.getSavedObjects(userCredentials)
.then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(2);
});

cy.log('Get imported saved objects for user1 infosec group');
cy.getRequest({
url: DirectKibanaRequest.getObjectsUrl(),
user,
header: 'x-ror-current-group: infosec_group'
}).then((result: GetObject) => {
const actual = result.saved_objects.some(
saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard'
);
// eslint-disable-next-line no-unused-expressions
expect(actual).to.be.false;
});
kbnApiAdvancedClient.getSavedObjects(user, "infosec_group")
.then(result => {
const actual = result.saved_objects.some(
saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard'
);
// eslint-disable-next-line no-unused-expressions
expect(actual).to.be.false;
});
};

const verifyDataViews = () => {
DirectKibanaRequest.deleteDataViews(user);
kbnApiAdvancedClient.deleteDataViews(user);
cy.log('Create data_views for user1 Administrators group');
cy.post({
url: `${Cypress.config().baseUrl}/api/data_views/data_view`,
payload: {
kbnApiAdvancedClient.createDataView(
{
data_view: {
id: 'logstash',
title: 'logstash-*',
name: 'My Logstash Data View'
}
}
});
},
user
);

cy.log('get all data_views for user1 infosec group');
cy.getRequest({
url: `${Cypress.config().baseUrl}/api/data_views`,
header: 'x-ror-current-group: infosec_group'
}).then((result: DataViews) => {
const actual = result.data_view.some(saved_object => saved_object.id === 'logstash');
// eslint-disable-next-line no-unused-expressions
expect(actual).to.be.false;
});
kbnApiAdvancedClient
.getDataViews(userCredentials, "infosec_group")
.then(result => {
const actual = result.data_view.some(saved_object => saved_object.id === 'logstash');
// eslint-disable-next-line no-unused-expressions
expect(actual).to.be.false;
});
};

verifySavedObjects();
Expand Down
43 changes: 43 additions & 0 deletions e2e-tests/cypress/e2e/Kibana-content-overwrite.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as semver from 'semver';
import { Login } from '../support/page-objects/Login';
import { StackManagement } from '../support/page-objects/StackManagement';
import { KibanaNavigation } from '../support/page-objects/KibanaNavigation';
import { getKibanaVersion } from '../support/helpers';

describe('Kibana-content-overwrite', () => {
beforeEach(() => {
Login.initialization();
});

it('should overwrite Kibana alerting content', () => {
const isAlertingOverwritePageVisible = () => {
if (semver.gte(getKibanaVersion(), '8.6.0')) {
cy.contains(
'Kibana alerting does not work with ReadonlyREST, but we are working on an even better alerting and reporting solution.'
).should('be.visible');
} else {
cy.contains(
'Kibana alerting does not work with ReadonlyREST, but we are working on an even better alerting and reporting solution.'
).should('not.exist');
}
};

if (semver.gte(getKibanaVersion(), '8.6.0')) {
if (semver.gte(getKibanaVersion(), '8.14.0')) {
StackManagement.openAlertsPage();
isAlertingOverwritePageVisible();
KibanaNavigation.openHomepage();
}
StackManagement.openRulesPage();
isAlertingOverwritePageVisible();

KibanaNavigation.openHomepage();

StackManagement.openConnectorsPage();
isAlertingOverwritePageVisible();
} else {
StackManagement.openRulesAndConnectorsPage();
isAlertingOverwritePageVisible();
}
});
});
72 changes: 72 additions & 0 deletions e2e-tests/cypress/e2e/Report-generation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Login } from "../support/page-objects/Login";
import { DataViews } from "../support/page-objects/management/DataViews";
import { Discover } from "../support/page-objects/Discover";
import { Reports } from "../support/page-objects/management/Reports";
import { dataPut } from "../support/page-objects/invoices";

describe('Report Generation', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the test - it's way too SLOOOOW.
Do we need so much data?

const indexName: string = 'invoices';
const searchName: string = `${ indexName } search`;


before(() => {
dataPut(1000000, indexName, 600, 200);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dataPut" doesn't tell much about what it does

});

beforeEach(() => {
Login.setLogin('user2:dev');
Login.initialization();

DataViews.deleteSavedObjectsIfExist([indexName, searchName]);
Reports.deleteAllReports(searchName)

Login.signOut();
})

it('should generate and verify reports for user2, and user3 should not see them', () => {
Login.setLogin('user2:dev');
Login.initialization();

DataViews.createDataView(indexName);

Discover.navigateTo();

Discover.selectDataView(indexName);
Discover.saveSearch(searchName);

for (let i = 0; i < 10; i++) {
Discover.generateCsvReport();
}

// Go to Reports and check if all reports are not empty
Reports.navigateTo();
Reports.checkAllReports(searchName);

Login.signOut();

Login.setLogin('user3:dev');
Login.initialization();

Reports.navigateTo();
Reports.verifyNoReports();

Login.signOut();
});

afterEach(() => {
Login.setLogin('user2:dev');
Login.initialization();

DataViews.deleteSavedObjectsIfExist([indexName, searchName]);
Reports.deleteAllReports(searchName)

Login.signOut();
})

after(() => {
cy.esDelete({
endpoint: indexName,
credentials: 'kibana:kibana',
})
});
});
7 changes: 3 additions & 4 deletions e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { RoAndRoStrictKibanaAccessAssertions } from '../support/page-objects/RoA
import roSettings from '../fixtures/roSettings.json';
import { Settings } from '../support/page-objects/Settings';
import defaultSettings from '../fixtures/defaultSettings.json';
import { kbnApiClient, KbnApiClient } from '../support/helpers/KbnApiClient';
import { userCredentials } from '../support/helpers';

describe('sanity check ro kibana access', () => {
beforeEach(() => {
Expand All @@ -11,10 +13,7 @@ describe('sanity check ro kibana access', () => {

afterEach(() => {
Settings.setSettingsData(defaultSettings);
cy.deleteRequest({
url: `${Cypress.config().baseUrl}/api/sample_data/ecommerce`,
header: 'x-ror-current-group: template_group'
});
kbnApiClient.deleteSampleData("ecommerce", userCredentials, "template_group");
});

it('should verify that everything works', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { RoAndRoStrictKibanaAccessAssertions } from '../support/page-objects/RoA
import roStrictSettings from '../fixtures/roStrictSettings.json';
import { Settings } from '../support/page-objects/Settings';
import defaultSettings from '../fixtures/defaultSettings.json';
import { kbnApiClient, KbnApiClient } from '../support/helpers/KbnApiClient';
import { userCredentials } from '../support/helpers';

describe('sanity check ro_strict kibana access', () => {
beforeEach(() => {
Expand All @@ -11,10 +13,7 @@ describe('sanity check ro_strict kibana access', () => {

afterEach(() => {
Settings.setSettingsData(defaultSettings);
cy.deleteRequest({
url: `${Cypress.config().baseUrl}/api/sample_data/ecommerce`,
header: 'x-ror-current-group: template_group'
});
kbnApiClient.deleteSampleData("ecommerce", userCredentials, "template_group");
});

it('should verify that everything works', () => {
Expand Down
Loading
Loading