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

Flaky cypress #3

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7c8058f
2.13 release notes (#1832)
stephen-crawford Mar 20, 2024
f0cd1cf
Add required ml permissions to support new roles (#1838)
b4sjoo Mar 22, 2024
3bff6db
Fixes issue with multi-tenancy and default route to use corresponding…
cwperks Mar 22, 2024
aa77c59
Adding @derek-ho as a maintainer (#1842)
cwperks Mar 26, 2024
d82e129
Add husky to pre-lint any commits, remove unused imports (#1851)
derek-ho Mar 26, 2024
c2ad67b
Add @derek-ho to CODEOWNERS (#1852)
cwperks Mar 26, 2024
3275dcb
Remove implicit dependency to admin as password (#1855)
derek-ho Apr 2, 2024
28604fd
Remove date from release notes (#1865)
cwperks Apr 2, 2024
aed7671
Clear session storage on auto-logout & remove unused saml function (#…
ps48 Apr 3, 2024
64995fc
Update copy for tenancy tab (#1881)
derek-ho Apr 9, 2024
9f350b0
Add cluster info to toasts, adds cluster info to URL (#1877)
derek-ho Apr 12, 2024
681d1b1
Fixes saml login flow to work with anonymous auth (#1839)
DarshitChanpura Apr 12, 2024
8f0a52d
Remove Dave Lago from codeowners, move to emeritus maintainer (#1884)
derek-ho Apr 12, 2024
7b8b18e
Merge branch 'main' of github.com:opensearch-project/security-dashboa…
derek-ho Apr 12, 2024
5f0f592
Revert to "admin" password for older versions
derek-ho Apr 15, 2024
8f5ef2d
Fix some state issues and try to use electron browser
derek-ho Apr 16, 2024
5892bba
Try modifying numtestskeptinmemory
derek-ho Apr 16, 2024
52079ce
Remove closetoast
derek-ho Apr 16, 2024
92ef4a4
Fix flaky cypress test
derek-ho Apr 16, 2024
a36dfab
Run 10x
derek-ho Apr 17, 2024
65b3f26
Fix test
derek-ho Apr 17, 2024
3d2931d
Fix permissions test
derek-ho Apr 17, 2024
70a26f6
Move management to correct section
derek-ho Apr 17, 2024
dc22920
Push up fixes for audit logs and roles
derek-ho Apr 17, 2024
9c405db
Remove local cluster checks to cut length and increase stability
derek-ho Apr 17, 2024
1dcb7f1
Improves before and after handling
DarshitChanpura Apr 18, 2024
6fa10ac
Temporarily disable permissions and roles tests
DarshitChanpura Apr 18, 2024
fd143de
adds delete datasource call to beforeEach
DarshitChanpura Apr 18, 2024
5eb94f9
Unskip permissions test
DarshitChanpura Apr 18, 2024
6369732
Absorb changes from core
DarshitChanpura Apr 18, 2024
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @cliu123 @cwperks @DarshitChanpura @davidlago @derek-ho @peternied @RyanL1997 @scrawfor99
* @cliu123 @cwperks @DarshitChanpura @derek-ho @peternied @RyanL1997 @scrawfor99
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
iteration: [1, 2, 3, 4, 5, 6, 7, 8, 9]
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -123,4 +124,4 @@ jobs:
uses: ./.github/actions/run-cypress-tests
with:
dashboards_config_file: opensearch_dashboards_multidatasources.yml
yarn_command: 'yarn cypress:run --browser chrome --headed --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"'
yarn_command: 'yarn cypress:run --browser electron --headless --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"'
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
TEST_BROWSER_HEADLESS: 1
CI: 1
PLUGIN_NAME: opensearch-security
OPENSEARCH_INITIAL_ADMIN_PASSWORD: myStrongPassword123!
OPENSEARCH_INITIAL_ADMIN_PASSWORD: admin

jobs:
tests:
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
| ---------------- | ----------------------------------------------------- | ----------- |
| Chang Liu | [cliu123](https://github.com/cliu123) | Amazon |
| Darshit Chanpura | [DarshitChanpura](https://github.com/DarshitChanpura) | Amazon |
| Dave Lago | [davidlago](https://github.com/davidlago) | Amazon |
| Peter Nied | [peternied](https://github.com/peternied) | Amazon |
| Craig Perkins | [cwperks](https://github.com/cwperks) | Amazon |
| Ryan Liang | [RyanL1997](https://github.com/RyanL1997) | Amazon |
Expand All @@ -22,3 +21,4 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
| Yan Zeng | [zengyan-amazon](https://github.com/zengyan-amazon) | Amazon |
| Bandini Bhopi | [bandinib-amzn](https://github.com/bandinib-amzn) | Amazon |
| Tianle Huang | [tianleh](https://github.com/tianleh) | Amazon |
| Dave Lago | [davidlago](https://github.com/davidlago) | Contributor |
1 change: 1 addition & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const OPENID_AUTH_LOGIN_WITH_FRAGMENT = '/auth/openid/captureUrlFragment'
export const SAML_AUTH_LOGIN = '/auth/saml/login';
export const SAML_AUTH_LOGIN_WITH_FRAGMENT = '/auth/saml/captureUrlFragment';
export const ANONYMOUS_AUTH_LOGIN = '/auth/anonymous';
export const AUTH_TYPE_PARAM = 'auth_type';

export const OPENID_AUTH_LOGOUT = '/auth/openid/logout';
export const SAML_AUTH_LOGOUT = '/auth/saml/logout';
Expand Down
2 changes: 2 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports = defineConfig({
defaultCommandTimeout: 60000,
requestTimeout: 60000,
responseTimeout: 60000,
experimentalMemoryManagement: true,
numTestsKeptInMemory: 0,
e2e: {
setupNodeEvents(on, config) {},
supportFile: 'test/cypress/support/e2e.js',
Expand Down
7 changes: 5 additions & 2 deletions public/apps/configuration/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { EuiBreadcrumb, EuiPage, EuiPageBody, EuiPageSideBar } from '@elastic/eu
import { flow, partial } from 'lodash';
import React, { createContext, useState } from 'react';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { DataSourceOption } from '../../../../../src/plugins/data_source_management/public/components/data_source_selector/data_source_selector';
import { DataSourceOption } from 'src/plugins/data_source_management/public/components/data_source_menu/types';
import { AppDependencies } from '../types';
import { AuditLogging } from './panels/audit-logging/audit-logging';
import { AuditLoggingEditSettings } from './panels/audit-logging/audit-logging-edit-settings';
Expand All @@ -41,6 +41,7 @@ import { Action, RouteItem, SubAction } from './types';
import { ResourceType } from '../../../common';
import { buildHashUrl, buildUrl } from './utils/url-builder';
import { CrossPageToast } from './cross-page-toast';
import { getDataSourceFromUrl } from '../../utils/datasource-utils';

const LANDING_PAGE_URL = '/getstarted';

Expand Down Expand Up @@ -155,7 +156,9 @@ export const DataSourceContext = createContext<DataSourceContextType | null>(nul

export function AppRouter(props: AppDependencies) {
const setGlobalBreadcrumbs = flow(getBreadcrumbs, props.coreStart.chrome.setBreadcrumbs);
const [dataSource, setDataSource] = useState<DataSourceOption>(LocalCluster);
const dataSourceFromUrl = getDataSourceFromUrl();

const [dataSource, setDataSource] = useState<DataSourceOption>(dataSourceFromUrl);

return (
<DataSourceContext.Provider value={{ dataSource, setDataSource }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ exports[`Audit logs render when AuditLoggingSettings.enabled is true 1`] = `
<div
className="panel-restrict-width"
>
<SecurityPluginTopNavMenu
<Memo()
coreStart={
Object {
"http": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function InternalUserEdit(props: InternalUserEditDeps) {
const [toasts, addToast, removeToast] = useToastState();

const [isFormValid, setIsFormValid] = useState<boolean>(true);
const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

React.useEffect(() => {
Expand Down Expand Up @@ -135,7 +136,13 @@ export function InternalUserEdit(props: InternalUserEditDeps) {
setCrossPageToast(buildUrl(ResourceType.users), {
id: 'updateUserSucceeded',
color: 'success',
title: getSuccessToastMessage('User', props.action, userName),
title: `${getSuccessToastMessage(
'User',
props.action,
userName,
dataSourceEnabled,
dataSource
)}`,
});
// Redirect to user listing
window.location.href = buildHashUrl(ResourceType.users);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -77,7 +77,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -98,7 +98,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -118,7 +118,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -140,7 +140,7 @@ describe('Internal user edit', () => {
sourceUserName={sampleUsername}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export function PermissionList(props: AppDependencies) {
const [selection, setSelection] = React.useState<PermissionListingItem[]>([]);
const [itemIdToExpandedRowMap, setItemIdToExpandedRowMap] = useState<ExpandedRowMapInterface>({});

const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

// Modal state
Expand Down Expand Up @@ -305,7 +306,13 @@ export function PermissionList(props: AppDependencies) {
fetchData();
addToast({
id: 'saveSucceeded',
title: getSuccessToastMessage('Action group', action, groupName),
title: `${getSuccessToastMessage(
'Action group',
action,
groupName,
dataSourceEnabled,
dataSource
)}`,
color: 'success',
});
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -123,7 +123,7 @@ describe('Permission list page ', () => {
shallow(
<PermissionList
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -145,7 +145,7 @@ describe('Permission list page ', () => {
shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -159,7 +159,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -186,7 +186,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -203,7 +203,7 @@ describe('Permission list page ', () => {
shallow(
<PermissionList
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -223,7 +223,7 @@ describe('Permission list page ', () => {
const component = shallow(
<PermissionList
coreStart={{} as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
EuiSuperSelect,
EuiTextArea,
} from '@elastic/eui';
import React, { Dispatch, Fragment, SetStateAction } from 'react';
import React, { Dispatch, Fragment, SetStateAction, useEffect } from 'react';
import { isEmpty } from 'lodash';
import { RoleIndexPermission } from '../../types';
import { ResourceType } from '../../../../../common';
Expand Down Expand Up @@ -320,9 +320,11 @@ export function IndexPermissionPanel(props: {
}) {
const { state, optionUniverse, setState } = props;
// Show one empty row if there is no data.
if (isEmpty(state)) {
setState([getEmptyIndexPermission()]);
}
useEffect(() => {
if (isEmpty(state)) {
setState([getEmptyIndexPermission()]);
}
}, [state, setState]);
return (
<PanelWithHeader
headerText="Index permissions"
Expand Down
9 changes: 8 additions & 1 deletion public/apps/configuration/panels/role-edit/role-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function RoleEdit(props: RoleEditDeps) {

const [isFormValid, setIsFormValid] = useState<boolean>(true);

const dataSourceEnabled = !!props.depsStart.dataSource?.dataSourceEnabled;
const { dataSource, setDataSource } = useContext(DataSourceContext)!;

React.useEffect(() => {
Expand Down Expand Up @@ -174,7 +175,13 @@ export function RoleEdit(props: RoleEditDeps) {
setCrossPageToast(buildUrl(ResourceType.roles, Action.view, roleName), {
id: 'updateRoleSucceeded',
color: 'success',
title: getSuccessToastMessage('Role', props.action, roleName),
title: `${getSuccessToastMessage(
'Role',
props.action,
roleName,
dataSourceEnabled,
dataSource
)}`,
});
// Redirect to role view
window.location.href = buildHashUrl(ResourceType.roles, Action.view, roleName);
Expand Down
11 changes: 7 additions & 4 deletions public/apps/configuration/panels/role-edit/tenant-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import { EuiButton, EuiComboBox, EuiFlexGroup, EuiFlexItem, EuiSuperSelect } from '@elastic/eui';
import React, { Dispatch, Fragment, SetStateAction } from 'react';
import React, { Dispatch, Fragment, SetStateAction, useEffect } from 'react';
import { isEmpty } from 'lodash';
import { RoleTenantPermission, TenantPermissionType, ComboBoxOptions } from '../../types';
import {
Expand Down Expand Up @@ -129,9 +129,12 @@ export function TenantPanel(props: {
}) {
const { state, optionUniverse, setState } = props;
// Show one empty row if there is no data.
if (isEmpty(state)) {
setState([getEmptyTenantPermission()]);
}

useEffect(() => {
if (isEmpty(state)) {
setState([getEmptyTenantPermission()]);
}
}, [state, setState]);
return (
<PanelWithHeader
headerText="Tenant permissions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

import { shallow } from 'enzyme';
import { render } from '@testing-library/react';
import React from 'react';
import { RoleIndexPermission, ComboBoxOptions, FieldLevelSecurityMethod } from '../../../types';
import { stringToComboBoxOption } from '../../../utils/combo-box-utils';
Expand Down Expand Up @@ -180,7 +181,7 @@ describe('Role edit - index permission panel', () => {
const state: RoleIndexPermissionStateClass[] = [];
const optionUniverse: ComboBoxOptions = [];

shallow(<IndexPermissionPanel {...{ state, optionUniverse, setState }} />);
render(<IndexPermissionPanel {...{ state, optionUniverse, setState }} />);

expect(setState).toHaveBeenCalledTimes(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Role edit', () => {
sourceRoleName={sampleSourceRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -89,7 +89,7 @@ describe('Role edit', () => {
sourceRoleName={sampleSourceRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand All @@ -112,7 +112,7 @@ describe('Role edit', () => {
sourceRoleName={sampleSourceRole}
buildBreadcrumbs={buildBreadcrumbs}
coreStart={mockCoreStart as any}
navigation={{} as any}
depsStart={{} as any}
params={{} as any}
config={{} as any}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { shallow } from 'enzyme';
import React from 'react';
import { EuiComboBox, EuiButton, EuiSuperSelect } from '@elastic/eui';
import { render } from '@testing-library/react';

jest.mock('../../../utils/array-state-utils');
// eslint-disable-next-line
Expand Down Expand Up @@ -76,7 +77,7 @@ describe('Role edit - tenant panel', () => {
const setState = jest.fn();

it('render an empty row if data is empty', () => {
shallow(<TenantPanel state={[]} optionUniverse={optionUniverse} setState={setState} />);
render(<TenantPanel state={[]} optionUniverse={optionUniverse} setState={setState} />);

expect(setState).toHaveBeenCalledWith([
{
Expand Down
Loading
Loading