* feat: vault mode access control and mfa on vault entry * chore: vault mode ci setup for e2e tests chore: vault mode ci setup * test: restore web packages changes Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: remove keycloak certs Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: set keycloak server envs Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: adding csp file Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: adding keycloak config Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: adding scope with email acr Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: exclude vault storage from parallel e2e tests Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: remove debugging codes Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: handle vault mode in keycloak group setup * test: revert some configs Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * test: updating the vault pageObject layout Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * fix: reusing otp authentication of mfa Signed-off-by: Kavita Gautam <kavita@jankaritech.com> * fix: update userAuthenticatesWithOTP function * fix: use a new OIDC authorization-code login for OCIS token --------- Signed-off-by: Kavita Gautam <kavita@jankaritech.com>
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
import { basename } from 'path'
|
|
import { Page, expect, test } from '@playwright/test'
|
|
import { objects } from '../../../index'
|
|
import { getOtpFromImage } from '../../../utils/mfa'
|
|
import { Jimp } from 'jimp'
|
|
|
|
export const uploadLogo = async (path: string, page: Page): Promise<void> => {
|
|
await page.click('#logo-context-btn')
|
|
|
|
// wait for the visible context menu and run accessibility scan on that menu
|
|
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
|
|
page,
|
|
['tippyBoxVisible'],
|
|
'logo menu'
|
|
)
|
|
|
|
const logoInput = page.locator('#logo-upload-input')
|
|
await logoInput.setInputFiles(path)
|
|
|
|
await page.locator('.oc-notification-message').waitFor()
|
|
await page.reload()
|
|
const selectors = new objects.a11y.Accessibility({ page }).getSelectors()
|
|
await page.locator(selectors.logoWrapper).waitFor()
|
|
// run accessibility scan on the logo area after upload
|
|
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
|
|
page,
|
|
['logoWrapper'],
|
|
'logo area after upload'
|
|
)
|
|
|
|
const logoImg = page.locator(`${selectors.logoWrapper} img`)
|
|
const logoSrc = await logoImg.getAttribute('src')
|
|
expect(logoSrc).toContain(basename(path))
|
|
}
|
|
|
|
export const resetLogo = async (page: Page): Promise<void> => {
|
|
const a11yObject = new objects.a11y.Accessibility({ page })
|
|
const selectors = a11yObject.getSelectors()
|
|
|
|
const imgBefore = page.locator(`${selectors.logoWrapper} img`)
|
|
const srcBefore = await imgBefore.getAttribute('src')
|
|
await page.click('#logo-context-btn')
|
|
|
|
// wait for the visible context menu and run accessibility scan on that menu
|
|
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
|
|
page,
|
|
['tippyBoxVisible'],
|
|
'logo menu'
|
|
)
|
|
|
|
await page.click('.oc-general-actions-reset-logo-trigger')
|
|
|
|
await page.locator('.oc-notification-message').waitFor()
|
|
await page.reload()
|
|
await page.locator(selectors.logoWrapper).waitFor()
|
|
|
|
// run accessibility scan on the logo area after reset
|
|
await objects.a11y.Accessibility.assertNoSevereA11yViolations(
|
|
page,
|
|
['logoWrapper'],
|
|
'logo area after reset'
|
|
)
|
|
|
|
const imgAfter = page.locator(`${selectors.logoWrapper} img`)
|
|
const srcAfter = await imgAfter.getAttribute('src')
|
|
expect(srcAfter).not.toEqual(srcBefore)
|
|
}
|
|
|
|
export const userAuthenticatesWithOTP = async (page: Page, deviceName: string): Promise<void> => {
|
|
const element = page.locator('#kc-totp-secret-qr-code')
|
|
const qrCodePath = test.info().outputPath('qr.png')
|
|
await element.screenshot({ path: qrCodePath })
|
|
const image = await Jimp.read(qrCodePath)
|
|
const { data, width, height } = image.bitmap
|
|
const otp = await getOtpFromImage(data, width, height)
|
|
await page.locator('#totp').fill(String(otp))
|
|
await page.locator('#userLabel').fill(deviceName)
|
|
await page.locator('#saveTOTPBtn').click()
|
|
}
|