Skip to content

Commit

Permalink
OZ-721: Roles assigned to user in KC should be assigned to user in Su…
Browse files Browse the repository at this point in the history
…perset, Odoo, OpenMRS
  • Loading branch information
kdaud committed Dec 18, 2024
1 parent 921dfb7 commit 4f732bf
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
15 changes: 15 additions & 0 deletions e2e/tests/keycloak-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ test('Logging out from Odoo ends the session in Keycloak and logs out the user.'
await expect(page).toHaveURL(/.*login/);
});

test('Odoo role assigned to a user in KC is applied upon login in OpenMRS.', async ({ page }) => {
// setup
await keycloak.open();

// replay
await keycloak.navigateToUsers();
await keycloak.searchUser();
await keycloak.searchRole();
await keycloak.assinOdooRole();

// verify
await odoo.open();
await openmrs.enterLoginCredentials();
});

test('Coded Odoo groups create corresponding Keycloak roles.', async ({ page }) => {
// setup
await page.goto(`${ODOO_URL}`);
Expand Down
15 changes: 15 additions & 0 deletions e2e/tests/keycloak-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ test('Logging out from OpenMRS ends the session in Keycloak and logs out the use
await expect(page).toHaveURL(/.*login/);
});

test('OpenMRS role assigned to a user in KC is applied upon login in OpenMRS.', async ({ page }) => {
// setup
await keycloak.open();

// replay
await keycloak.navigateToUsers();
await keycloak.searchUser();
await keycloak.searchRole();
await keycloak.assinOpenMRSRole();

// verify
await page.goto(`${O3_URL}/openmrs/admin/users/users.list`);
await expect(page.locator('tr td:nth-child(5) span')).toContainText('Inventory Reporting');
});

test('Creating an OpenMRS role creates the corresponding Keycloak role.', async ({ page }) => {
// setup
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`);
Expand Down
17 changes: 16 additions & 1 deletion e2e/tests/keycloak-superset-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { KEYCLOAK_URL, SUPERSET_URL } from '../utils/configs/globalSetup';
import { KEYCLOAK_URL, O3_URL, SUPERSET_URL } from '../utils/configs/globalSetup';
import { Keycloak } from '../utils/functions/keycloak';
import { OpenMRS, delay } from '../utils/functions/openmrs';
import { Superset, randomSupersetRoleName} from '../utils/functions/superset';
Expand Down Expand Up @@ -42,6 +42,21 @@ test('Logging out from Superset ends the session in Keycloak and logs out the us
await expect(page).toHaveURL(/.*login/);
});

test('Superset role assigned to a user in KC is applied upon login in Superset.', async ({ page }) => {
// setup
await keycloak.open();

// replay
await keycloak.navigateToUsers();
await keycloak.searchUser();
await keycloak.searchRole();
await keycloak.assinSupersetRole();

// verify
await page.goto(`${SUPERSET_URL}/users/list/`);
await expect(page.locator('tr td:nth-child(5) span')).toContainText('Inventory Reporting');
});

test('Creating a Superset role creates the corresponding Keycloak role.', async ({ page }) => {
// setup
await openmrs.login();
Expand Down
45 changes: 45 additions & 0 deletions e2e/utils/functions/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,51 @@ export class Keycloak {
await delay(2000);
}

async navigateToUsers() {
await this.page.getByTestId('realmSelectorToggle').click();
await expect(this.page.getByRole('menuitem', { name: 'ozone' })).toBeVisible();
await this.page.getByRole('menuitem', { name: 'ozone' }).click();
await this.page.getByRole('link', { name: 'Users' }).click();
await delay(2000);//
}

async searchUser() {
await expect(this.page.getByPlaceholder('Search user')).toBeVisible();
await this.page.getByPlaceholder('Search user').fill('jdoe');
await this.page.getByPlaceholder('Search user').press('Enter');
await this.page.locator('tr td:nth-child(2) a').click();
await this.page.getByTestId('role-mapping-tab').click();
}

async searchRole() {
await this.page.getByTestId('assignRole').click();
await this.page.getByRole('button', { name: 'Filter by realm roles' }).click();
await this.page.getByTestId('roles').click();
await expect(this.page.getByPlaceholder('Search by role name')).toBeVisible();
}

async assinOdooRole() {
await this.page.getByPlaceholder('Search by role name').fill('Inventory Reporting');//Application: Enters Vitals');
await this.page.getByRole('checkbox', { name: 'Select row' }).check();
await this.page.getByTestId('assign').click();
await expect(this.page.getByText('User role mapping successfully updated')).toBeVisible();
}

async assinOpenMRSRole() {
await this.page.getByPlaceholder('Search by role name').fill('Inventory Reporting');
await delay(3000);
await this.page.getByRole('checkbox', { name: 'Select row' }).check();
await this.page.getByTestId('assign').click();
await expect(this.page.getByText('User role mapping successfully updated')).toBeVisible();
}

async assinSupersetRole() {
await this.page.getByPlaceholder('Search by role name').fill('Inventory Reporting');//Application: Enters Vitals');
await this.page.getByRole('checkbox', { name: 'Select row' }).check();
await this.page.getByTestId('assign').click();
await expect(this.page.getByText('User role mapping successfully updated')).toBeVisible();
}

async selectOpenMRSId() {
await expect(this.page.getByPlaceholder('Search for client')).toBeVisible();
await this.page.getByPlaceholder('Search for client').fill('openmrs');
Expand Down

0 comments on commit 4f732bf

Please sign in to comment.