mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-05-24 01:12:54 -04:00
* initial oidc implementation * add dynamic scheme * e2e test setup * add caching * fix * try this * add libldap-2.5 to runtime dependencies (#2849) * New translations en-us.json (Norwegian) (#2851) * New Crowdin updates (#2855) * New translations en-us.json (Italian) * New translations en-us.json (Norwegian) * New translations en-us.json (Portuguese) * fix * remove cache * cache yarn deps * cache docker image * cleanup action * lint * fix tests * remove not needed variables * run code gen * fix tests * add docs * move code into custom scheme * remove unneeded type * fix oidc admin * add more tests * add better spacing on login page * create auth providers * clean up testing stuff * type fixes * add OIDC auth method to postgres enum * add option to bypass login screen and go directly to iDP * remove check so we can fallback to another auth method oauth fails * Add provider name to be shown at the login screen * add new properties to admin about api * fix spec * add a prompt to change auth method when changing password * Create new auth section. Add more info on auth methods * update docs * run ruff * update docs * format * docs gen * formatting * initialize logger in class * mypy type fixes * docs gen * add models to get proper fields in docs and fix serialization * validate id token before using it * only request a mealie token on initial callback * remove unused method * fix unit tests * docs gen * check for valid idToken before getting token * add iss to mealie token * check to see if we already have a mealie token before getting one * fix lock file * update authlib * update lock file * add remember me environment variable * add user group setting to allow only certain groups to log in --------- Co-authored-by: Carter Mintey <cmintey8@gmail.com> Co-authored-by: Carter <35710697+cmintey@users.noreply.github.com>
141 lines
6.1 KiB
TypeScript
141 lines
6.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test('password login', async ({ page }) => {
|
|
const username = "changeme@example.com"
|
|
const password = "MyPassword"
|
|
const name = "Change Me"
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByLabel('Email or Username').click();
|
|
await page.getByLabel('Email or Username').fill(username);
|
|
await page.locator('div').filter({ hasText: /^Password$/ }).nth(3).click();
|
|
await page.getByLabel('Password').fill(password);
|
|
await page.getByRole('button', { name: 'Login', exact: true }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
});
|
|
|
|
test('ldap login', async ({ page }) => {
|
|
const username = "bender"
|
|
const password = "bender"
|
|
const name = "Bender Bending Rodríguez"
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByLabel('Email or Username').click();
|
|
await page.getByLabel('Email or Username').fill(username);
|
|
await page.locator('div').filter({ hasText: /^Password$/ }).nth(3).click();
|
|
await page.getByLabel('Password').fill(password);
|
|
await page.getByRole('button', { name: 'Login', exact: true }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
await expect(page.getByRole('link', { name: 'Settings' })).not.toBeVisible();
|
|
});
|
|
|
|
test('ldap admin login', async ({ page }) => {
|
|
const username = "professor"
|
|
const password = "professor"
|
|
const name = "Hubert J. Farnsworth"
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByLabel('Email or Username').click();
|
|
await page.getByLabel('Email or Username').fill(username);
|
|
await page.locator('div').filter({ hasText: /^Password$/ }).nth(3).click();
|
|
await page.getByLabel('Password').fill(password);
|
|
await page.getByRole('button', { name: 'Login', exact: true }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
await expect(page.getByRole('link', { name: 'Settings' })).toBeVisible();
|
|
});
|
|
|
|
test('oidc initial login', async ({ page }) => {
|
|
const username = "testUser"
|
|
const name = "Test User"
|
|
const claims = {
|
|
"sub": username,
|
|
"email": `${username}@example.com`,
|
|
"preferred_username": username,
|
|
"name": name
|
|
}
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByRole('button', { name: 'Login with OAuth' }).click();
|
|
await page.getByPlaceholder('Enter any user/subject').fill(username);
|
|
await page.getByPlaceholder('Optional claims JSON value,').fill(JSON.stringify(claims));
|
|
await page.getByRole('button', { name: 'Sign-in' }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
await expect(page.getByRole('link', { name: 'Settings' })).not.toBeVisible();
|
|
});
|
|
|
|
test('oidc sequential login', async ({ page }) => {
|
|
const username = "testUser2"
|
|
const name = "Test User 2"
|
|
const claims = {
|
|
"sub": username,
|
|
"email": `${username}@example.com`,
|
|
"preferred_username": username,
|
|
"name": name
|
|
}
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByRole('button', { name: 'Login with OAuth' }).click();
|
|
await page.getByPlaceholder('Enter any user/subject').fill(username);
|
|
await page.getByPlaceholder('Optional claims JSON value,').fill(JSON.stringify(claims));
|
|
await page.getByRole('button', { name: 'Sign-in' }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
await page.getByRole('button', { name: 'Logout' }).click();
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByRole('button', { name: 'Login with OAuth' }).click();
|
|
await page.getByPlaceholder('Enter any user/subject').fill(username);
|
|
await page.getByPlaceholder('Optional claims JSON value,').fill(JSON.stringify(claims));
|
|
await page.getByRole('button', { name: 'Sign-in' }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
});
|
|
|
|
test('settings page verify oidc', async ({ page }) => {
|
|
const username = "oidcUser"
|
|
const name = "OIDC User"
|
|
const claims = {
|
|
"sub": username,
|
|
"email": `${username}@example.com`,
|
|
"preferred_username": username,
|
|
"name": name
|
|
}
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByRole('button', { name: 'Login with OAuth' }).click();
|
|
await page.getByPlaceholder('Enter any user/subject').fill(username);
|
|
await page.getByPlaceholder('Optional claims JSON value,').fill(JSON.stringify(claims));
|
|
await page.getByRole('button', { name: 'Sign-in' }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
await page.getByRole('button', { name: 'Logout' }).click();
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByLabel('Email or Username').click();
|
|
await page.getByLabel('Email or Username').fill('changeme@example.com');
|
|
await page.getByLabel('Password').click();
|
|
await page.getByLabel('Password').fill('MyPassword');
|
|
await page.getByRole('button', { name: 'Login', exact: true }).click();
|
|
await page.getByRole('link', { name: 'Settings' }).click();
|
|
await page.getByRole('link', { name: 'Users' }).click();
|
|
await page.getByRole('cell', { name: username, exact: true }).click();
|
|
await expect(page.getByText('Permissions Administrator')).toBeVisible();
|
|
});
|
|
|
|
test('oidc admin user', async ({ page }) => {
|
|
const username = "oidcAdmin"
|
|
const name = "OIDC Admin"
|
|
const claims = {
|
|
"sub": username,
|
|
"email": `${username}@example.com`,
|
|
"preferred_username": username,
|
|
"name": name,
|
|
"groups": ["admin"]
|
|
}
|
|
|
|
await page.goto('http://localhost:9000/login');
|
|
await page.getByRole('button', { name: 'Login with OAuth' }).click();
|
|
await page.getByPlaceholder('Enter any user/subject').fill(username);
|
|
await page.getByPlaceholder('Optional claims JSON value,').fill(JSON.stringify(claims));
|
|
await page.getByRole('button', { name: 'Sign-in' }).click();
|
|
await expect(page.getByRole('navigation')).toContainText(name);
|
|
await expect(page.getByRole('link', { name: 'Settings' })).toBeVisible();
|
|
});
|