mirror of
https://github.com/inventree/InvenTree.git
synced 2026-07-10 17:11:01 +00:00
[PUI] Session authentication (#6970)
* Adjust backend cookie settings * Allow CORS requests to /accounts/ * Refactor frontend code - Remove API token functions - Simplify cookie approach - Add isLoggedIn method * Adjust REST_AUTH settings * Cleanup auth functions in auth.tsx * Adjust CSRF_COOKIE_SAMESITE value * Fix login request * Prevent session auth on login view - Existing (invalid) session token causes 403 * Refactor ApiImage - Point to the right host - Simplify code - Now we use session cookies, so it *Just Works* * Fix download for attachment table - Now works with remote host * Cleanup settings.py * Refactor login / logout notifications * Update API version * Update src/frontend/src/components/items/AttachmentLink.tsx Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com> * fix assert url * Remove comment * Add explicit page to logout user * Change tests to first logout * Prune dead code * Adjust tests * Cleanup * Direct to login view * Trying something * Update CUI test * Fix basic tests * Refactoring * Fix basic checks * Fix for PUI command tests * More test updates * Add speciifc test for quick login * More cleanup of playwright tests * Add some missing icons * Fix typo * Ignore coverage report for playwright test * Remove coveralls upload task --------- Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com> Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
@@ -1,28 +1,37 @@
|
||||
import { expect, test } from './baseFixtures.js';
|
||||
import { classicUrl, user } from './defaults.js';
|
||||
import { baseUrl, loginUrl, logoutUrl, user } from './defaults.js';
|
||||
import { doLogin, doQuickLogin } from './login.js';
|
||||
|
||||
test('PUI - Basic test via django', async ({ page }) => {
|
||||
await page.goto(`${classicUrl}/platform/`);
|
||||
await expect(page).toHaveTitle('InvenTree Demo Server');
|
||||
await page.waitForURL('**/platform/');
|
||||
await page.getByLabel('username').fill(user.username);
|
||||
await page.getByLabel('password').fill(user.password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await page.waitForURL('**/platform/*');
|
||||
await page.goto(`${classicUrl}/platform/`);
|
||||
test('PUI - Basic Login Test', async ({ page }) => {
|
||||
await doLogin(page);
|
||||
|
||||
await expect(page).toHaveTitle('InvenTree Demo Server');
|
||||
});
|
||||
// Check that the username is provided
|
||||
await page.getByText(user.username);
|
||||
|
||||
test('PUI - Basic test', async ({ page }) => {
|
||||
await page.goto('./platform/');
|
||||
await expect(page).toHaveTitle('InvenTree');
|
||||
await page.waitForURL('**/platform/');
|
||||
await page.getByLabel('username').fill(user.username);
|
||||
await page.getByLabel('password').fill(user.password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(page).toHaveTitle(RegExp('^InvenTree'));
|
||||
|
||||
// Go to the dashboard
|
||||
await page.goto(baseUrl);
|
||||
await page.waitForURL('**/platform');
|
||||
await page.goto('./platform/');
|
||||
|
||||
await expect(page).toHaveTitle('InvenTree');
|
||||
await page
|
||||
.getByRole('heading', { name: `Welcome to your Dashboard, ${user.name}` })
|
||||
.click();
|
||||
});
|
||||
|
||||
test('PUI - Quick Login Test', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
// Check that the username is provided
|
||||
await page.getByText(user.username);
|
||||
|
||||
await expect(page).toHaveTitle(RegExp('^InvenTree'));
|
||||
|
||||
// Go to the dashboard
|
||||
await page.goto(baseUrl);
|
||||
await page.waitForURL('**/platform');
|
||||
|
||||
await page
|
||||
.getByRole('heading', { name: `Welcome to your Dashboard, ${user.name}` })
|
||||
.click();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user