Skip to content

Vault experiment #2318

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
26 changes: 17 additions & 9 deletions .circleci/export-playwright-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,39 @@ export sitePwd=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".da
echo "export SITE_PASSWORD=$sitePwd" >> playwright-env/envvars

# DSM
export dsmUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[1] | .userName")
export dsmUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[1] | .password")
export bspToken=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.bsp | .[] | select(.env==\"$ENV\") | .token")
echo "export DSM_USER_EMAIL=$dsmUser" >> playwright-env/envvars
echo "export DSM_USER_PASSWORD=$dsmUserPassword" >> playwright-env/envvars
echo "export BSP_TOKEN=$bspToken" >> playwright-env/envvars

# Additional DSM User (DSM permission testing)
export dsmUser1=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[0] | .userName")
export dsmUser1Password=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[0] | .password")
echo "export DSM_USER1_PASSWORD=$dsmUser1Password" >> playwright-env/envvars
echo "export DSM_USER1_EMAIL=$dsmUser1" >> playwright-env/envvars
echo "export DSM_USER1_PASSWORD=$dsmUser1Password" >> playwright-env/envvars

# Additional DSM User (DSM general testing)
export dsmUser2=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[2] | .userName")
export dsmUser2Password=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[2] | .password")
# Additional DSM User (DSM permission testing)
export dsmUser2=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[1] | .userName")
export dsmUser2Password=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[1] | .password")
echo "export DSM_USER2_PASSWORD=$dsmUser2Password" >> playwright-env/envvars
echo "export DSM_USER2_EMAIL=$dsmUser2" >> playwright-env/envvars

# Additional DSM User (DSM general testing)
export dsmUser3=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[2] | .userName")
export dsmUser3Password=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[2] | .password")
echo "export DSM_USER3_PASSWORD=$dsmUser3Password" >> playwright-env/envvars
echo "export DSM_USER3_EMAIL=$dsmUser3" >> playwright-env/envvars

# Additional DSM User (DSM general testing)
export dsmUser4=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[3] | .userName")
export dsmUser4Password=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[3] | .password")
echo "export DSM_USER4_PASSWORD=$dsmUser4Password" >> playwright-env/envvars
echo "export DSM_USER4_EMAIL=$dsmUser4" >> playwright-env/envvars

# Additional DSM User (mr-view-permission.spec)
export dsmUser5=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[4] | .userName")
export dsmUser5Password=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"dsm\") | .users[4] | .password")
echo "export DSM_USER5_PASSWORD=$dsmUser5Password" >> playwright-env/envvars
echo "export DSM_USER5_EMAIL=$dsmUser5" >> playwright-env/envvars


# RGP
export rgpUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"rgp\") | .userName")
export rgpUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"rgp\") | .password")
Expand Down
3 changes: 3 additions & 0 deletions playwright-e2e/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ DSM_USER2_PASSWORD=
# fourth user with very limited kit_shipping permissions
DSM_USER4_EMAIL=
DSM_USER4_PASSWORD=
# fifth user for mr-view-permissions.spec
DSM_USER5_EMAIL=
DSM_USER5_PASSWORD=

BSP_TOKEN=

Expand Down
28 changes: 28 additions & 0 deletions playwright-e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ Worthy of note:
If you don't want to use the `.env` file, you can also specify environment variables in cmd. See an example of this in **Examples** section.


## Test Users

> process.env.DSM_USER1_EMAIL: [email protected]
>
> ![Hunter Stormreaver screenshot](data/readme/hunter_stormreaver.png)

> process.env.DSM_USER2_EMAIL: [email protected]
>
> ![Mason Whiteclaw screenshot](data/readme/mason_whiteclaw.png)

> process.env.DSM_USER3_EMAIL: [email protected]
>
> ![Maya Bonechewer screenshot](data/readme/maya_bonechewer.png)

> process.env.DSM_USER4_EMAIL: [email protected]
>
> ![GP Collection screenshot](data/readme/gp_collection_date.png)

> process.env.DSM_USER5_EMAIL: [email protected]
>
> ![Eli Stormreaver screenshot](data/readme/eli_stormreaver.png)
>

>




## Email forwarding
* Tests run assertions that probe actual delivered email using gmail APIs. In order for
these tests to work properly, the emails that pepper sends need to be forwarded into a shared
Expand Down
4 changes: 2 additions & 2 deletions playwright-e2e/authentication/auth-dsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Page, expect } from '@playwright/test';
import { waitForNoSpinner } from 'utils/test-utils';
import { fillInEmailPassword } from './auth-base';

