committed by
GitHub
36 changed files with 1060 additions and 781 deletions
File diff suppressed because it is too large
@ -0,0 +1,56 @@ |
|||||
|
import { test, expect, type Page, type TestInfo } from '@playwright/test'; |
||||
|
import * as OTPAuth from "otpauth"; |
||||
|
|
||||
|
import * as utils from "../global-utils"; |
||||
|
import { createAccount, logUser } from './setups/user'; |
||||
|
import { activateTOTP, disableTOTP } from './setups/2fa'; |
||||
|
|
||||
|
let users = utils.loadEnv(); |
||||
|
let totp; |
||||
|
|
||||
|
test.beforeAll('Setup', async ({ browser }, testInfo: TestInfo) => { |
||||
|
await utils.startVault(browser, testInfo, {}); |
||||
|
}); |
||||
|
|
||||
|
test.afterAll('Teardown', async ({}) => { |
||||
|
utils.stopVault(); |
||||
|
}); |
||||
|
|
||||
|
test('Change Key settings', async ({ page }) => { |
||||
|
await createAccount(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Change SHA-256 Iterations', async () => { |
||||
|
await page.getByRole('button', { name: 'Toggle collapse Settings' }).click(); |
||||
|
await page.getByRole('link', { name: 'Security' }).click(); |
||||
|
await page.getByRole('link', { name: 'Keys' }).click(); |
||||
|
|
||||
|
await page.getByRole('spinbutton', { name: 'KDF iterations * (required)'}).fill('700000'); |
||||
|
|
||||
|
await page.getByRole('button', { name: 'Update encryption settings' }).click(); |
||||
|
await page.getByRole('textbox', { name: 'Master password * (required)' }).fill(users.user1.password); |
||||
|
await page.getByRole('button', { name: 'Update settings' }).click(); |
||||
|
await page.getByRole('heading', { name: 'Log in' }).click(); |
||||
|
}); |
||||
|
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Switch to Argon2', async () => { |
||||
|
await page.getByRole('button', { name: 'Toggle collapse Settings' }).click(); |
||||
|
await page.getByRole('link', { name: 'Security' }).click(); |
||||
|
await page.getByRole('link', { name: 'Keys' }).click(); |
||||
|
|
||||
|
await page.locator('.ng-arrow-wrapper').click(); |
||||
|
await page.getByText('Argon2id').click(); |
||||
|
|
||||
|
await page.getByRole('spinbutton', { name: 'KDF memory (MB) * (required)'}).fill('16'); |
||||
|
await page.getByRole('spinbutton', { name: 'KDF iterations * (required)'}).fill('2'); |
||||
|
await page.getByRole('spinbutton', { name: 'KDF parallelism * (required)'}).fill('1'); |
||||
|
|
||||
|
await page.getByRole('button', { name: 'Update encryption settings' }).click(); |
||||
|
await page.getByRole('textbox', { name: 'Master password * (required)' }).fill(users.user1.password); |
||||
|
await page.getByRole('button', { name: 'Update settings' }).click(); |
||||
|
await page.getByRole('heading', { name: 'Log in' }).click(); |
||||
|
}); |
||||
|
|
||||
|
await logUser(test, page, users.user1); |
||||
|
}); |
||||
@ -0,0 +1,110 @@ |
|||||
|
import { test, expect, type Page, type TestInfo } from '@playwright/test'; |
||||
|
import * as OTPAuth from "otpauth"; |
||||
|
|
||||
|
import * as utils from "../global-utils"; |
||||
|
import { createAccount, logUser } from './setups/user'; |
||||
|
|
||||
|
let users = utils.loadEnv(); |
||||
|
let totp; |
||||
|
|
||||
|
test.beforeAll('Setup', async ({ browser }, testInfo: TestInfo) => { |
||||
|
await utils.startVault(browser, testInfo, {}); |
||||
|
|
||||
|
const context = await browser.newContext(); |
||||
|
const page = await context.newPage(); |
||||
|
await createAccount(test, page, users.user1); |
||||
|
await context.close(); |
||||
|
}); |
||||
|
|
||||
|
test.afterAll('Teardown', async ({}) => { |
||||
|
utils.stopVault(); |
||||
|
}); |
||||
|
|
||||
|
test('Password', async ({ context, page }, testInfo: TestInfo) => { |
||||
|
const label = 'Test Password'; |
||||
|
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Create password entry', async () => { |
||||
|
await page.getByRole('button', { name: 'New item' }).click(); |
||||
|
await page.getByRole('textbox', { name: 'Item name * (required)' }).fill(label); |
||||
|
await page.getByRole('textbox', { name: 'Username' }).fill(users.user1.name); |
||||
|
await page.getByRole('textbox', { name: 'Password' }).fill(users.user1.password); |
||||
|
await page.getByRole('button', { name: 'Save' }).click(); |
||||
|
await utils.checkNotification(page, 'Item added'); |
||||
|
await page.getByRole('button', { name: 'Close' }).click(); |
||||
|
}); |
||||
|
|
||||
|
// Log again
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Check', async () => { |
||||
|
await page.getByRole('row').filter({ hasText: label }).getByRole('button', { name: label }).click(); |
||||
|
await page.getByTestId('copy-username').click(); |
||||
|
await utils.checkNotification(page, 'Username copied'); |
||||
|
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(users.user1.name) |
||||
|
await page.getByTestId('copy-password').click(); |
||||
|
await utils.checkNotification(page, 'Password copied'); |
||||
|
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(users.user1.password) |
||||
|
await page.getByRole('button', { name: 'Close' }).click(); |
||||
|
}); |
||||
|
|
||||
|
await test.step('Delete', async () => { |
||||
|
await page.getByRole('row').filter({ hasText: label }).getByLabel('Options').click(); |
||||
|
await page.getByRole('menuitem', { name: 'Delete' }).click(); |
||||
|
await page.getByRole('button', { name: 'Yes' }).click(); |
||||
|
await utils.checkNotification(page, 'Item sent to bin'); |
||||
|
}); |
||||
|
|
||||
|
// Log again
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Deleted', async () => { |
||||
|
await expect(page.getByRole('row').filter({ hasText: label })).toHaveCount(0) |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
test('SSH Key', async ({ context, page }, testInfo: TestInfo) => { |
||||
|
const label = 'Test SSH key'; |
||||
|
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
const privateKey = await test.step('Create key entry', async () => { |
||||
|
await page.getByRole('button', { name: 'New', exact: true }).click(); |
||||
|
await page.getByRole('menuitem', { name: 'SSH key' }).click(); |
||||
|
await page.getByRole('textbox', { name: 'Item name * (required)' }).fill('Test SSH key'); |
||||
|
await page.getByRole('button', { name: 'Save' }).click(); |
||||
|
await utils.checkNotification(page, 'Item added'); |
||||
|
|
||||
|
await page.getByRole('button', { name: 'Copy private key' }).click(); |
||||
|
await utils.checkNotification(page, 'Private key copied'); |
||||
|
return await page.evaluate(() => navigator.clipboard.readText()); |
||||
|
}); |
||||
|
|
||||
|
// Log again
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Check', async () => { |
||||
|
await page.getByRole('row').filter({ hasText: label }).getByRole('button', { name: label }).click(); |
||||
|
|
||||
|
await page.getByRole('button', { name: 'Copy private key' }).click(); |
||||
|
await utils.checkNotification(page, 'Private key copied'); |
||||
|
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(privateKey) |
||||
|
await page.getByRole('button', { name: 'Close' }).click(); |
||||
|
}); |
||||
|
|
||||
|
await test.step('Delete', async () => { |
||||
|
await page.getByRole('row').filter({ hasText: label }).getByLabel('Options').click(); |
||||
|
await page.getByRole('menuitem', { name: 'Delete' }).click(); |
||||
|
await page.getByRole('button', { name: 'Yes' }).click(); |
||||
|
await utils.checkNotification(page, 'Item sent to bin'); |
||||
|
}); |
||||
|
|
||||
|
// Log again
|
||||
|
await logUser(test, page, users.user1); |
||||
|
|
||||
|
await test.step('Deleted', async () => { |
||||
|
await expect(page.getByRole('row').filter({ hasText: label })).toHaveCount(0) |
||||
|
}) |
||||
|
}); |
||||
@ -0,0 +1,21 @@ |
|||||
|
import { expect, type Browser, Page } from '@playwright/test'; |
||||
|
import * as utils from '../../global-utils'; |
||||
|
|
||||
|
utils.loadEnv(); |
||||
|
|
||||
|
export async function login(test, page: Page) { |
||||
|
await test.step(`Admin login`, async () => { |
||||
|
await page.goto('/admin'); |
||||
|
await page.getByRole('textbox', { name: 'Enter admin token' }).fill(process.env.ADMIN_TOKEN); |
||||
|
await page.getByRole('button', { name: 'Enter' }).click(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
export async function invite(test, page: Page, email: string) { |
||||
|
await test.step(`Invite user with ${email}`, async () => { |
||||
|
await page.getByRole('link', { name: 'Users' }).click(); |
||||
|
await page.getByRole('textbox', { name: 'Enter email' }).fill(email); |
||||
|
await page.getByRole('button', { name: 'Invite' }).click(); |
||||
|
await expect(page.getByRole('row', { name: email })).toHaveText(/Invited/); |
||||
|
}); |
||||
|
} |
||||
Loading…
Reference in new issue