const { DSM_USER_EMAIL, DSM_USER_PASSWORD, DSM_BASE_URL } = process.env;
const { DSM_USER1_EMAIL, DSM_USER1_PASSWORD, DSM_BASE_URL } = process.env;

export async function login(page: Page, opts: { email?: string; password?: string } = {}): Promise<void> {
const { email = DSM_USER_EMAIL, password = DSM_USER_PASSWORD } = opts;
const { email = DSM_USER1_EMAIL, password = DSM_USER1_PASSWORD } = opts;

const assertLoggedIn = async (page: Page): Promise<void> => {
await expect(page.locator('.auth0-loading')).toBeHidden({timeout: 50 * 1000});
Expand Down
3 changes: 3 additions & 0 deletions playwright-e2e/config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ DSM_USER2_PASSWORD=
# fourth user with very limited kit_shipping permissions
DSM_USER4_EMAIL=
DSM_USER4_PASSWORD=
# fifth user for mr-view-permissions.spec
DSM_USER5_EMAIL=
DSM_USER5_PASSWORD=

BSP_TOKEN=

Expand Down
3 changes: 3 additions & 0 deletions playwright-e2e/config/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ DSM_USER2_PASSWORD=
# fourth user with very limited kit_shipping permissions
DSM_USER4_EMAIL=
DSM_USER4_PASSWORD=
# fifth user for mr-view-permissions.spec
DSM_USER5_EMAIL=
DSM_USER5_PASSWORD=

BSP_TOKEN=

Expand Down
Binary file added playwright-e2e/data/readme/eli_stormreaver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playwright-e2e/data/readme/mason_whiteclaw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playwright-e2e/data/readme/maya_bonechewer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export enum StudyNavEnum {
PARTICIPANT_LIST = 'Participant List'
DASHBOARD = 'Dashboard',
STATISTICS_DASHBOARD = 'Statistics Dashboard',
PARTICIPANT_LIST = 'Participant List',
TISSUE_LIST = 'Tissue List',
FIELD_SETTINGS = 'Field Settings',
MR_ABSTRACTION_SETTINGS = 'MR Abstraction Settings',
}
2 changes: 1 addition & 1 deletion playwright-e2e/dsm/component/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Tabs {
return clas ? clas.includes('active') : false;
}

private async open(tabName: TabEnum): Promise<void> {
public async open(tabName: TabEnum): Promise<void> {
await expect(async () => {
if (!(await this.isOpen(tabName))) {
await this.tabLocator(tabName).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export default class UserPermissionPage {
private DARWIN_ARK_STUDY_GROUP = 'darwin';
private currentStudyPermissions: UserPermission[];
private readonly page: Page;
private readonly root: Locator;

constructor(page: Page) {
this.page = page;
this.currentStudyPermissions = [];
this.root = this.page.locator('app-users-and-permissions');
}

/* Locators */
Expand All @@ -26,7 +28,8 @@ export default class UserPermissionPage {
}

public getStudyAdmin(email: string): Locator {
return this.page.getByText(`${email}`);
return this.root.locator('app-list-users app-administration-user', { hasText: new RegExp(email) });
// return this.page.getByText(`${email}`);
}

public getComparePermissionsButton(studyAdmin: Locator): Locator {
Expand All @@ -53,6 +56,17 @@ export default class UserPermissionPage {
return studyAdmin.locator(`//ancestor::mat-expansion-panel//button[contains(., 'Discard changes')]`);
}

public async expandPanel(email: string): Promise<void> {
const user = this.getStudyAdmin(email);
try {
await user.scrollIntoViewIfNeeded();
} catch (err) {
// ignore
}
await user.click();
await expect(user.locator('[role="region"]')).toBeVisible();
}

/* Assertions */
public async assertPageTitle(): Promise<void> {
await expect(this.page.getByRole('heading', { name: `${this.PAGE_TITLE}` }),
Expand Down
22 changes: 11 additions & 11 deletions playwright-e2e/fixtures/dsm-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Fixtures } from '@playwright/test';
import { login } from 'authentication/auth-dsm';
import { fixtureBase as base } from 'fixtures/fixture-base';

const { DSM_USER1_EMAIL, DSM_USER1_PASSWORD, DSM_USER2_EMAIL, DSM_USER2_PASSWORD, DSM_USER4_EMAIL, DSM_USER4_PASSWORD } = process.env;
const { DSM_USER2_EMAIL, DSM_USER2_PASSWORD, DSM_USER3_EMAIL, DSM_USER3_PASSWORD, DSM_USER4_EMAIL, DSM_USER4_PASSWORD } = process.env;

// Use this fixture for login in DSM tests
const fixture = base.extend<Fixtures>({
Expand All @@ -15,27 +15,27 @@ const fixture = base.extend<Fixtures>({
// Use this for login in DSM tests with limited permissions - view sequencing permission test
const fixtureForLimitedPermissions = base.extend<Fixtures>({
page: async ({ page }, use) => {
if (DSM_USER1_EMAIL === undefined || DSM_USER1_EMAIL === null) {
throw Error('Invalid parameter: DSM_USER1_EMAIL is undefined or null.');
if (DSM_USER2_EMAIL === undefined || DSM_USER2_EMAIL === null) {
throw Error('Invalid parameter: DSM_USER2_EMAIL is undefined or null.');
}
if (DSM_USER1_PASSWORD === undefined || DSM_USER1_PASSWORD === null) {
throw Error('Invalid parameter: DSM_USER1_PASSWORD is undefined or null.');
if (DSM_USER2_PASSWORD === undefined || DSM_USER2_PASSWORD === null) {
throw Error('Invalid parameter: DSM_USER2_PASSWORD is undefined or null.');
}
await login(page, {email: DSM_USER1_EMAIL, password: DSM_USER1_PASSWORD});
await login(page, {email: DSM_USER2_EMAIL, password: DSM_USER2_PASSWORD});
await use(page);
}
});

// Use this for general DSM tests with limited permissions
const fixtureForGeneralTesting = base.extend<Fixtures>({
page: async ({ page }, use) => {
if (DSM_USER2_EMAIL === undefined || DSM_USER2_EMAIL === null) {
throw Error('Invalid parameter: DSM_USER2_EMAIL is undefined or null.');
if (DSM_USER3_EMAIL === undefined || DSM_USER3_EMAIL === null) {
throw Error('Invalid parameter: DSM_USER3_EMAIL is undefined or null.');
}
if (DSM_USER2_PASSWORD === undefined || DSM_USER2_PASSWORD === null) {
throw Error('Invalid parameter: DSM_USER2_PASSWORD is undefined or null.');
if (DSM_USER3_PASSWORD === undefined || DSM_USER3_PASSWORD === null) {
throw Error('Invalid parameter: DSM_USER3_PASSWORD is undefined or null.');
}
await login(page, {email: DSM_USER2_EMAIL, password: DSM_USER2_PASSWORD});
await login(page, {email: DSM_USER3_EMAIL, password: DSM_USER3_PASSWORD});
await use(page);
}
});
Expand Down
3 changes: 3 additions & 0 deletions playwright-e2e/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { data } from './utils/vault';

export default { data };
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { test, expect } from '@playwright/test';
import { login } from 'authentication/auth-dsm';
import Dropdown from 'dsm/component/dropdown';
import { CustomViewColumns } from 'dsm/component/filters/sections/search/search-enums';
import { MainMenuEnum } from 'dsm/component/navigation/enums/mainMenu-enum';
import { MiscellaneousEnum } from 'dsm/component/navigation/enums/miscellaneousNav-enum';
import { StudyEnum } from 'dsm/component/navigation/enums/selectStudyNav-enum';
import { StudyNavEnum } from 'dsm/component/navigation/enums/studyNav-enum';
import { Navigation } from 'dsm/component/navigation/navigation';
import { TabEnum } from 'dsm/component/tabs/enums/tab-enum';
import Tabs from 'dsm/component/tabs/tabs';
import { UserPermission } from 'dsm/pages/miscellaneous-pages/enums/userPermission-enum';
import UserPermissionPage from 'dsm/pages/miscellaneous-pages/user-and-permissions-page';
import ParticipantListPage from 'dsm/pages/participant-list-page';
import Select from 'dss/component/select';
import { logInfo } from 'utils/log-utils';

const {
OSTEO_USER_EMAIL,
PANCAN_USER_EMAIL,
DSM_USER_EMAIL,
DSM_USER_PASSWORD,
DSM_USER5_EMAIL,
DSM_USER5_PASSWORD,
} = process.env;

test.describe.serial('View Medical Records Permission', () => {
const studies = [StudyEnum.OSTEO2, StudyEnum.PANCAN];
const emails = [OSTEO_USER_EMAIL as string, PANCAN_USER_EMAIL as string];

for (const [i, study] of studies.entries()) {
test(`@${study}: Login as Hunter to verify test user has the right permissions selected`, async ({ page, request }) => {
await login(page, { email: DSM_USER_EMAIL, password: DSM_USER_PASSWORD });
await new Select(page, { label: 'Select study' }).selectOption(study);
await new Navigation(page, request).selectMiscellaneous(MiscellaneousEnum.USERS_AND_PERMISSIONS);

const testUser = DSM_USER5_EMAIL as string;

const userPermissionsPage = new UserPermissionPage(page);
await userPermissionsPage.expandPanel(testUser);
const studyAdmin = userPermissionsPage.getStudyAdmin(testUser);
await userPermissionsPage.assertSelectedPermissions(studyAdmin,
[
UserPermission.MEDICAL_RECORDS_VIEW_AND_REQUEST_RECORDS_AND_TISSUE,
UserPermission.PARTICIPANT_VIEW_LIST,
]);
});
}

for (const [i, study] of studies.entries()) {
test(`@${study}: Login as test user to verify UI displays as expected`, async ({ page, request }) => {
await login(page, { email: DSM_USER5_EMAIL, password: DSM_USER5_PASSWORD });
await new Select(page, { label: 'Select study' }).selectOption(study);

const navigation = new Navigation(page, request);

await test.step('Verify user only see the Selected Study and Study menus', async () => {
const expectedNavigationMenus = [MainMenuEnum.SELECTED_STUDY, MainMenuEnum.STUDY];
const visibleNavigationMenus = await navigation.getDisplayedMainMenu();
expect(visibleNavigationMenus).toMatchObject(expectedNavigationMenus);

const expectedStudyMenuOptions = [
StudyNavEnum.DASHBOARD,
StudyNavEnum.PARTICIPANT_LIST,
StudyNavEnum.TISSUE_LIST,
];
const studyMenu = new Dropdown(page, 'Study');
const visibleMenuOptions = await studyMenu.getDisplayedOptions<StudyNavEnum>();
expect(visibleMenuOptions).toMatchObject(expectedStudyMenuOptions);
});

await test.step('Verify user can see all avialable medical records tabs in Participant page', async () => {
const participantListPage = await navigation.selectFromStudy<ParticipantListPage>(StudyNavEnum.PARTICIPANT_LIST);
await participantListPage.waitForReady();

// Find participant created by Playwright DSS test
const rowIndex = await participantListPage.findParticipantFor(CustomViewColumns.PARTICIPANT, 'Email', {value: emails[i] });
const participantListTable = participantListPage.participantListTable;
const shortId = await participantListTable.getParticipantDataAt(rowIndex, 'Short ID');
logInfo(`Participant Short ID: ${shortId}`);

// Open Participant page to verify visible tabs
await participantListTable.openParticipantPageAt(rowIndex);
const expectedTabs = ['Survey Data', 'Sample Information', 'Contact Information', 'Medical Records', 'Onc History'];
const visibleTabs = page.locator('tabset a[role="tab"]');
const tabNames = await visibleTabs.allInnerTexts();
expect(tabNames).toStrictEqual(expectedTabs);
// All tab is enabled
for (const tabName of tabNames) {
const tab = new Tabs(page);
await tab.open(tabName as TabEnum);
}
})
});
}
})
1 change: 1 addition & 0 deletions playwright-e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"resolveJsonModule": true,
"declaration": true,
"rootDir": ".",

"outDir": "build",
"baseUrl": ".",
"strict": true,
Expand Down
30 changes: 30 additions & 0 deletions playwright-e2e/utils/vault.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import vault from 'node-vault';

const client = vault({
apiVersion: 'v1',
endpoint: process.env.VAULT_ADDR,
});

const GITHUB_TOKEN = process.env.VAULT_TOKEN;

const data = async () => {
try {
const login = await client.githubLogin({ token: GITHUB_TOKEN });
client.token = login.auth.client_token;
const { data } = await client.read('secret/pepper/test/v1/e2e');

const users = data.users;
users.forEach((key: any, value: any) => {
if (key.app === 'dsm') {
console.log('dsm');
}
})
// console.log(data.users);
return data;
} catch (error) {
console.error(error);
}
return null;
};

export { client as vault, data };